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, 59725.27KB/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)
Starting Experiments
Num of Finished Tasks is 0
Num of Pending Tasks is 2
Time out (secs) is 18000
scheduler: FIFOScheduler(
DistributedResourceManager{
(Remote: Remote REMOTE_ID: 0,
    <Remote: 'inproc://172.31.45.231/23041/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='')))
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f270418bb90>, '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: 2.960, ObjLoss=618.421,BoxCenterLoss=4.041,BoxScaleLoss=2.641,ClassLoss=0.968
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 2.683, ObjLoss=23.706,BoxCenterLoss=3.900,BoxScaleLoss=1.876,ClassLoss=0.791
[Epoch 1] Validation: motorbike=0.37882315287585505 mAP=0.37882315287585505
[Epoch 2] Training cost: 4.379, ObjLoss=14.130,BoxCenterLoss=4.042,BoxScaleLoss=1.493,ClassLoss=0.736
[Epoch 2] Validation: motorbike=0.5289340264019197 mAP=0.5289340264019197
[Epoch 3] Training cost: 3.232, ObjLoss=9.360,BoxCenterLoss=3.739,BoxScaleLoss=1.221,ClassLoss=0.629
[Epoch 3] Validation: motorbike=0.3943850844929091 mAP=0.3943850844929091
[Epoch 4] Training cost: 3.958, ObjLoss=8.065,BoxCenterLoss=3.857,BoxScaleLoss=1.063,ClassLoss=0.561
[Epoch 4] Validation: motorbike=0.6360140090870552 mAP=0.6360140090870552
[Epoch 5] Training cost: 4.877, ObjLoss=6.412,BoxCenterLoss=3.713,BoxScaleLoss=0.977,ClassLoss=0.395
[Epoch 5] Validation: motorbike=0.7267149112487159 mAP=0.7267149112487159
[Epoch 6] Training cost: 3.141, ObjLoss=6.409,BoxCenterLoss=3.696,BoxScaleLoss=1.016,ClassLoss=0.390
[Epoch 6] Validation: motorbike=0.6686683718092885 mAP=0.6686683718092885
[Epoch 7] Training cost: 3.205, ObjLoss=5.503,BoxCenterLoss=3.670,BoxScaleLoss=1.013,ClassLoss=0.393
[Epoch 7] Validation: motorbike=0.6661986661986663 mAP=0.6661986661986663
[Epoch 8] Training cost: 4.697, ObjLoss=6.128,BoxCenterLoss=3.852,BoxScaleLoss=1.188,ClassLoss=0.370
[Epoch 8] Validation: motorbike=0.7054357914345637 mAP=0.7054357914345637
[Epoch 9] Training cost: 4.248, ObjLoss=5.032,BoxCenterLoss=3.520,BoxScaleLoss=0.982,ClassLoss=0.269
[Epoch 9] Validation: motorbike=0.7664410058027081 mAP=0.7664410058027081
[Epoch 10] Training cost: 3.855, ObjLoss=4.575,BoxCenterLoss=3.574,BoxScaleLoss=0.971,ClassLoss=0.230
[Epoch 10] Validation: motorbike=0.7490206762934035 mAP=0.7490206762934035
[Epoch 11] Training cost: 7.665, ObjLoss=5.493,BoxCenterLoss=3.688,BoxScaleLoss=1.104,ClassLoss=0.191
[Epoch 11] Validation: motorbike=0.8255920550038198 mAP=0.8255920550038198
[Epoch 12] Training cost: 4.020, ObjLoss=5.500,BoxCenterLoss=3.673,BoxScaleLoss=1.052,ClassLoss=0.254
[Epoch 12] Validation: motorbike=0.8337171967042099 mAP=0.8337171967042099
[Epoch 13] Training cost: 4.086, ObjLoss=4.938,BoxCenterLoss=3.457,BoxScaleLoss=0.889,ClassLoss=0.208
[Epoch 13] Validation: motorbike=0.8336642267900819 mAP=0.8336642267900819
[Epoch 14] Training cost: 6.619, ObjLoss=5.666,BoxCenterLoss=3.807,BoxScaleLoss=1.028,ClassLoss=0.205
[Epoch 14] Validation: motorbike=0.8327264468440939 mAP=0.8327264468440939
[Epoch 15] Training cost: 6.949, ObjLoss=5.384,BoxCenterLoss=3.795,BoxScaleLoss=1.113,ClassLoss=0.180
[Epoch 15] Validation: motorbike=0.8133656312339699 mAP=0.8133656312339699
[Epoch 16] Training cost: 5.629, ObjLoss=4.983,BoxCenterLoss=3.740,BoxScaleLoss=1.027,ClassLoss=0.155
[Epoch 16] Validation: motorbike=0.7744247129273868 mAP=0.7744247129273868
[Epoch 17] Training cost: 5.027, ObjLoss=3.988,BoxCenterLoss=3.487,BoxScaleLoss=0.864,ClassLoss=0.209
[Epoch 17] Validation: motorbike=0.826715045215994 mAP=0.826715045215994
[Epoch 18] Training cost: 4.252, ObjLoss=4.069,BoxCenterLoss=3.371,BoxScaleLoss=0.886,ClassLoss=0.158
[Epoch 18] Validation: motorbike=0.8816349794406222 mAP=0.8816349794406222
[Epoch 19] Training cost: 6.649, ObjLoss=4.684,BoxCenterLoss=3.472,BoxScaleLoss=0.862,ClassLoss=0.143
[Epoch 19] Validation: motorbike=0.7714129011697721 mAP=0.7714129011697721
[Epoch 20] Training cost: 3.439, ObjLoss=4.517,BoxCenterLoss=3.435,BoxScaleLoss=0.939,ClassLoss=0.219
[Epoch 20] Validation: motorbike=0.7955784114875023 mAP=0.7955784114875023
[Epoch 21] Training cost: 3.242, ObjLoss=4.349,BoxCenterLoss=3.627,BoxScaleLoss=0.963,ClassLoss=0.208
[Epoch 21] Validation: motorbike=0.7500971250971251 mAP=0.7500971250971251
[Epoch 22] Training cost: 3.061, ObjLoss=4.564,BoxCenterLoss=3.625,BoxScaleLoss=0.894,ClassLoss=0.219
[Epoch 22] Validation: motorbike=0.8786328760753315 mAP=0.8786328760753315
[Epoch 23] Training cost: 2.716, ObjLoss=4.633,BoxCenterLoss=3.613,BoxScaleLoss=0.869,ClassLoss=0.239
[Epoch 23] Validation: motorbike=0.8627780265711301 mAP=0.8627780265711301
[Epoch 24] Training cost: 3.647, ObjLoss=4.373,BoxCenterLoss=3.523,BoxScaleLoss=0.992,ClassLoss=0.171
[Epoch 24] Validation: motorbike=0.8765958707307682 mAP=0.8765958707307682
[Epoch 25] Training cost: 3.228, ObjLoss=4.096,BoxCenterLoss=3.348,BoxScaleLoss=0.815,ClassLoss=0.160
[Epoch 25] Validation: motorbike=0.878115367018923 mAP=0.878115367018923
[Epoch 26] Training cost: 5.784, ObjLoss=4.581,BoxCenterLoss=3.498,BoxScaleLoss=0.963,ClassLoss=0.107
[Epoch 26] Validation: motorbike=0.8103165137486402 mAP=0.8103165137486402
[Epoch 27] Training cost: 6.715, ObjLoss=4.611,BoxCenterLoss=3.684,BoxScaleLoss=1.010,ClassLoss=0.129
[Epoch 27] Validation: motorbike=0.8420877515217138 mAP=0.8420877515217138
[Epoch 28] Training cost: 5.898, ObjLoss=4.679,BoxCenterLoss=3.662,BoxScaleLoss=0.811,ClassLoss=0.123
[Epoch 28] Validation: motorbike=0.8495498957714658 mAP=0.8495498957714658
[Epoch 29] Training cost: 6.236, ObjLoss=3.904,BoxCenterLoss=3.692,BoxScaleLoss=0.812,ClassLoss=0.103
[Epoch 29] Validation: motorbike=0.8373534553681613 mAP=0.8373534553681613
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f270552ac90>, '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: 2.879, ObjLoss=774.033,BoxCenterLoss=4.221,BoxScaleLoss=3.001,ClassLoss=1.087
[Epoch 0] Validation: motorbike=0.05108707249276966 mAP=0.05108707249276966
[Epoch 1] Training cost: 2.963, ObjLoss=17.206,BoxCenterLoss=4.175,BoxScaleLoss=2.494,ClassLoss=1.019
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 4.506, ObjLoss=15.148,BoxCenterLoss=4.102,BoxScaleLoss=2.144,ClassLoss=0.918
[Epoch 2] Validation: motorbike=0.12396694214876033 mAP=0.12396694214876033
[Epoch 3] Training cost: 3.471, ObjLoss=12.367,BoxCenterLoss=3.765,BoxScaleLoss=1.793,ClassLoss=0.756
[Epoch 3] Validation: motorbike=0.3850926850926851 mAP=0.3850926850926851
[Epoch 4] Training cost: 3.876, ObjLoss=8.553,BoxCenterLoss=3.697,BoxScaleLoss=1.406,ClassLoss=0.683
[Epoch 4] Validation: motorbike=0.42286989326463015 mAP=0.42286989326463015
[Epoch 5] Training cost: 5.313, ObjLoss=7.525,BoxCenterLoss=3.814,BoxScaleLoss=1.305,ClassLoss=0.673
[Epoch 5] Validation: motorbike=0.5696399354800763 mAP=0.5696399354800763
[Epoch 6] Training cost: 3.278, ObjLoss=6.773,BoxCenterLoss=3.813,BoxScaleLoss=1.391,ClassLoss=0.660
[Epoch 6] Validation: motorbike=0.5746891195167058 mAP=0.5746891195167058
[Epoch 7] Training cost: 3.540, ObjLoss=6.522,BoxCenterLoss=3.719,BoxScaleLoss=1.277,ClassLoss=0.596
[Epoch 7] Validation: motorbike=0.5914478884959433 mAP=0.5914478884959433
[Epoch 8] Training cost: 4.882, ObjLoss=6.549,BoxCenterLoss=4.015,BoxScaleLoss=1.204,ClassLoss=0.567
[Epoch 8] Validation: motorbike=0.6775810934901844 mAP=0.6775810934901844
[Epoch 9] Training cost: 4.326, ObjLoss=5.729,BoxCenterLoss=3.747,BoxScaleLoss=1.191,ClassLoss=0.468
[Epoch 9] Validation: motorbike=0.7501058786093158 mAP=0.7501058786093158
[Epoch 10] Training cost: 3.985, ObjLoss=5.592,BoxCenterLoss=3.555,BoxScaleLoss=1.067,ClassLoss=0.431
[Epoch 10] Validation: motorbike=0.7220100766766443 mAP=0.7220100766766443
[Epoch 11] Training cost: 7.938, ObjLoss=6.875,BoxCenterLoss=3.826,BoxScaleLoss=1.169,ClassLoss=0.427
[Epoch 11] Validation: motorbike=0.7630929573641739 mAP=0.7630929573641739
[Epoch 12] Training cost: 4.420, ObjLoss=5.826,BoxCenterLoss=3.836,BoxScaleLoss=1.172,ClassLoss=0.469
[Epoch 12] Validation: motorbike=0.7912023530072323 mAP=0.7912023530072323
[Epoch 13] Training cost: 4.365, ObjLoss=5.599,BoxCenterLoss=3.775,BoxScaleLoss=1.114,ClassLoss=0.405
[Epoch 13] Validation: motorbike=0.7761726689386265 mAP=0.7761726689386265
[Epoch 14] Training cost: 6.957, ObjLoss=5.847,BoxCenterLoss=3.851,BoxScaleLoss=1.069,ClassLoss=0.336
[Epoch 14] Validation: motorbike=0.8077741743221962 mAP=0.8077741743221962
[Epoch 15] Training cost: 7.630, ObjLoss=6.029,BoxCenterLoss=3.898,BoxScaleLoss=1.113,ClassLoss=0.396
[Epoch 15] Validation: motorbike=0.7779326021973081 mAP=0.7779326021973081
[Epoch 16] Training cost: 6.060, ObjLoss=5.876,BoxCenterLoss=3.966,BoxScaleLoss=1.042,ClassLoss=0.340
[Epoch 16] Validation: motorbike=0.7473155642872018 mAP=0.7473155642872018
[Epoch 17] Training cost: 5.095, ObjLoss=5.160,BoxCenterLoss=3.697,BoxScaleLoss=1.024,ClassLoss=0.343
[Epoch 17] Validation: motorbike=0.7708805944100063 mAP=0.7708805944100063
[Epoch 18] Training cost: 4.377, ObjLoss=4.914,BoxCenterLoss=3.738,BoxScaleLoss=1.001,ClassLoss=0.337
[Epoch 18] Validation: motorbike=0.7604978924319253 mAP=0.7604978924319253
[Epoch 19] Training cost: 6.852, ObjLoss=5.452,BoxCenterLoss=3.690,BoxScaleLoss=0.973,ClassLoss=0.287
[Epoch 19] Validation: motorbike=0.7974325132861717 mAP=0.7974325132861717
[Epoch 20] Training cost: 3.789, ObjLoss=5.377,BoxCenterLoss=3.784,BoxScaleLoss=1.019,ClassLoss=0.375
[Epoch 20] Validation: motorbike=0.7692219785243042 mAP=0.7692219785243042
[Epoch 21] Training cost: 3.358, ObjLoss=5.262,BoxCenterLoss=3.789,BoxScaleLoss=1.178,ClassLoss=0.386
[Epoch 21] Validation: motorbike=0.8054833031791557 mAP=0.8054833031791557
[Epoch 22] Training cost: 3.263, ObjLoss=4.791,BoxCenterLoss=3.597,BoxScaleLoss=1.018,ClassLoss=0.333
[Epoch 22] Validation: motorbike=0.7938672580616315 mAP=0.7938672580616315
[Epoch 23] Training cost: 3.031, ObjLoss=5.299,BoxCenterLoss=3.702,BoxScaleLoss=1.145,ClassLoss=0.401
[Epoch 23] Validation: motorbike=0.7557712086013973 mAP=0.7557712086013973
[Epoch 24] Training cost: 3.776, ObjLoss=4.674,BoxCenterLoss=3.506,BoxScaleLoss=0.976,ClassLoss=0.268
[Epoch 24] Validation: motorbike=0.8173101864685376 mAP=0.8173101864685376
[Epoch 25] Training cost: 3.400, ObjLoss=4.661,BoxCenterLoss=3.595,BoxScaleLoss=1.015,ClassLoss=0.321
[Epoch 25] Validation: motorbike=0.7770572358612226 mAP=0.7770572358612226
[Epoch 26] Training cost: 6.204, ObjLoss=5.063,BoxCenterLoss=3.677,BoxScaleLoss=1.041,ClassLoss=0.236
[Epoch 26] Validation: motorbike=0.8472432748092573 mAP=0.8472432748092573
[Epoch 27] Training cost: 7.018, ObjLoss=5.181,BoxCenterLoss=3.755,BoxScaleLoss=0.981,ClassLoss=0.208
[Epoch 27] Validation: motorbike=0.8455445889604086 mAP=0.8455445889604086
[Epoch 28] Training cost: 5.954, ObjLoss=5.115,BoxCenterLoss=3.882,BoxScaleLoss=1.044,ClassLoss=0.242
[Epoch 28] Validation: motorbike=0.8133770050766099 mAP=0.8133770050766099
[Epoch 29] Training cost: 6.333, ObjLoss=5.002,BoxCenterLoss=3.634,BoxScaleLoss=1.012,ClassLoss=0.220
[Epoch 29] Validation: motorbike=0.8256049071096093 mAP=0.8256049071096093
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f2704164110>, '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: 3.699, ObjLoss=600.962,BoxCenterLoss=3.743,BoxScaleLoss=2.342,ClassLoss=0.918
[Epoch 1] Training cost: 4.787, ObjLoss=17.015,BoxCenterLoss=3.697,BoxScaleLoss=1.454,ClassLoss=0.729
[Epoch 2] Training cost: 5.975, ObjLoss=17.074,BoxCenterLoss=3.681,BoxScaleLoss=1.169,ClassLoss=0.599
[Epoch 3] Training cost: 9.150, ObjLoss=11.386,BoxCenterLoss=3.579,BoxScaleLoss=1.211,ClassLoss=0.429
[Epoch 4] Training cost: 4.726, ObjLoss=8.757,BoxCenterLoss=3.700,BoxScaleLoss=1.175,ClassLoss=0.452
[Epoch 5] Training cost: 7.341, ObjLoss=7.555,BoxCenterLoss=3.724,BoxScaleLoss=1.141,ClassLoss=0.335
[Epoch 6] Training cost: 7.330, ObjLoss=7.205,BoxCenterLoss=3.470,BoxScaleLoss=0.924,ClassLoss=0.275
[Epoch 7] Training cost: 4.496, ObjLoss=8.218,BoxCenterLoss=3.538,BoxScaleLoss=1.046,ClassLoss=0.342
[Epoch 8] Training cost: 7.046, ObjLoss=7.191,BoxCenterLoss=3.723,BoxScaleLoss=1.045,ClassLoss=0.278
[Epoch 9] Training cost: 5.953, ObjLoss=6.016,BoxCenterLoss=3.326,BoxScaleLoss=0.847,ClassLoss=0.229
[Epoch 10] Training cost: 4.273, ObjLoss=6.242,BoxCenterLoss=3.379,BoxScaleLoss=0.917,ClassLoss=0.262
[Epoch 11] Training cost: 5.724, ObjLoss=5.438,BoxCenterLoss=3.499,BoxScaleLoss=0.907,ClassLoss=0.275
[Epoch 12] Training cost: 6.077, ObjLoss=5.535,BoxCenterLoss=3.464,BoxScaleLoss=0.859,ClassLoss=0.226
[Epoch 13] Training cost: 8.117, ObjLoss=5.996,BoxCenterLoss=3.425,BoxScaleLoss=0.921,ClassLoss=0.191
[Epoch 14] Training cost: 6.232, ObjLoss=5.258,BoxCenterLoss=3.507,BoxScaleLoss=0.915,ClassLoss=0.169
[Epoch 15] Training cost: 4.822, ObjLoss=5.437,BoxCenterLoss=3.433,BoxScaleLoss=0.824,ClassLoss=0.207
[Epoch 16] Training cost: 3.950, ObjLoss=5.017,BoxCenterLoss=3.504,BoxScaleLoss=0.913,ClassLoss=0.252
[Epoch 17] Training cost: 3.626, ObjLoss=5.220,BoxCenterLoss=3.417,BoxScaleLoss=0.904,ClassLoss=0.224
[Epoch 18] Training cost: 7.477, ObjLoss=4.823,BoxCenterLoss=3.216,BoxScaleLoss=0.868,ClassLoss=0.125
[Epoch 19] Training cost: 3.718, ObjLoss=4.213,BoxCenterLoss=3.442,BoxScaleLoss=0.910,ClassLoss=0.206
[Epoch 20] Training cost: 5.429, ObjLoss=4.025,BoxCenterLoss=3.301,BoxScaleLoss=0.857,ClassLoss=0.174
[Epoch 21] Training cost: 5.637, ObjLoss=3.608,BoxCenterLoss=3.511,BoxScaleLoss=0.773,ClassLoss=0.123
[Epoch 22] Training cost: 5.234, ObjLoss=3.988,BoxCenterLoss=3.416,BoxScaleLoss=0.801,ClassLoss=0.147
[Epoch 23] Training cost: 5.233, ObjLoss=3.802,BoxCenterLoss=3.346,BoxScaleLoss=0.861,ClassLoss=0.135
[Epoch 24] Training cost: 6.075, ObjLoss=3.864,BoxCenterLoss=3.375,BoxScaleLoss=0.829,ClassLoss=0.116
[Epoch 25] Training cost: 7.848, ObjLoss=4.187,BoxCenterLoss=3.364,BoxScaleLoss=0.815,ClassLoss=0.127
[Epoch 26] Training cost: 5.401, ObjLoss=4.248,BoxCenterLoss=3.584,BoxScaleLoss=0.824,ClassLoss=0.132
[Epoch 27] Training cost: 6.136, ObjLoss=3.740,BoxCenterLoss=3.269,BoxScaleLoss=0.754,ClassLoss=0.131
[Epoch 28] Training cost: 7.880, ObjLoss=3.985,BoxCenterLoss=3.371,BoxScaleLoss=0.735,ClassLoss=0.101
[Epoch 29] Training cost: 4.174, ObjLoss=3.983,BoxCenterLoss=3.380,BoxScaleLoss=0.745,ClassLoss=0.144
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> finish model fitting
The best config: {'lr.choice': 0, 'net.choice': 0}

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.8567926833139815

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)