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)
Downloading ./tiny_motorbike.zip from https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip...
21273KB [00:00, 69683.30KB/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/24939/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 0x7ff13898c1d0>, '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: 8.856, ObjLoss=1939.499,BoxCenterLoss=3.811,BoxScaleLoss=2.432,ClassLoss=0.994
[Epoch 0] Validation: motorbike=0.0202020202020202 mAP=0.0202020202020202
[Epoch 1] Training cost: 3.707, ObjLoss=70.842,BoxCenterLoss=3.615,BoxScaleLoss=1.564,ClassLoss=0.824
[Epoch 1] Validation: motorbike=0.0703090013434841 mAP=0.0703090013434841
[Epoch 2] Training cost: 3.858, ObjLoss=34.758,BoxCenterLoss=3.665,BoxScaleLoss=1.367,ClassLoss=0.827
[Epoch 2] Validation: motorbike=0.004022526146419952 mAP=0.004022526146419952
[Epoch 3] Training cost: 4.466, ObjLoss=29.525,BoxCenterLoss=3.833,BoxScaleLoss=1.174,ClassLoss=0.832
[Epoch 3] Validation: motorbike=0.04184117598751745 mAP=0.04184117598751745
[Epoch 4] Training cost: 3.280, ObjLoss=22.257,BoxCenterLoss=3.503,BoxScaleLoss=1.080,ClassLoss=0.702
[Epoch 4] Validation: motorbike=0.21172026076288417 mAP=0.21172026076288417
[Epoch 5] Training cost: 3.462, ObjLoss=35.381,BoxCenterLoss=3.396,BoxScaleLoss=1.100,ClassLoss=0.639
[Epoch 5] Validation: motorbike=0.13723212404517082 mAP=0.13723212404517082
[Epoch 6] Training cost: 7.094, ObjLoss=21.140,BoxCenterLoss=3.646,BoxScaleLoss=1.161,ClassLoss=0.561
[Epoch 6] Validation: motorbike=0.256973581973582 mAP=0.256973581973582
[Epoch 7] Training cost: 7.362, ObjLoss=14.521,BoxCenterLoss=3.710,BoxScaleLoss=1.091,ClassLoss=0.499
[Epoch 7] Validation: motorbike=0.3036049740289115 mAP=0.3036049740289115
[Epoch 8] Training cost: 6.640, ObjLoss=14.686,BoxCenterLoss=3.616,BoxScaleLoss=0.925,ClassLoss=0.442
[Epoch 8] Validation: motorbike=0.39189333878329097 mAP=0.39189333878329097
[Epoch 9] Training cost: 3.346, ObjLoss=50.145,BoxCenterLoss=3.685,BoxScaleLoss=1.014,ClassLoss=0.524
[Epoch 9] Validation: motorbike=0.35482672026555007 mAP=0.35482672026555007
[Epoch 10] Training cost: 6.569, ObjLoss=22.721,BoxCenterLoss=3.574,BoxScaleLoss=1.153,ClassLoss=0.362
[Epoch 10] Validation: motorbike=0.45742014742014736 mAP=0.45742014742014736
[Epoch 11] Training cost: 7.356, ObjLoss=18.652,BoxCenterLoss=3.692,BoxScaleLoss=1.036,ClassLoss=0.338
[Epoch 11] Validation: motorbike=0.3981888025058128 mAP=0.3981888025058128
[Epoch 12] Training cost: 5.170, ObjLoss=24.401,BoxCenterLoss=3.594,BoxScaleLoss=0.936,ClassLoss=0.353
[Epoch 12] Validation: motorbike=0.5764705882352941 mAP=0.5764705882352941
[Epoch 13] Training cost: 4.379, ObjLoss=33.359,BoxCenterLoss=3.672,BoxScaleLoss=0.959,ClassLoss=0.353
[Epoch 13] Validation: motorbike=0.6236749611848493 mAP=0.6236749611848493
[Epoch 14] Training cost: 5.061, ObjLoss=17.053,BoxCenterLoss=3.493,BoxScaleLoss=0.790,ClassLoss=0.286
[Epoch 14] Validation: motorbike=0.5595981747297537 mAP=0.5595981747297537
[Epoch 15] Training cost: 4.453, ObjLoss=21.010,BoxCenterLoss=3.827,BoxScaleLoss=1.005,ClassLoss=0.346
[Epoch 15] Validation: motorbike=0.5792654808959157 mAP=0.5792654808959157
[Epoch 16] Training cost: 4.512, ObjLoss=8.414,BoxCenterLoss=3.520,BoxScaleLoss=0.860,ClassLoss=0.272
[Epoch 16] Validation: motorbike=0.610720155342581 mAP=0.610720155342581
[Epoch 17] Training cost: 3.813, ObjLoss=9.311,BoxCenterLoss=3.544,BoxScaleLoss=0.889,ClassLoss=0.316
[Epoch 17] Validation: motorbike=0.6631779984721161 mAP=0.6631779984721161
[Epoch 18] Training cost: 5.863, ObjLoss=8.147,BoxCenterLoss=3.442,BoxScaleLoss=0.960,ClassLoss=0.231
[Epoch 18] Validation: motorbike=0.6869236961646829 mAP=0.6869236961646829
[Epoch 19] Training cost: 6.769, ObjLoss=8.386,BoxCenterLoss=3.557,BoxScaleLoss=0.858,ClassLoss=0.217
[Epoch 19] Validation: motorbike=0.6370599522142172 mAP=0.6370599522142172
[Epoch 20] Training cost: 3.640, ObjLoss=8.574,BoxCenterLoss=3.532,BoxScaleLoss=1.026,ClassLoss=0.258
[Epoch 20] Validation: motorbike=0.6410256410256411 mAP=0.6410256410256411
[Epoch 21] Training cost: 3.870, ObjLoss=6.776,BoxCenterLoss=3.589,BoxScaleLoss=0.967,ClassLoss=0.259
[Epoch 21] Validation: motorbike=0.643338346283772 mAP=0.643338346283772
[Epoch 22] Training cost: 4.371, ObjLoss=8.565,BoxCenterLoss=3.634,BoxScaleLoss=0.999,ClassLoss=0.243
[Epoch 22] Validation: motorbike=0.5723804615011291 mAP=0.5723804615011291
[Epoch 23] Training cost: 4.198, ObjLoss=12.245,BoxCenterLoss=3.665,BoxScaleLoss=0.949,ClassLoss=0.274
[Epoch 23] Validation: motorbike=0.6960804033365009 mAP=0.6960804033365009
[Epoch 24] Training cost: 6.213, ObjLoss=7.855,BoxCenterLoss=3.548,BoxScaleLoss=0.867,ClassLoss=0.177
[Epoch 24] Validation: motorbike=0.5168679964473918 mAP=0.5168679964473918
[Epoch 25] Training cost: 6.361, ObjLoss=7.336,BoxCenterLoss=3.667,BoxScaleLoss=0.831,ClassLoss=0.186
[Epoch 25] Validation: motorbike=0.6528813926513382 mAP=0.6528813926513382
[Epoch 26] Training cost: 3.193, ObjLoss=7.823,BoxCenterLoss=3.677,BoxScaleLoss=0.980,ClassLoss=0.273
[Epoch 26] Validation: motorbike=0.677027096423856 mAP=0.677027096423856
[Epoch 27] Training cost: 5.355, ObjLoss=6.805,BoxCenterLoss=3.468,BoxScaleLoss=0.836,ClassLoss=0.178
[Epoch 27] Validation: motorbike=0.6965474254206648 mAP=0.6965474254206648
[Epoch 28] Training cost: 3.446, ObjLoss=6.295,BoxCenterLoss=3.563,BoxScaleLoss=0.946,ClassLoss=0.301
[Epoch 28] Validation: motorbike=0.6620733652312601 mAP=0.6620733652312601
[Epoch 29] Training cost: 5.858, ObjLoss=6.216,BoxCenterLoss=3.724,BoxScaleLoss=0.845,ClassLoss=0.183
[Epoch 29] Validation: motorbike=0.6513211367756823 mAP=0.6513211367756823
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7ff078087ed0>, '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: 8.727, ObjLoss=2028.565,BoxCenterLoss=3.998,BoxScaleLoss=3.402,ClassLoss=1.193
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 3.487, ObjLoss=24.088,BoxCenterLoss=3.659,BoxScaleLoss=1.959,ClassLoss=0.891
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 4.305, ObjLoss=26.064,BoxCenterLoss=3.757,BoxScaleLoss=1.751,ClassLoss=0.796
[Epoch 2] Validation: motorbike=0.09090909090909091 mAP=0.09090909090909091
[Epoch 3] Training cost: 4.814, ObjLoss=14.723,BoxCenterLoss=3.710,BoxScaleLoss=1.530,ClassLoss=0.768
[Epoch 3] Validation: motorbike=0.2321110262286733 mAP=0.2321110262286733
[Epoch 4] Training cost: 3.456, ObjLoss=12.259,BoxCenterLoss=3.699,BoxScaleLoss=1.371,ClassLoss=0.755
[Epoch 4] Validation: motorbike=0.4194828469022018 mAP=0.4194828469022018
[Epoch 5] Training cost: 3.465, ObjLoss=9.803,BoxCenterLoss=3.708,BoxScaleLoss=1.407,ClassLoss=0.785
[Epoch 5] Validation: motorbike=0.5244002336483539 mAP=0.5244002336483539
[Epoch 6] Training cost: 7.070, ObjLoss=8.228,BoxCenterLoss=3.689,BoxScaleLoss=1.331,ClassLoss=0.647
[Epoch 6] Validation: motorbike=0.5737583647889759 mAP=0.5737583647889759
[Epoch 7] Training cost: 7.338, ObjLoss=7.477,BoxCenterLoss=3.726,BoxScaleLoss=1.070,ClassLoss=0.614
[Epoch 7] Validation: motorbike=0.5484720014131779 mAP=0.5484720014131779
[Epoch 8] Training cost: 6.873, ObjLoss=6.684,BoxCenterLoss=3.639,BoxScaleLoss=1.047,ClassLoss=0.524
[Epoch 8] Validation: motorbike=0.4573482410815876 mAP=0.4573482410815876
[Epoch 9] Training cost: 3.578, ObjLoss=7.242,BoxCenterLoss=3.611,BoxScaleLoss=1.130,ClassLoss=0.627
[Epoch 9] Validation: motorbike=0.6252376045687221 mAP=0.6252376045687221
[Epoch 10] Training cost: 7.023, ObjLoss=6.918,BoxCenterLoss=3.679,BoxScaleLoss=0.959,ClassLoss=0.528
[Epoch 10] Validation: motorbike=0.5763484278835269 mAP=0.5763484278835269
[Epoch 11] Training cost: 7.499, ObjLoss=6.828,BoxCenterLoss=3.739,BoxScaleLoss=0.985,ClassLoss=0.494
[Epoch 11] Validation: motorbike=0.6575025618503879 mAP=0.6575025618503879
[Epoch 12] Training cost: 5.675, ObjLoss=5.611,BoxCenterLoss=3.737,BoxScaleLoss=0.968,ClassLoss=0.496
[Epoch 12] Validation: motorbike=0.6557522802509433 mAP=0.6557522802509433
[Epoch 13] Training cost: 4.249, ObjLoss=5.436,BoxCenterLoss=3.503,BoxScaleLoss=0.935,ClassLoss=0.462
[Epoch 13] Validation: motorbike=0.6935395484500343 mAP=0.6935395484500343
[Epoch 14] Training cost: 5.092, ObjLoss=5.423,BoxCenterLoss=3.581,BoxScaleLoss=0.839,ClassLoss=0.451
[Epoch 14] Validation: motorbike=0.7143027311325966 mAP=0.7143027311325966
[Epoch 15] Training cost: 4.517, ObjLoss=5.122,BoxCenterLoss=3.600,BoxScaleLoss=0.921,ClassLoss=0.451
[Epoch 15] Validation: motorbike=0.7132725859998588 mAP=0.7132725859998588
[Epoch 16] Training cost: 4.668, ObjLoss=5.269,BoxCenterLoss=3.543,BoxScaleLoss=0.956,ClassLoss=0.451
[Epoch 16] Validation: motorbike=0.7231381473418208 mAP=0.7231381473418208
[Epoch 17] Training cost: 3.998, ObjLoss=4.971,BoxCenterLoss=3.550,BoxScaleLoss=0.879,ClassLoss=0.419
[Epoch 17] Validation: motorbike=0.7599785698172795 mAP=0.7599785698172795
[Epoch 18] Training cost: 5.987, ObjLoss=5.003,BoxCenterLoss=3.577,BoxScaleLoss=0.793,ClassLoss=0.362
[Epoch 18] Validation: motorbike=0.7512628316010982 mAP=0.7512628316010982
[Epoch 19] Training cost: 7.080, ObjLoss=5.450,BoxCenterLoss=3.666,BoxScaleLoss=0.938,ClassLoss=0.377
[Epoch 19] Validation: motorbike=0.740621587714611 mAP=0.740621587714611
[Epoch 20] Training cost: 3.919, ObjLoss=5.100,BoxCenterLoss=3.615,BoxScaleLoss=0.933,ClassLoss=0.427
[Epoch 20] Validation: motorbike=0.7544368510277601 mAP=0.7544368510277601
[Epoch 21] Training cost: 3.937, ObjLoss=5.476,BoxCenterLoss=3.717,BoxScaleLoss=0.899,ClassLoss=0.418
[Epoch 21] Validation: motorbike=0.7810960172204191 mAP=0.7810960172204191
[Epoch 22] Training cost: 4.306, ObjLoss=4.563,BoxCenterLoss=3.643,BoxScaleLoss=0.885,ClassLoss=0.377
[Epoch 22] Validation: motorbike=0.7750817772931716 mAP=0.7750817772931716
[Epoch 23] Training cost: 3.933, ObjLoss=4.587,BoxCenterLoss=3.436,BoxScaleLoss=0.867,ClassLoss=0.363
[Epoch 23] Validation: motorbike=0.7865527254241987 mAP=0.7865527254241987
[Epoch 24] Training cost: 6.077, ObjLoss=4.948,BoxCenterLoss=3.680,BoxScaleLoss=0.829,ClassLoss=0.262
[Epoch 24] Validation: motorbike=0.7462678622601017 mAP=0.7462678622601017
[Epoch 25] Training cost: 6.539, ObjLoss=4.705,BoxCenterLoss=3.370,BoxScaleLoss=0.820,ClassLoss=0.255
[Epoch 25] Validation: motorbike=0.7999278073039966 mAP=0.7999278073039966
[Epoch 26] Training cost: 3.301, ObjLoss=4.707,BoxCenterLoss=3.412,BoxScaleLoss=0.807,ClassLoss=0.352
[Epoch 26] Validation: motorbike=0.7576423158047171 mAP=0.7576423158047171
[Epoch 27] Training cost: 5.379, ObjLoss=4.255,BoxCenterLoss=3.562,BoxScaleLoss=0.803,ClassLoss=0.261
[Epoch 27] Validation: motorbike=0.7853519358354949 mAP=0.7853519358354949
[Epoch 28] Training cost: 3.329, ObjLoss=5.133,BoxCenterLoss=3.603,BoxScaleLoss=0.900,ClassLoss=0.400
[Epoch 28] Validation: motorbike=0.765107880625122 mAP=0.765107880625122
[Epoch 29] Training cost: 5.893, ObjLoss=4.450,BoxCenterLoss=3.417,BoxScaleLoss=0.822,ClassLoss=0.258
[Epoch 29] Validation: motorbike=0.8110125985125984 mAP=0.8110125985125984
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7ff073ef89d0>, '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.242, ObjLoss=713.990,BoxCenterLoss=3.921,BoxScaleLoss=2.682,ClassLoss=1.015
[Epoch 1] Training cost: 5.575, ObjLoss=16.437,BoxCenterLoss=3.990,BoxScaleLoss=2.177,ClassLoss=0.910
[Epoch 2] Training cost: 6.330, ObjLoss=13.123,BoxCenterLoss=3.672,BoxScaleLoss=1.672,ClassLoss=0.765
[Epoch 3] Training cost: 9.041, ObjLoss=9.745,BoxCenterLoss=3.668,BoxScaleLoss=1.545,ClassLoss=0.669
[Epoch 4] Training cost: 5.231, ObjLoss=7.909,BoxCenterLoss=3.738,BoxScaleLoss=1.513,ClassLoss=0.672
[Epoch 5] Training cost: 7.578, ObjLoss=7.239,BoxCenterLoss=3.747,BoxScaleLoss=1.320,ClassLoss=0.554
[Epoch 6] Training cost: 7.561, ObjLoss=6.544,BoxCenterLoss=3.556,BoxScaleLoss=1.131,ClassLoss=0.469
[Epoch 7] Training cost: 4.733, ObjLoss=6.275,BoxCenterLoss=3.585,BoxScaleLoss=1.222,ClassLoss=0.532
[Epoch 8] Training cost: 7.110, ObjLoss=6.226,BoxCenterLoss=3.754,BoxScaleLoss=1.127,ClassLoss=0.461
[Epoch 9] Training cost: 6.300, ObjLoss=5.871,BoxCenterLoss=3.593,BoxScaleLoss=1.054,ClassLoss=0.423
[Epoch 10] Training cost: 4.574, ObjLoss=5.339,BoxCenterLoss=3.492,BoxScaleLoss=0.988,ClassLoss=0.428
[Epoch 11] Training cost: 6.190, ObjLoss=5.122,BoxCenterLoss=3.425,BoxScaleLoss=0.977,ClassLoss=0.359
[Epoch 12] Training cost: 6.324, ObjLoss=5.281,BoxCenterLoss=3.736,BoxScaleLoss=1.057,ClassLoss=0.406
[Epoch 13] Training cost: 8.364, ObjLoss=5.735,BoxCenterLoss=3.535,BoxScaleLoss=0.951,ClassLoss=0.293
[Epoch 14] Training cost: 6.643, ObjLoss=5.282,BoxCenterLoss=3.683,BoxScaleLoss=1.012,ClassLoss=0.349
[Epoch 15] Training cost: 5.358, ObjLoss=5.067,BoxCenterLoss=3.699,BoxScaleLoss=0.970,ClassLoss=0.356
[Epoch 16] Training cost: 3.841, ObjLoss=4.969,BoxCenterLoss=3.532,BoxScaleLoss=1.053,ClassLoss=0.392
[Epoch 17] Training cost: 4.271, ObjLoss=4.932,BoxCenterLoss=3.551,BoxScaleLoss=1.038,ClassLoss=0.387
[Epoch 18] Training cost: 8.022, ObjLoss=5.158,BoxCenterLoss=3.449,BoxScaleLoss=0.904,ClassLoss=0.230
[Epoch 19] Training cost: 3.996, ObjLoss=5.018,BoxCenterLoss=3.485,BoxScaleLoss=0.998,ClassLoss=0.332
[Epoch 20] Training cost: 5.608, ObjLoss=4.339,BoxCenterLoss=3.553,BoxScaleLoss=0.877,ClassLoss=0.291
[Epoch 21] Training cost: 6.223, ObjLoss=4.582,BoxCenterLoss=3.559,BoxScaleLoss=0.945,ClassLoss=0.258
[Epoch 22] Training cost: 5.465, ObjLoss=4.378,BoxCenterLoss=3.468,BoxScaleLoss=0.941,ClassLoss=0.253
[Epoch 23] Training cost: 5.308, ObjLoss=4.664,BoxCenterLoss=3.499,BoxScaleLoss=0.919,ClassLoss=0.266
[Epoch 24] Training cost: 6.292, ObjLoss=4.557,BoxCenterLoss=3.555,BoxScaleLoss=0.851,ClassLoss=0.226
[Epoch 25] Training cost: 7.864, ObjLoss=4.686,BoxCenterLoss=3.386,BoxScaleLoss=0.901,ClassLoss=0.216
[Epoch 26] Training cost: 5.645, ObjLoss=4.351,BoxCenterLoss=3.490,BoxScaleLoss=0.932,ClassLoss=0.217
[Epoch 27] Training cost: 6.160, ObjLoss=3.979,BoxCenterLoss=3.303,BoxScaleLoss=0.797,ClassLoss=0.172
[Epoch 28] Training cost: 8.114, ObjLoss=4.427,BoxCenterLoss=3.244,BoxScaleLoss=0.777,ClassLoss=0.142
[Epoch 29] Training cost: 4.107, ObjLoss=4.582,BoxCenterLoss=3.445,BoxScaleLoss=0.889,ClassLoss=0.269
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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]))
>>> create dataset(VOC format)
mAP on test dataset: 0.8403263454141987

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)