Skip to content

Instantly share code, notes, and snippets.

View philschmid's full-sized avatar

Philipp Schmid philschmid

View GitHub Profile
from autogluon import ObjectDetection as task
epochs = 20
detector = task.fit(dataset_train,
num_trials=3,
epochs=epochs,
lr=ag.Categorical(5e-4, 1e-4, 3e-4),
ngpus_per_trial=1)
# download the data
root = './'
filename_zip = ag.download('https://philschmid-datasets.s3.eu-central-1.amazonaws.com/tiny_fruit.zip',
path=root)
# unzip data
filename = ag.unzip(filename_zip, root=root)
# create Dataset
data_root = os.path.join(root, filename)
# train dataset
test_map = detector.evaluate(dataset_test)
print(f"The mAP on the test dataset is {test_map[1][1]}")
image = 'mixed_10.jpg'
image_path = os.path.join(data_root, 'JPEGImages', image)
ind, prob, loc = detector.predict(image_path)
savefile = 'model.pkl'
detector.save(savefile)
from autogluon import Detector
new_detector = Detector.load(savefile)
image = 'mixed_17.jpg'
image_path = os.path.join(data_root, 'JPEGImages', image)
detector.predict(image_path)
serverless create --template aws-python3 --path scale-machine-learning-w-pytorch
import json
def hello(event, context):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input":event
}
response = {
"statusCode": 200,
serverless plugin install -n serverless-python-requirements
https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp38-cp38-linux_x86_64.whl
torchvision==0.6.0
requests_toolbelt