This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test_map = detector.evaluate(dataset_test) | |
| print(f"The mAP on the test dataset is {test_map[1][1]}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| image = 'mixed_10.jpg' | |
| image_path = os.path.join(data_root, 'JPEGImages', image) | |
| ind, prob, loc = detector.predict(image_path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| savefile = 'model.pkl' | |
| detector.save(savefile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| serverless create --template aws-python3 --path scale-machine-learning-w-pytorch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| def hello(event, context): | |
| body = { | |
| "message": "Go Serverless v1.0! Your function executed successfully!", | |
| "input":event | |
| } | |
| response = { | |
| "statusCode": 200, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| serverless plugin install -n serverless-python-requirements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp38-cp38-linux_x86_64.whl | |
| torchvision==0.6.0 | |
| requests_toolbelt |