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, 52838.45KB/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/25467/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 0x7ff2f0df6110>, '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: 6.217, ObjLoss=744.308,BoxCenterLoss=4.008,BoxScaleLoss=2.472,ClassLoss=0.920
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 7.491, ObjLoss=13.783,BoxCenterLoss=3.678,BoxScaleLoss=1.862,ClassLoss=0.718
[Epoch 1] Validation: motorbike=0.3950387072795518 mAP=0.3950387072795518
[Epoch 2] Training cost: 3.066, ObjLoss=15.242,BoxCenterLoss=3.662,BoxScaleLoss=1.492,ClassLoss=0.756
[Epoch 2] Validation: motorbike=0.39591972460099895 mAP=0.39591972460099895
[Epoch 3] Training cost: 7.154, ObjLoss=26.138,BoxCenterLoss=3.693,BoxScaleLoss=1.174,ClassLoss=0.542
[Epoch 3] Validation: motorbike=0.3359374588084157 mAP=0.3359374588084157
[Epoch 4] Training cost: 5.822, ObjLoss=17.933,BoxCenterLoss=3.797,BoxScaleLoss=1.119,ClassLoss=0.447
[Epoch 4] Validation: motorbike=0.694550747058584 mAP=0.694550747058584
[Epoch 5] Training cost: 6.928, ObjLoss=8.664,BoxCenterLoss=3.568,BoxScaleLoss=1.134,ClassLoss=0.358
[Epoch 5] Validation: motorbike=0.4619435592033424 mAP=0.4619435592033424
[Epoch 6] Training cost: 5.349, ObjLoss=9.221,BoxCenterLoss=3.815,BoxScaleLoss=1.205,ClassLoss=0.422
[Epoch 6] Validation: motorbike=0.5361198297274322 mAP=0.5361198297274322
[Epoch 7] Training cost: 6.501, ObjLoss=6.770,BoxCenterLoss=3.599,BoxScaleLoss=1.065,ClassLoss=0.314
[Epoch 7] Validation: motorbike=0.7538991311718585 mAP=0.7538991311718585
[Epoch 8] Training cost: 3.592, ObjLoss=7.652,BoxCenterLoss=3.646,BoxScaleLoss=1.092,ClassLoss=0.391
[Epoch 8] Validation: motorbike=0.6527019782654312 mAP=0.6527019782654312
[Epoch 9] Training cost: 4.664, ObjLoss=13.189,BoxCenterLoss=3.583,BoxScaleLoss=1.104,ClassLoss=0.341
[Epoch 9] Validation: motorbike=0.6858739160314554 mAP=0.6858739160314554
[Epoch 10] Training cost: 5.516, ObjLoss=8.907,BoxCenterLoss=3.677,BoxScaleLoss=1.169,ClassLoss=0.280
[Epoch 10] Validation: motorbike=0.6706664136158881 mAP=0.6706664136158881
[Epoch 11] Training cost: 4.684, ObjLoss=10.638,BoxCenterLoss=3.574,BoxScaleLoss=1.085,ClassLoss=0.329
[Epoch 11] Validation: motorbike=0.7155957535810787 mAP=0.7155957535810787
[Epoch 12] Training cost: 3.910, ObjLoss=10.006,BoxCenterLoss=3.658,BoxScaleLoss=1.138,ClassLoss=0.379
[Epoch 12] Validation: motorbike=0.7959235886065156 mAP=0.7959235886065156
[Epoch 13] Training cost: 5.421, ObjLoss=5.795,BoxCenterLoss=3.676,BoxScaleLoss=0.971,ClassLoss=0.240
[Epoch 13] Validation: motorbike=0.7628097916027425 mAP=0.7628097916027425
[Epoch 14] Training cost: 3.673, ObjLoss=5.608,BoxCenterLoss=3.502,BoxScaleLoss=1.050,ClassLoss=0.322
[Epoch 14] Validation: motorbike=0.7558316935589663 mAP=0.7558316935589663
[Epoch 15] Training cost: 6.834, ObjLoss=5.590,BoxCenterLoss=3.676,BoxScaleLoss=0.964,ClassLoss=0.259
[Epoch 15] Validation: motorbike=0.757007681106353 mAP=0.757007681106353
[Epoch 16] Training cost: 3.309, ObjLoss=5.579,BoxCenterLoss=3.596,BoxScaleLoss=0.991,ClassLoss=0.323
[Epoch 16] Validation: motorbike=0.7802342300556586 mAP=0.7802342300556586
[Epoch 17] Training cost: 5.518, ObjLoss=4.743,BoxCenterLoss=3.566,BoxScaleLoss=0.913,ClassLoss=0.224
[Epoch 17] Validation: motorbike=0.7621572871572873 mAP=0.7621572871572873
[Epoch 18] Training cost: 5.265, ObjLoss=5.238,BoxCenterLoss=3.524,BoxScaleLoss=0.854,ClassLoss=0.220
[Epoch 18] Validation: motorbike=0.8278879658431735 mAP=0.8278879658431735
[Epoch 19] Training cost: 3.447, ObjLoss=5.397,BoxCenterLoss=3.521,BoxScaleLoss=0.916,ClassLoss=0.320
[Epoch 19] Validation: motorbike=0.8723905723905727 mAP=0.8723905723905727
[Epoch 20] Training cost: 3.897, ObjLoss=5.579,BoxCenterLoss=3.543,BoxScaleLoss=0.931,ClassLoss=0.227
[Epoch 20] Validation: motorbike=0.8570504698553478 mAP=0.8570504698553478
[Epoch 21] Training cost: 3.093, ObjLoss=5.405,BoxCenterLoss=3.301,BoxScaleLoss=0.869,ClassLoss=0.263
[Epoch 21] Validation: motorbike=0.8515151515151516 mAP=0.8515151515151516
[Epoch 22] Training cost: 5.749, ObjLoss=5.072,BoxCenterLoss=3.708,BoxScaleLoss=0.944,ClassLoss=0.160
[Epoch 22] Validation: motorbike=0.8061958880373202 mAP=0.8061958880373202
[Epoch 23] Training cost: 6.817, ObjLoss=5.050,BoxCenterLoss=3.537,BoxScaleLoss=0.905,ClassLoss=0.141
[Epoch 23] Validation: motorbike=0.8604752691911947 mAP=0.8604752691911947
[Epoch 24] Training cost: 4.105, ObjLoss=4.677,BoxCenterLoss=3.351,BoxScaleLoss=0.915,ClassLoss=0.218
[Epoch 24] Validation: motorbike=0.7302174858634188 mAP=0.7302174858634188
[Epoch 25] Training cost: 3.541, ObjLoss=4.940,BoxCenterLoss=3.518,BoxScaleLoss=0.962,ClassLoss=0.271
[Epoch 25] Validation: motorbike=0.8551559281818595 mAP=0.8551559281818595
[Epoch 26] Training cost: 3.879, ObjLoss=4.307,BoxCenterLoss=3.615,BoxScaleLoss=1.020,ClassLoss=0.209
[Epoch 26] Validation: motorbike=0.7980928162746345 mAP=0.7980928162746345
[Epoch 27] Training cost: 7.637, ObjLoss=4.917,BoxCenterLoss=3.228,BoxScaleLoss=0.810,ClassLoss=0.125
[Epoch 27] Validation: motorbike=0.813566745495455 mAP=0.813566745495455
[Epoch 28] Training cost: 6.985, ObjLoss=4.520,BoxCenterLoss=3.387,BoxScaleLoss=0.860,ClassLoss=0.137
[Epoch 28] Validation: motorbike=0.8520633783013679 mAP=0.8520633783013679
[Epoch 29] Training cost: 3.539, ObjLoss=4.099,BoxCenterLoss=3.110,BoxScaleLoss=0.826,ClassLoss=0.204
[Epoch 29] Validation: motorbike=0.8592729109970487 mAP=0.8592729109970487
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7ff225449950>, '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: 5.832, ObjLoss=887.693,BoxCenterLoss=4.074,BoxScaleLoss=3.207,ClassLoss=1.069
[Epoch 0] Validation: motorbike=0.09577942113347716 mAP=0.09577942113347716
[Epoch 1] Training cost: 7.555, ObjLoss=18.113,BoxCenterLoss=3.893,BoxScaleLoss=2.362,ClassLoss=0.953
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 3.273, ObjLoss=18.215,BoxCenterLoss=3.858,BoxScaleLoss=1.835,ClassLoss=0.867
[Epoch 2] Validation: motorbike=0.1590909090909091 mAP=0.1590909090909091
[Epoch 3] Training cost: 7.451, ObjLoss=11.805,BoxCenterLoss=3.605,BoxScaleLoss=1.536,ClassLoss=0.735
[Epoch 3] Validation: motorbike=0.3437935900020157 mAP=0.3437935900020157
[Epoch 4] Training cost: 6.185, ObjLoss=9.031,BoxCenterLoss=3.640,BoxScaleLoss=1.323,ClassLoss=0.638
[Epoch 4] Validation: motorbike=0.3465352049910873 mAP=0.3465352049910873
[Epoch 5] Training cost: 7.126, ObjLoss=7.439,BoxCenterLoss=3.622,BoxScaleLoss=1.292,ClassLoss=0.572
[Epoch 5] Validation: motorbike=0.46092125451719057 mAP=0.46092125451719057
[Epoch 6] Training cost: 5.373, ObjLoss=7.099,BoxCenterLoss=3.895,BoxScaleLoss=1.348,ClassLoss=0.658
[Epoch 6] Validation: motorbike=0.44713968925542713 mAP=0.44713968925542713
[Epoch 7] Training cost: 7.082, ObjLoss=6.764,BoxCenterLoss=3.665,BoxScaleLoss=1.141,ClassLoss=0.492
[Epoch 7] Validation: motorbike=0.578888888888889 mAP=0.578888888888889
[Epoch 8] Training cost: 3.558, ObjLoss=6.754,BoxCenterLoss=3.763,BoxScaleLoss=1.295,ClassLoss=0.595
[Epoch 8] Validation: motorbike=0.6374340138278988 mAP=0.6374340138278988
[Epoch 9] Training cost: 5.358, ObjLoss=5.895,BoxCenterLoss=3.685,BoxScaleLoss=1.119,ClassLoss=0.509
[Epoch 9] Validation: motorbike=0.6095765260490666 mAP=0.6095765260490666
[Epoch 10] Training cost: 5.920, ObjLoss=5.841,BoxCenterLoss=3.647,BoxScaleLoss=1.024,ClassLoss=0.437
[Epoch 10] Validation: motorbike=0.5944025037116047 mAP=0.5944025037116047
[Epoch 11] Training cost: 4.746, ObjLoss=5.787,BoxCenterLoss=3.789,BoxScaleLoss=1.183,ClassLoss=0.484
[Epoch 11] Validation: motorbike=0.7361423581084141 mAP=0.7361423581084141
[Epoch 12] Training cost: 3.878, ObjLoss=5.653,BoxCenterLoss=3.707,BoxScaleLoss=1.284,ClassLoss=0.562
[Epoch 12] Validation: motorbike=0.627933739301664 mAP=0.627933739301664
[Epoch 13] Training cost: 5.681, ObjLoss=5.416,BoxCenterLoss=3.646,BoxScaleLoss=1.075,ClassLoss=0.433
[Epoch 13] Validation: motorbike=0.7703919871231284 mAP=0.7703919871231284
[Epoch 14] Training cost: 3.703, ObjLoss=5.413,BoxCenterLoss=3.637,BoxScaleLoss=1.095,ClassLoss=0.452
[Epoch 14] Validation: motorbike=0.719221596647088 mAP=0.719221596647088
[Epoch 15] Training cost: 6.987, ObjLoss=5.602,BoxCenterLoss=3.804,BoxScaleLoss=1.156,ClassLoss=0.402
[Epoch 15] Validation: motorbike=0.7618202084686353 mAP=0.7618202084686353
[Epoch 16] Training cost: 3.405, ObjLoss=5.323,BoxCenterLoss=3.809,BoxScaleLoss=1.170,ClassLoss=0.490
[Epoch 16] Validation: motorbike=0.7442713508482129 mAP=0.7442713508482129
[Epoch 17] Training cost: 5.731, ObjLoss=4.808,BoxCenterLoss=3.567,BoxScaleLoss=0.985,ClassLoss=0.347
[Epoch 17] Validation: motorbike=0.8096065199699438 mAP=0.8096065199699438
[Epoch 18] Training cost: 5.077, ObjLoss=5.001,BoxCenterLoss=3.467,BoxScaleLoss=0.919,ClassLoss=0.302
[Epoch 18] Validation: motorbike=0.820557013256504 mAP=0.820557013256504
[Epoch 19] Training cost: 3.577, ObjLoss=5.132,BoxCenterLoss=3.606,BoxScaleLoss=1.053,ClassLoss=0.423
[Epoch 19] Validation: motorbike=0.7810658147556544 mAP=0.7810658147556544
[Epoch 20] Training cost: 4.204, ObjLoss=4.588,BoxCenterLoss=3.448,BoxScaleLoss=0.946,ClassLoss=0.337
[Epoch 20] Validation: motorbike=0.8149311343571244 mAP=0.8149311343571244
[Epoch 21] Training cost: 3.155, ObjLoss=5.118,BoxCenterLoss=3.408,BoxScaleLoss=1.008,ClassLoss=0.422
[Epoch 21] Validation: motorbike=0.8308023415977963 mAP=0.8308023415977963
[Epoch 22] Training cost: 6.013, ObjLoss=5.419,BoxCenterLoss=3.714,BoxScaleLoss=0.873,ClassLoss=0.272
[Epoch 22] Validation: motorbike=0.840684154064436 mAP=0.840684154064436
[Epoch 23] Training cost: 7.275, ObjLoss=5.000,BoxCenterLoss=3.600,BoxScaleLoss=0.941,ClassLoss=0.255
[Epoch 23] Validation: motorbike=0.8158693579148125 mAP=0.8158693579148125
[Epoch 24] Training cost: 3.971, ObjLoss=4.585,BoxCenterLoss=3.552,BoxScaleLoss=0.889,ClassLoss=0.295
[Epoch 24] Validation: motorbike=0.8179690908793078 mAP=0.8179690908793078
[Epoch 25] Training cost: 3.476, ObjLoss=4.933,BoxCenterLoss=3.508,BoxScaleLoss=0.942,ClassLoss=0.369
[Epoch 25] Validation: motorbike=0.8290463821892394 mAP=0.8290463821892394
[Epoch 26] Training cost: 4.086, ObjLoss=4.472,BoxCenterLoss=3.651,BoxScaleLoss=0.993,ClassLoss=0.328
[Epoch 26] Validation: motorbike=0.8153537266067011 mAP=0.8153537266067011
[Epoch 27] Training cost: 7.691, ObjLoss=4.967,BoxCenterLoss=3.529,BoxScaleLoss=0.920,ClassLoss=0.196
[Epoch 27] Validation: motorbike=0.8427489177489178 mAP=0.8427489177489178
[Epoch 28] Training cost: 6.725, ObjLoss=5.158,BoxCenterLoss=3.449,BoxScaleLoss=0.914,ClassLoss=0.186
[Epoch 28] Validation: motorbike=0.8074838269811299 mAP=0.8074838269811299
[Epoch 29] Training cost: 3.553, ObjLoss=4.554,BoxCenterLoss=3.320,BoxScaleLoss=0.967,ClassLoss=0.289
[Epoch 29] Validation: motorbike=0.8197023306930428 mAP=0.8197023306930428
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7ff2f0bbd8d0>, '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': 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.266, ObjLoss=599.985,BoxCenterLoss=3.695,BoxScaleLoss=2.488,ClassLoss=0.912
[Epoch 1] Training cost: 5.358, ObjLoss=21.360,BoxCenterLoss=3.667,BoxScaleLoss=1.555,ClassLoss=0.785
[Epoch 2] Training cost: 6.215, ObjLoss=13.282,BoxCenterLoss=3.686,BoxScaleLoss=1.285,ClassLoss=0.614
[Epoch 3] Training cost: 9.127, ObjLoss=7.912,BoxCenterLoss=3.668,BoxScaleLoss=1.201,ClassLoss=0.460
[Epoch 4] Training cost: 5.238, ObjLoss=7.100,BoxCenterLoss=3.643,BoxScaleLoss=1.083,ClassLoss=0.446
[Epoch 5] Training cost: 7.410, ObjLoss=6.026,BoxCenterLoss=3.514,BoxScaleLoss=0.991,ClassLoss=0.289
[Epoch 6] Training cost: 7.575, ObjLoss=6.740,BoxCenterLoss=3.555,BoxScaleLoss=1.015,ClassLoss=0.285
[Epoch 7] Training cost: 4.948, ObjLoss=9.694,BoxCenterLoss=3.531,BoxScaleLoss=1.079,ClassLoss=0.335
[Epoch 8] Training cost: 7.339, ObjLoss=9.628,BoxCenterLoss=3.670,BoxScaleLoss=0.993,ClassLoss=0.261
[Epoch 9] Training cost: 6.407, ObjLoss=6.899,BoxCenterLoss=3.448,BoxScaleLoss=0.904,ClassLoss=0.215
[Epoch 10] Training cost: 4.768, ObjLoss=5.107,BoxCenterLoss=3.338,BoxScaleLoss=0.805,ClassLoss=0.208
[Epoch 11] Training cost: 6.017, ObjLoss=4.836,BoxCenterLoss=3.375,BoxScaleLoss=0.755,ClassLoss=0.198
[Epoch 12] Training cost: 6.055, ObjLoss=5.185,BoxCenterLoss=3.547,BoxScaleLoss=0.919,ClassLoss=0.218
[Epoch 13] Training cost: 8.762, ObjLoss=5.921,BoxCenterLoss=3.558,BoxScaleLoss=0.942,ClassLoss=0.153
[Epoch 14] Training cost: 6.408, ObjLoss=4.722,BoxCenterLoss=3.441,BoxScaleLoss=0.853,ClassLoss=0.175
[Epoch 15] Training cost: 5.761, ObjLoss=5.019,BoxCenterLoss=3.479,BoxScaleLoss=0.986,ClassLoss=0.218
[Epoch 16] Training cost: 3.811, ObjLoss=4.561,BoxCenterLoss=3.413,BoxScaleLoss=0.883,ClassLoss=0.231
[Epoch 17] Training cost: 4.301, ObjLoss=4.101,BoxCenterLoss=3.306,BoxScaleLoss=0.800,ClassLoss=0.189
[Epoch 18] Training cost: 7.807, ObjLoss=5.025,BoxCenterLoss=3.505,BoxScaleLoss=1.029,ClassLoss=0.146
[Epoch 19] Training cost: 4.200, ObjLoss=4.952,BoxCenterLoss=3.555,BoxScaleLoss=1.001,ClassLoss=0.211
[Epoch 20] Training cost: 5.656, ObjLoss=4.201,BoxCenterLoss=3.477,BoxScaleLoss=0.898,ClassLoss=0.154
[Epoch 21] Training cost: 6.229, ObjLoss=3.791,BoxCenterLoss=3.405,BoxScaleLoss=0.745,ClassLoss=0.120
[Epoch 22] Training cost: 5.565, ObjLoss=3.905,BoxCenterLoss=3.389,BoxScaleLoss=0.824,ClassLoss=0.124
[Epoch 23] Training cost: 5.100, ObjLoss=3.661,BoxCenterLoss=3.389,BoxScaleLoss=0.828,ClassLoss=0.140
[Epoch 24] Training cost: 6.471, ObjLoss=3.537,BoxCenterLoss=3.376,BoxScaleLoss=0.892,ClassLoss=0.103
[Epoch 25] Training cost: 7.847, ObjLoss=3.788,BoxCenterLoss=3.281,BoxScaleLoss=0.712,ClassLoss=0.080
[Epoch 26] Training cost: 5.984, ObjLoss=3.441,BoxCenterLoss=3.464,BoxScaleLoss=0.760,ClassLoss=0.084
[Epoch 27] Training cost: 5.835, ObjLoss=3.683,BoxCenterLoss=3.287,BoxScaleLoss=0.825,ClassLoss=0.118
[Epoch 28] Training cost: 8.417, ObjLoss=4.152,BoxCenterLoss=3.308,BoxScaleLoss=0.711,ClassLoss=0.095
[Epoch 29] Training cost: 4.138, ObjLoss=5.001,BoxCenterLoss=3.505,BoxScaleLoss=0.831,ClassLoss=0.154
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> finish model fitting
The best config: {'lr▁choice': 0, '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.8657854819901728

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)
../../_images/output_beginner_1fd7a6_11_0.png

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)