Object Detection - Quick Start¶
Object detection is the process of identifying and localizing objects in an image and is an important task in computer vision. Follow this tutorial to learn how to use AutoGluon for object detection.
Tip: If you are new to AutoGluon, review Image Classification - Quick Start first to learn the basics of the AutoGluon API.
Our goal is to detect motorbike in images by YOLO3 model. A tiny dataset is collected from VOC dataset, which only contains the motorbike category. The model pretrained on the COCO dataset is used to fine-tune our small dataset. With the help of AutoGluon, we are able to try many models with different hyperparameters automatically, and return the best one as our final model.
To start, import autogluon and ObjectDetection module as your task:
import autogluon as ag
from autogluon import ObjectDetection as task
Tiny_motorbike Dataset¶
We collect a toy dataset for detecting motorbikes in images. From the VOC dataset, images are randomly selected for training, validation, and testing - 120 images for training, 50 images for validation, and 50 for testing. This tiny dataset follows the same format as VOC.
Using the commands below, we can download this dataset, which is only
23M. The variable root specifies the path to store the dataset in.
The name of unzipped folder is called tiny_motorbike.
root = './'
filename_zip = ag.download('https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip',
path=root)
filename = ag.unzip(filename_zip, root=root)
/var/lib/jenkins/miniconda3/envs/autogluon_docs/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: should_run_async will not call transform_cell automatically in the future. Please pass the result to transformed_cell argument and any exception that happen during thetransform in preprocessing_exc_tuple in IPython 7.17 and above. and should_run_async(code) Downloading ./tiny_motorbike.zip from https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip... 21273KB [00:00, 37761.91KB/s]
When we retrieve the dataset, we can create a dataset instance with its path and classes if it is a custom dataset.
import os
data_root = os.path.join(root, filename)
dataset_train = task.Dataset(data_root, classes=('motorbike',))
>>> create dataset(VOC format)
Fit Models by AutoGluon¶
In this section, we demonstrate how to apply AutoGluon to fit our detection models. We use mobilenet as the backbone for the YOLO3 model. Two different learning rates are used to fine-tune the network. The best model is the one that obtains the best performance on the validation dataset. You can also try using more networks and hyperparameters to create a larger searching space.
We fit a classifier using AutoGluon as follows. In each experiment
(one trial in our searching space), we train the model for 30 epoches.
time_limits = 5*60*60 # 5 hours
epochs = 30
detector = task.fit(dataset_train,
num_trials=2,
epochs=epochs,
lr=ag.Categorical(5e-4, 1e-4),
ngpus_per_trial=1,
time_limits=time_limits)
scheduler_options: Key 'training_history_callback_delta_secs': Imputing default value 60
scheduler_options: Key 'delay_get_config': Imputing default value True
Starting Experiments
Num of Finished Tasks is 0
Num of Pending Tasks is 2
scheduler: FIFOScheduler(
DistributedResourceManager{
(Remote: Remote REMOTE_ID: 0,
<Remote: 'inproc://172.31.41.232/9309/1' processes=1 threads=8, memory=33.24 GB>, Resource: NodeResourceManager(8 CPUs, 1 GPUs))
})
HBox(children=(FloatProgress(value=0.0, max=2.0), HTML(value='')))
Time out (secs) is 18000
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f75dc45ee10>, 'net': 'mobilenet1.0', 'lr': 0.0005, 'loss': SoftmaxCrossEntropyLoss(batch_axis=0, w=None), 'num_gpus': 1, 'batch_size': 16, 'split_ratio': 0.8, 'epochs': 30, 'num_workers': 8, 'hybridize': True, 'verbose': False, 'final_fit': False, 'seed': 223, 'data_shape': 416, 'start_epoch': 0, 'transfer': 'coco', 'lr_mode': 'step', 'lr_decay': 0.1, 'lr_decay_period': 0, 'lr_decay_epoch': '160,180', 'warmup_lr': 0.0, 'warmup_epochs': 2, 'warmup_iters': 1000, 'warmup_factor': 0.3333333333333333, 'momentum': 0.9, 'wd': 0.0005, 'log_interval': 100, 'save_prefix': 'yolo3_mobilenet1.0_custom', 'save_interval': 10, 'val_interval': 1, 'num_samples': -1, 'no_random_shape': False, 'no_wd': False, 'mixup': False, 'no_mixup_epochs': 20, 'label_smooth': False, 'resume': '', 'syncbn': False, 'reuse_pred_weights': True, 'task_id': 0}
[Epoch 0] Training cost: 9.263, ObjLoss=2154.776,BoxCenterLoss=3.556,BoxScaleLoss=2.291,ClassLoss=0.979
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 7.666, ObjLoss=121.157,BoxCenterLoss=3.322,BoxScaleLoss=1.405,ClassLoss=0.745
[Epoch 1] Validation: motorbike=0.000581362528055349 mAP=0.000581362528055349
[Epoch 2] Training cost: 2.822, ObjLoss=291.800,BoxCenterLoss=3.480,BoxScaleLoss=1.636,ClassLoss=0.790
[Epoch 2] Validation: motorbike=0.0 mAP=0.0
[Epoch 3] Training cost: 5.328, ObjLoss=97.136,BoxCenterLoss=3.294,BoxScaleLoss=1.208,ClassLoss=0.771
[Epoch 3] Validation: motorbike=0.0 mAP=0.0
[Epoch 4] Training cost: 5.000, ObjLoss=97.614,BoxCenterLoss=3.474,BoxScaleLoss=1.363,ClassLoss=0.798
[Epoch 4] Validation: motorbike=0.0 mAP=0.0
[Epoch 5] Training cost: 5.141, ObjLoss=75.751,BoxCenterLoss=3.235,BoxScaleLoss=1.199,ClassLoss=0.718
[Epoch 5] Validation: motorbike=0.054252199413489736 mAP=0.054252199413489736
[Epoch 6] Training cost: 4.502, ObjLoss=68.503,BoxCenterLoss=3.441,BoxScaleLoss=1.442,ClassLoss=0.705
[Epoch 6] Validation: motorbike=0.014930690864554917 mAP=0.014930690864554917
[Epoch 7] Training cost: 5.542, ObjLoss=42.044,BoxCenterLoss=3.356,BoxScaleLoss=1.060,ClassLoss=0.684
[Epoch 7] Validation: motorbike=0.04386602870813397 mAP=0.04386602870813397
[Epoch 8] Training cost: 2.935, ObjLoss=61.555,BoxCenterLoss=3.404,BoxScaleLoss=1.182,ClassLoss=0.696
[Epoch 8] Validation: motorbike=0.04938482570061517 mAP=0.04938482570061517
[Epoch 9] Training cost: 3.715, ObjLoss=41.235,BoxCenterLoss=3.333,BoxScaleLoss=0.995,ClassLoss=0.652
[Epoch 9] Validation: motorbike=0.07845865840388055 mAP=0.07845865840388055
[Epoch 10] Training cost: 4.938, ObjLoss=26.982,BoxCenterLoss=3.372,BoxScaleLoss=1.129,ClassLoss=0.645
[Epoch 10] Validation: motorbike=0.023179169790098424 mAP=0.023179169790098424
[Epoch 11] Training cost: 7.655, ObjLoss=17.043,BoxCenterLoss=3.303,BoxScaleLoss=1.175,ClassLoss=0.568
[Epoch 11] Validation: motorbike=0.125 mAP=0.125
[Epoch 12] Training cost: 4.386, ObjLoss=19.094,BoxCenterLoss=3.364,BoxScaleLoss=1.078,ClassLoss=0.587
[Epoch 12] Validation: motorbike=0.05250377677063895 mAP=0.05250377677063895
[Epoch 13] Training cost: 3.921, ObjLoss=20.023,BoxCenterLoss=3.250,BoxScaleLoss=0.999,ClassLoss=0.578
[Epoch 13] Validation: motorbike=0.10690705942102592 mAP=0.10690705942102592
[Epoch 14] Training cost: 6.934, ObjLoss=13.386,BoxCenterLoss=3.209,BoxScaleLoss=1.192,ClassLoss=0.465
[Epoch 14] Validation: motorbike=0.16115702479338842 mAP=0.16115702479338842
[Epoch 15] Training cost: 5.193, ObjLoss=15.637,BoxCenterLoss=3.380,BoxScaleLoss=1.096,ClassLoss=0.520
[Epoch 15] Validation: motorbike=0.08636363636363636 mAP=0.08636363636363636
[Epoch 16] Training cost: 2.893, ObjLoss=32.662,BoxCenterLoss=3.276,BoxScaleLoss=1.025,ClassLoss=0.535
[Epoch 16] Validation: motorbike=0.08100441950616166 mAP=0.08100441950616166
[Epoch 17] Training cost: 6.987, ObjLoss=17.737,BoxCenterLoss=3.293,BoxScaleLoss=1.213,ClassLoss=0.438
[Epoch 17] Validation: motorbike=0.041666666666666664 mAP=0.041666666666666664
[Epoch 18] Training cost: 3.356, ObjLoss=18.556,BoxCenterLoss=3.389,BoxScaleLoss=1.078,ClassLoss=0.530
[Epoch 18] Validation: motorbike=0.0762366750509043 mAP=0.0762366750509043
[Epoch 19] Training cost: 4.466, ObjLoss=32.007,BoxCenterLoss=3.368,BoxScaleLoss=0.977,ClassLoss=0.500
[Epoch 19] Validation: motorbike=0.048484848484848485 mAP=0.048484848484848485
[Epoch 20] Training cost: 3.539, ObjLoss=29.989,BoxCenterLoss=3.309,BoxScaleLoss=0.955,ClassLoss=0.491
[Epoch 20] Validation: motorbike=0.14639905548996457 mAP=0.14639905548996457
[Epoch 21] Training cost: 4.857, ObjLoss=26.980,BoxCenterLoss=3.317,BoxScaleLoss=1.022,ClassLoss=0.430
[Epoch 21] Validation: motorbike=0.10448642266824085 mAP=0.10448642266824085
[Epoch 22] Training cost: 4.458, ObjLoss=19.538,BoxCenterLoss=3.303,BoxScaleLoss=0.971,ClassLoss=0.424
[Epoch 22] Validation: motorbike=0.08195592286501377 mAP=0.08195592286501377
[Epoch 23] Training cost: 3.789, ObjLoss=24.228,BoxCenterLoss=3.325,BoxScaleLoss=1.021,ClassLoss=0.482
[Epoch 23] Validation: motorbike=0.0382549801764388 mAP=0.0382549801764388
[Epoch 24] Training cost: 4.742, ObjLoss=15.388,BoxCenterLoss=3.307,BoxScaleLoss=1.112,ClassLoss=0.393
[Epoch 24] Validation: motorbike=0.17353660831921702 mAP=0.17353660831921702
[Epoch 25] Training cost: 6.792, ObjLoss=14.006,BoxCenterLoss=3.332,BoxScaleLoss=1.146,ClassLoss=0.380
[Epoch 25] Validation: motorbike=0.08823529411764705 mAP=0.08823529411764705
[Epoch 26] Training cost: 4.765, ObjLoss=11.457,BoxCenterLoss=3.273,BoxScaleLoss=1.069,ClassLoss=0.369
[Epoch 26] Validation: motorbike=0.0808080808080808 mAP=0.0808080808080808
[Epoch 27] Training cost: 3.939, ObjLoss=13.438,BoxCenterLoss=3.295,BoxScaleLoss=1.077,ClassLoss=0.427
[Epoch 27] Validation: motorbike=0.11869684992214638 mAP=0.11869684992214638
[Epoch 28] Training cost: 5.164, ObjLoss=11.331,BoxCenterLoss=3.385,BoxScaleLoss=1.111,ClassLoss=0.389
[Epoch 28] Validation: motorbike=0.06269592476489029 mAP=0.06269592476489029
[Epoch 29] Training cost: 7.138, ObjLoss=131.990,BoxCenterLoss=3.336,BoxScaleLoss=1.193,ClassLoss=0.310
[Epoch 29] Validation: motorbike=0.020137166204581933 mAP=0.020137166204581933
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f7518a77910>, 'net': 'mobilenet1.0', 'lr': 0.0001, 'loss': SoftmaxCrossEntropyLoss(batch_axis=0, w=None), 'num_gpus': 1, 'batch_size': 16, 'split_ratio': 0.8, 'epochs': 30, 'num_workers': 8, 'hybridize': True, 'verbose': False, 'final_fit': False, 'seed': 223, 'data_shape': 416, 'start_epoch': 0, 'transfer': 'coco', 'lr_mode': 'step', 'lr_decay': 0.1, 'lr_decay_period': 0, 'lr_decay_epoch': '160,180', 'warmup_lr': 0.0, 'warmup_epochs': 2, 'warmup_iters': 1000, 'warmup_factor': 0.3333333333333333, 'momentum': 0.9, 'wd': 0.0005, 'log_interval': 100, 'save_prefix': 'yolo3_mobilenet1.0_custom', 'save_interval': 10, 'val_interval': 1, 'num_samples': -1, 'no_random_shape': False, 'no_wd': False, 'mixup': False, 'no_mixup_epochs': 20, 'label_smooth': False, 'resume': '', 'syncbn': False, 'reuse_pred_weights': True, 'task_id': 1}
[Epoch 0] Training cost: 9.342, ObjLoss=2236.140,BoxCenterLoss=3.696,BoxScaleLoss=2.979,ClassLoss=1.034
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 8.010, ObjLoss=22.149,BoxCenterLoss=3.553,BoxScaleLoss=1.994,ClassLoss=0.891
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 3.003, ObjLoss=27.603,BoxCenterLoss=3.409,BoxScaleLoss=1.782,ClassLoss=0.777
[Epoch 2] Validation: motorbike=0.0 mAP=0.0
[Epoch 3] Training cost: 5.625, ObjLoss=16.517,BoxCenterLoss=3.506,BoxScaleLoss=1.455,ClassLoss=0.689
[Epoch 3] Validation: motorbike=0.20525252525252524 mAP=0.20525252525252524
[Epoch 4] Training cost: 5.068, ObjLoss=10.424,BoxCenterLoss=3.328,BoxScaleLoss=1.262,ClassLoss=0.642
[Epoch 4] Validation: motorbike=0.30743553470826196 mAP=0.30743553470826196
[Epoch 5] Training cost: 5.087, ObjLoss=11.071,BoxCenterLoss=3.387,BoxScaleLoss=1.106,ClassLoss=0.648
[Epoch 5] Validation: motorbike=0.15374079392709236 mAP=0.15374079392709236
[Epoch 6] Training cost: 4.574, ObjLoss=9.187,BoxCenterLoss=3.327,BoxScaleLoss=1.169,ClassLoss=0.600
[Epoch 6] Validation: motorbike=0.24393794423635803 mAP=0.24393794423635803
[Epoch 7] Training cost: 5.782, ObjLoss=7.271,BoxCenterLoss=3.373,BoxScaleLoss=1.034,ClassLoss=0.572
[Epoch 7] Validation: motorbike=0.24371977742033013 mAP=0.24371977742033013
[Epoch 8] Training cost: 2.981, ObjLoss=7.774,BoxCenterLoss=3.231,BoxScaleLoss=1.141,ClassLoss=0.595
[Epoch 8] Validation: motorbike=0.4777786021364386 mAP=0.4777786021364386
[Epoch 9] Training cost: 3.767, ObjLoss=6.299,BoxCenterLoss=3.261,BoxScaleLoss=1.066,ClassLoss=0.550
[Epoch 9] Validation: motorbike=0.5032191619210467 mAP=0.5032191619210467
[Epoch 10] Training cost: 5.113, ObjLoss=6.050,BoxCenterLoss=3.234,BoxScaleLoss=0.946,ClassLoss=0.460
[Epoch 10] Validation: motorbike=0.5108245266211188 mAP=0.5108245266211188
[Epoch 11] Training cost: 7.634, ObjLoss=6.374,BoxCenterLoss=3.380,BoxScaleLoss=0.921,ClassLoss=0.426
[Epoch 11] Validation: motorbike=0.5905592727118831 mAP=0.5905592727118831
[Epoch 12] Training cost: 4.401, ObjLoss=5.177,BoxCenterLoss=3.196,BoxScaleLoss=0.896,ClassLoss=0.412
[Epoch 12] Validation: motorbike=0.5607789132467377 mAP=0.5607789132467377
[Epoch 13] Training cost: 3.948, ObjLoss=5.346,BoxCenterLoss=3.271,BoxScaleLoss=0.903,ClassLoss=0.464
[Epoch 13] Validation: motorbike=0.6799187245588334 mAP=0.6799187245588334
[Epoch 14] Training cost: 7.268, ObjLoss=5.696,BoxCenterLoss=3.234,BoxScaleLoss=0.850,ClassLoss=0.373
[Epoch 14] Validation: motorbike=0.7247433109155597 mAP=0.7247433109155597
[Epoch 15] Training cost: 5.380, ObjLoss=5.002,BoxCenterLoss=3.164,BoxScaleLoss=0.928,ClassLoss=0.390
[Epoch 15] Validation: motorbike=0.6963391165372417 mAP=0.6963391165372417
[Epoch 16] Training cost: 3.167, ObjLoss=5.461,BoxCenterLoss=3.266,BoxScaleLoss=0.931,ClassLoss=0.468
[Epoch 16] Validation: motorbike=0.6483974358974359 mAP=0.6483974358974359
[Epoch 17] Training cost: 7.214, ObjLoss=5.081,BoxCenterLoss=3.201,BoxScaleLoss=0.807,ClassLoss=0.296
[Epoch 17] Validation: motorbike=0.7255168530960155 mAP=0.7255168530960155
[Epoch 18] Training cost: 3.222, ObjLoss=4.912,BoxCenterLoss=3.275,BoxScaleLoss=0.893,ClassLoss=0.428
[Epoch 18] Validation: motorbike=0.6594077861365062 mAP=0.6594077861365062
[Epoch 19] Training cost: 4.873, ObjLoss=5.080,BoxCenterLoss=3.353,BoxScaleLoss=0.860,ClassLoss=0.403
[Epoch 19] Validation: motorbike=0.7398780000587976 mAP=0.7398780000587976
[Epoch 20] Training cost: 3.465, ObjLoss=4.822,BoxCenterLoss=3.128,BoxScaleLoss=0.787,ClassLoss=0.374
[Epoch 20] Validation: motorbike=0.7538219265218169 mAP=0.7538219265218169
[Epoch 21] Training cost: 4.742, ObjLoss=4.262,BoxCenterLoss=3.192,BoxScaleLoss=0.737,ClassLoss=0.317
[Epoch 21] Validation: motorbike=0.7420385170385171 mAP=0.7420385170385171
[Epoch 22] Training cost: 4.556, ObjLoss=4.366,BoxCenterLoss=3.238,BoxScaleLoss=0.834,ClassLoss=0.321
[Epoch 22] Validation: motorbike=0.7678940232307929 mAP=0.7678940232307929
[Epoch 23] Training cost: 3.761, ObjLoss=4.343,BoxCenterLoss=3.211,BoxScaleLoss=0.821,ClassLoss=0.368
[Epoch 23] Validation: motorbike=0.6985768621361841 mAP=0.6985768621361841
[Epoch 24] Training cost: 4.758, ObjLoss=4.135,BoxCenterLoss=3.338,BoxScaleLoss=0.748,ClassLoss=0.288
[Epoch 24] Validation: motorbike=0.770427391756323 mAP=0.770427391756323
[Epoch 25] Training cost: 6.482, ObjLoss=4.101,BoxCenterLoss=2.985,BoxScaleLoss=0.676,ClassLoss=0.208
[Epoch 25] Validation: motorbike=0.76116652223807 mAP=0.76116652223807
[Epoch 26] Training cost: 4.631, ObjLoss=4.266,BoxCenterLoss=3.326,BoxScaleLoss=0.767,ClassLoss=0.304
[Epoch 26] Validation: motorbike=0.7767399935180683 mAP=0.7767399935180683
[Epoch 27] Training cost: 3.868, ObjLoss=4.122,BoxCenterLoss=3.105,BoxScaleLoss=0.836,ClassLoss=0.317
[Epoch 27] Validation: motorbike=0.7285821592103425 mAP=0.7285821592103425
[Epoch 28] Training cost: 5.052, ObjLoss=4.188,BoxCenterLoss=3.307,BoxScaleLoss=0.783,ClassLoss=0.274
[Epoch 28] Validation: motorbike=0.7545062695924765 mAP=0.7545062695924765
[Epoch 29] Training cost: 7.340, ObjLoss=4.512,BoxCenterLoss=3.178,BoxScaleLoss=0.756,ClassLoss=0.216
[Epoch 29] Validation: motorbike=0.7014225181313591 mAP=0.7014225181313591
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f75dc519ad0>, 'net': 'mobilenet1.0', 'lr': 0.0001, 'loss': SoftmaxCrossEntropyLoss(batch_axis=0, w=None), 'num_gpus': 1, 'batch_size': 16, 'split_ratio': 0.8, 'epochs': 30, 'num_workers': 8, 'hybridize': True, 'verbose': False, 'final_fit': True, 'seed': 223, 'data_shape': 416, 'start_epoch': 0, 'transfer': 'coco', 'lr_mode': 'step', 'lr_decay': 0.1, 'lr_decay_period': 0, 'lr_decay_epoch': '160,180', 'warmup_lr': 0.0, 'warmup_epochs': 2, 'warmup_iters': 1000, 'warmup_factor': 0.3333333333333333, 'momentum': 0.9, 'wd': 0.0005, 'log_interval': 100, 'save_prefix': 'yolo3_mobilenet1.0_custom', 'save_interval': 10, 'val_interval': 1, 'num_samples': -1, 'no_random_shape': False, 'no_wd': False, 'mixup': False, 'no_mixup_epochs': 20, 'label_smooth': False, 'resume': '', 'syncbn': False, 'reuse_pred_weights': True, 'task_id': 2}
[Epoch 0] Training cost: 6.344, ObjLoss=713.591,BoxCenterLoss=3.979,BoxScaleLoss=2.899,ClassLoss=1.033
[Epoch 1] Training cost: 5.443, ObjLoss=15.457,BoxCenterLoss=3.757,BoxScaleLoss=2.154,ClassLoss=0.895
[Epoch 2] Training cost: 6.477, ObjLoss=13.234,BoxCenterLoss=3.783,BoxScaleLoss=1.724,ClassLoss=0.765
[Epoch 3] Training cost: 9.348, ObjLoss=9.586,BoxCenterLoss=3.657,BoxScaleLoss=1.393,ClassLoss=0.654
[Epoch 4] Training cost: 5.086, ObjLoss=7.864,BoxCenterLoss=3.679,BoxScaleLoss=1.468,ClassLoss=0.660
[Epoch 5] Training cost: 7.766, ObjLoss=7.430,BoxCenterLoss=3.836,BoxScaleLoss=1.382,ClassLoss=0.560
[Epoch 6] Training cost: 7.715, ObjLoss=6.534,BoxCenterLoss=3.622,BoxScaleLoss=1.173,ClassLoss=0.500
[Epoch 7] Training cost: 4.515, ObjLoss=6.162,BoxCenterLoss=3.547,BoxScaleLoss=1.123,ClassLoss=0.534
[Epoch 8] Training cost: 7.385, ObjLoss=6.292,BoxCenterLoss=3.827,BoxScaleLoss=1.123,ClassLoss=0.467
[Epoch 9] Training cost: 6.043, ObjLoss=5.359,BoxCenterLoss=3.359,BoxScaleLoss=0.976,ClassLoss=0.379
[Epoch 10] Training cost: 4.809, ObjLoss=5.693,BoxCenterLoss=3.664,BoxScaleLoss=1.103,ClassLoss=0.447
[Epoch 11] Training cost: 5.935, ObjLoss=5.250,BoxCenterLoss=3.618,BoxScaleLoss=1.045,ClassLoss=0.398
[Epoch 12] Training cost: 6.144, ObjLoss=5.230,BoxCenterLoss=3.577,BoxScaleLoss=0.948,ClassLoss=0.385
[Epoch 13] Training cost: 8.600, ObjLoss=5.672,BoxCenterLoss=3.506,BoxScaleLoss=0.980,ClassLoss=0.307
[Epoch 14] Training cost: 6.375, ObjLoss=5.472,BoxCenterLoss=3.660,BoxScaleLoss=1.060,ClassLoss=0.350
[Epoch 15] Training cost: 5.697, ObjLoss=4.917,BoxCenterLoss=3.587,BoxScaleLoss=1.025,ClassLoss=0.361
[Epoch 16] Training cost: 4.000, ObjLoss=4.753,BoxCenterLoss=3.393,BoxScaleLoss=0.965,ClassLoss=0.357
[Epoch 17] Training cost: 4.019, ObjLoss=4.521,BoxCenterLoss=3.421,BoxScaleLoss=0.909,ClassLoss=0.343
[Epoch 18] Training cost: 7.995, ObjLoss=5.689,BoxCenterLoss=3.616,BoxScaleLoss=0.984,ClassLoss=0.268
[Epoch 19] Training cost: 3.939, ObjLoss=4.489,BoxCenterLoss=3.309,BoxScaleLoss=0.994,ClassLoss=0.301
[Epoch 20] Training cost: 5.599, ObjLoss=4.636,BoxCenterLoss=3.588,BoxScaleLoss=0.906,ClassLoss=0.326
[Epoch 21] Training cost: 5.898, ObjLoss=4.506,BoxCenterLoss=3.569,BoxScaleLoss=0.878,ClassLoss=0.254
[Epoch 22] Training cost: 5.824, ObjLoss=4.399,BoxCenterLoss=3.541,BoxScaleLoss=0.919,ClassLoss=0.230
[Epoch 23] Training cost: 5.139, ObjLoss=4.236,BoxCenterLoss=3.470,BoxScaleLoss=0.882,ClassLoss=0.258
[Epoch 24] Training cost: 6.223, ObjLoss=4.770,BoxCenterLoss=3.473,BoxScaleLoss=0.898,ClassLoss=0.233
[Epoch 25] Training cost: 7.877, ObjLoss=4.487,BoxCenterLoss=3.344,BoxScaleLoss=0.860,ClassLoss=0.199
[Epoch 26] Training cost: 6.136, ObjLoss=4.721,BoxCenterLoss=3.502,BoxScaleLoss=0.937,ClassLoss=0.245
[Epoch 27] Training cost: 5.788, ObjLoss=4.208,BoxCenterLoss=3.368,BoxScaleLoss=0.886,ClassLoss=0.202
[Epoch 28] Training cost: 8.548, ObjLoss=5.047,BoxCenterLoss=3.592,BoxScaleLoss=0.849,ClassLoss=0.215
[Epoch 29] Training cost: 4.045, ObjLoss=4.652,BoxCenterLoss=3.584,BoxScaleLoss=0.927,ClassLoss=0.259
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> finish model fitting
The best config: {'lr▁choice': 1, 'net▁choice': 0}
Note that num_trials=2 above is only used to speed up the tutorial.
In normal practice, it is common to only use time_limits and drop
num_trials.
After fitting, AutoGluon automatically returns the best model among all models in the searching space. From the output, we know the best model is the one trained with the second learning rate. To see how well the returned model performed on test dataset, call detector.evaluate().
dataset_test = task.Dataset(data_root, index_file_name='test', classes=('motorbike',))
test_map = detector.evaluate(dataset_test)
print("mAP on test dataset: {}".format(test_map[1][1]))
/var/lib/jenkins/miniconda3/envs/autogluon_docs/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: should_run_async will not call transform_cell automatically in the future. Please pass the result to transformed_cell argument and any exception that happen during thetransform in preprocessing_exc_tuple in IPython 7.17 and above. and should_run_async(code) >>> create dataset(VOC format)
mAP on test dataset: 0.8236719893337853
Below, we randomly select an image from test dataset and show the predicted box and probability over the origin image.
image = '000467.jpg'
image_path = os.path.join(data_root, 'JPEGImages', image)
ind, prob, loc = detector.predict(image_path)
We can also save the trained model, and use it later.
savefile = 'model.pkl'
detector.save(savefile)
from autogluon import Detector
new_detector = Detector.load(savefile)