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, 61107.32KB/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.45.231/13376/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 0x7fb68bb7df90>, '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: 3.532, ObjLoss=876.377,BoxCenterLoss=3.729,BoxScaleLoss=2.723,ClassLoss=0.925
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 2.913, ObjLoss=19.925,BoxCenterLoss=3.101,BoxScaleLoss=1.432,ClassLoss=0.643
[Epoch 1] Validation: motorbike=0.18909311656675826 mAP=0.18909311656675826
[Epoch 2] Training cost: 6.015, ObjLoss=21.382,BoxCenterLoss=3.340,BoxScaleLoss=1.221,ClassLoss=0.606
[Epoch 2] Validation: motorbike=0.33793256926671855 mAP=0.33793256926671855
[Epoch 3] Training cost: 4.333, ObjLoss=22.124,BoxCenterLoss=3.272,BoxScaleLoss=1.099,ClassLoss=0.502
[Epoch 3] Validation: motorbike=0.338230055880084 mAP=0.338230055880084
[Epoch 4] Training cost: 3.245, ObjLoss=10.020,BoxCenterLoss=3.176,BoxScaleLoss=1.030,ClassLoss=0.468
[Epoch 4] Validation: motorbike=0.13540251866378802 mAP=0.13540251866378802
[Epoch 5] Training cost: 5.316, ObjLoss=9.397,BoxCenterLoss=3.295,BoxScaleLoss=0.956,ClassLoss=0.332
[Epoch 5] Validation: motorbike=0.6306785843233915 mAP=0.6306785843233915
[Epoch 6] Training cost: 2.959, ObjLoss=9.903,BoxCenterLoss=3.139,BoxScaleLoss=0.816,ClassLoss=0.335
[Epoch 6] Validation: motorbike=0.7013942184362689 mAP=0.7013942184362689
[Epoch 7] Training cost: 5.109, ObjLoss=9.110,BoxCenterLoss=3.168,BoxScaleLoss=0.867,ClassLoss=0.308
[Epoch 7] Validation: motorbike=0.6978953564897034 mAP=0.6978953564897034
[Epoch 8] Training cost: 3.918, ObjLoss=5.910,BoxCenterLoss=3.164,BoxScaleLoss=0.813,ClassLoss=0.329
[Epoch 8] Validation: motorbike=0.7361944568841121 mAP=0.7361944568841121
[Epoch 9] Training cost: 7.487, ObjLoss=7.085,BoxCenterLoss=3.184,BoxScaleLoss=0.830,ClassLoss=0.238
[Epoch 9] Validation: motorbike=0.788025287518479 mAP=0.788025287518479
[Epoch 10] Training cost: 3.153, ObjLoss=7.745,BoxCenterLoss=3.066,BoxScaleLoss=0.897,ClassLoss=0.263
[Epoch 10] Validation: motorbike=0.4770876300288065 mAP=0.4770876300288065
[Epoch 11] Training cost: 5.249, ObjLoss=6.861,BoxCenterLoss=3.162,BoxScaleLoss=0.975,ClassLoss=0.220
[Epoch 11] Validation: motorbike=0.7213206811804009 mAP=0.7213206811804009
[Epoch 12] Training cost: 3.603, ObjLoss=5.319,BoxCenterLoss=3.211,BoxScaleLoss=0.890,ClassLoss=0.273
[Epoch 12] Validation: motorbike=0.662144926699202 mAP=0.662144926699202
[Epoch 13] Training cost: 2.932, ObjLoss=5.408,BoxCenterLoss=3.065,BoxScaleLoss=0.843,ClassLoss=0.269
[Epoch 13] Validation: motorbike=0.7076754984580408 mAP=0.7076754984580408
[Epoch 14] Training cost: 6.626, ObjLoss=5.401,BoxCenterLoss=3.207,BoxScaleLoss=1.082,ClassLoss=0.187
[Epoch 14] Validation: motorbike=0.6412662282525297 mAP=0.6412662282525297
[Epoch 15] Training cost: 3.406, ObjLoss=4.544,BoxCenterLoss=3.181,BoxScaleLoss=1.082,ClassLoss=0.252
[Epoch 15] Validation: motorbike=0.6252456280019143 mAP=0.6252456280019143
[Epoch 16] Training cost: 4.230, ObjLoss=5.096,BoxCenterLoss=2.927,BoxScaleLoss=0.868,ClassLoss=0.192
[Epoch 16] Validation: motorbike=0.6970676421890815 mAP=0.6970676421890815
[Epoch 17] Training cost: 3.857, ObjLoss=5.218,BoxCenterLoss=3.259,BoxScaleLoss=0.864,ClassLoss=0.210
[Epoch 17] Validation: motorbike=0.746222518506188 mAP=0.746222518506188
[Epoch 18] Training cost: 2.843, ObjLoss=5.422,BoxCenterLoss=3.302,BoxScaleLoss=0.834,ClassLoss=0.285
[Epoch 18] Validation: motorbike=0.7213310542642875 mAP=0.7213310542642875
[Epoch 19] Training cost: 3.933, ObjLoss=8.177,BoxCenterLoss=3.162,BoxScaleLoss=0.745,ClassLoss=0.193
[Epoch 19] Validation: motorbike=0.78655329995345 mAP=0.78655329995345
[Epoch 20] Training cost: 6.864, ObjLoss=5.886,BoxCenterLoss=3.264,BoxScaleLoss=0.810,ClassLoss=0.136
[Epoch 20] Validation: motorbike=0.7533225497796803 mAP=0.7533225497796803
[Epoch 21] Training cost: 6.218, ObjLoss=5.545,BoxCenterLoss=3.031,BoxScaleLoss=0.694,ClassLoss=0.134
[Epoch 21] Validation: motorbike=0.7789917268674154 mAP=0.7789917268674154
[Epoch 22] Training cost: 6.225, ObjLoss=6.494,BoxCenterLoss=3.069,BoxScaleLoss=0.701,ClassLoss=0.132
[Epoch 22] Validation: motorbike=0.7291149942012011 mAP=0.7291149942012011
[Epoch 23] Training cost: 5.488, ObjLoss=4.335,BoxCenterLoss=3.008,BoxScaleLoss=0.768,ClassLoss=0.114
[Epoch 23] Validation: motorbike=0.7845910936388181 mAP=0.7845910936388181
[Epoch 24] Training cost: 4.779, ObjLoss=5.632,BoxCenterLoss=3.118,BoxScaleLoss=0.790,ClassLoss=0.160
[Epoch 24] Validation: motorbike=0.7449336710399084 mAP=0.7449336710399084
[Epoch 25] Training cost: 4.485, ObjLoss=3.817,BoxCenterLoss=2.990,BoxScaleLoss=0.700,ClassLoss=0.155
[Epoch 25] Validation: motorbike=0.6596990238639286 mAP=0.6596990238639286
[Epoch 26] Training cost: 4.667, ObjLoss=3.113,BoxCenterLoss=3.092,BoxScaleLoss=0.680,ClassLoss=0.134
[Epoch 26] Validation: motorbike=0.7692354956871086 mAP=0.7692354956871086
[Epoch 27] Training cost: 2.923, ObjLoss=4.575,BoxCenterLoss=3.181,BoxScaleLoss=0.744,ClassLoss=0.222
[Epoch 27] Validation: motorbike=0.7519913419913419 mAP=0.7519913419913419
[Epoch 28] Training cost: 4.382, ObjLoss=3.872,BoxCenterLoss=3.108,BoxScaleLoss=0.701,ClassLoss=0.128
[Epoch 28] Validation: motorbike=0.7798932630708068 mAP=0.7798932630708068
[Epoch 29] Training cost: 6.454, ObjLoss=3.724,BoxCenterLoss=3.032,BoxScaleLoss=0.684,ClassLoss=0.090
[Epoch 29] Validation: motorbike=0.783893118375877 mAP=0.783893118375877
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7fb5ba974290>, '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: 3.684, ObjLoss=1011.793,BoxCenterLoss=3.594,BoxScaleLoss=2.910,ClassLoss=0.993
[Epoch 0] Validation: motorbike=0.018181818181818184 mAP=0.018181818181818184
[Epoch 1] Training cost: 3.267, ObjLoss=13.267,BoxCenterLoss=3.370,BoxScaleLoss=1.863,ClassLoss=0.824
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 6.167, ObjLoss=14.000,BoxCenterLoss=3.332,BoxScaleLoss=1.891,ClassLoss=0.809
[Epoch 2] Validation: motorbike=0.09090909090909091 mAP=0.09090909090909091
[Epoch 3] Training cost: 4.318, ObjLoss=11.477,BoxCenterLoss=3.186,BoxScaleLoss=1.573,ClassLoss=0.633
[Epoch 3] Validation: motorbike=0.31485507246376815 mAP=0.31485507246376815
[Epoch 4] Training cost: 3.328, ObjLoss=11.500,BoxCenterLoss=3.277,BoxScaleLoss=1.284,ClassLoss=0.631
[Epoch 4] Validation: motorbike=0.2728749028749029 mAP=0.2728749028749029
[Epoch 5] Training cost: 5.296, ObjLoss=6.981,BoxCenterLoss=3.289,BoxScaleLoss=1.180,ClassLoss=0.542
[Epoch 5] Validation: motorbike=0.3032122865755636 mAP=0.3032122865755636
[Epoch 6] Training cost: 2.993, ObjLoss=6.918,BoxCenterLoss=3.408,BoxScaleLoss=1.173,ClassLoss=0.571
[Epoch 6] Validation: motorbike=0.3459036964067924 mAP=0.3459036964067924
[Epoch 7] Training cost: 5.227, ObjLoss=5.954,BoxCenterLoss=3.239,BoxScaleLoss=0.994,ClassLoss=0.496
[Epoch 7] Validation: motorbike=0.4032594351651153 mAP=0.4032594351651153
[Epoch 8] Training cost: 4.208, ObjLoss=5.514,BoxCenterLoss=3.322,BoxScaleLoss=1.037,ClassLoss=0.490
[Epoch 8] Validation: motorbike=0.5294532843780148 mAP=0.5294532843780148
[Epoch 9] Training cost: 7.780, ObjLoss=5.534,BoxCenterLoss=3.210,BoxScaleLoss=0.945,ClassLoss=0.404
[Epoch 9] Validation: motorbike=0.5551457134109445 mAP=0.5551457134109445
[Epoch 10] Training cost: 3.384, ObjLoss=5.551,BoxCenterLoss=3.238,BoxScaleLoss=1.112,ClassLoss=0.467
[Epoch 10] Validation: motorbike=0.5973671514381634 mAP=0.5973671514381634
[Epoch 11] Training cost: 5.657, ObjLoss=5.235,BoxCenterLoss=3.314,BoxScaleLoss=0.975,ClassLoss=0.393
[Epoch 11] Validation: motorbike=0.5779172887567339 mAP=0.5779172887567339
[Epoch 12] Training cost: 3.699, ObjLoss=5.051,BoxCenterLoss=3.303,BoxScaleLoss=0.849,ClassLoss=0.408
[Epoch 12] Validation: motorbike=0.6347451286063436 mAP=0.6347451286063436
[Epoch 13] Training cost: 3.153, ObjLoss=4.716,BoxCenterLoss=3.236,BoxScaleLoss=0.878,ClassLoss=0.416
[Epoch 13] Validation: motorbike=0.7131770330099515 mAP=0.7131770330099515
[Epoch 14] Training cost: 7.068, ObjLoss=5.932,BoxCenterLoss=3.330,BoxScaleLoss=0.888,ClassLoss=0.326
[Epoch 14] Validation: motorbike=0.7343757221715883 mAP=0.7343757221715883
[Epoch 15] Training cost: 3.586, ObjLoss=4.426,BoxCenterLoss=3.140,BoxScaleLoss=0.903,ClassLoss=0.354
[Epoch 15] Validation: motorbike=0.7635781444324329 mAP=0.7635781444324329
[Epoch 16] Training cost: 4.399, ObjLoss=4.252,BoxCenterLoss=3.049,BoxScaleLoss=0.829,ClassLoss=0.336
[Epoch 16] Validation: motorbike=0.7750167338447802 mAP=0.7750167338447802
[Epoch 17] Training cost: 4.275, ObjLoss=4.653,BoxCenterLoss=3.350,BoxScaleLoss=0.901,ClassLoss=0.397
[Epoch 17] Validation: motorbike=0.6811935001273237 mAP=0.6811935001273237
[Epoch 18] Training cost: 3.105, ObjLoss=4.701,BoxCenterLoss=3.261,BoxScaleLoss=0.927,ClassLoss=0.389
[Epoch 18] Validation: motorbike=0.7205479165879421 mAP=0.7205479165879421
[Epoch 19] Training cost: 4.241, ObjLoss=4.146,BoxCenterLoss=3.212,BoxScaleLoss=0.784,ClassLoss=0.323
[Epoch 19] Validation: motorbike=0.8088821341997385 mAP=0.8088821341997385
[Epoch 20] Training cost: 7.139, ObjLoss=4.687,BoxCenterLoss=3.220,BoxScaleLoss=0.885,ClassLoss=0.252
[Epoch 20] Validation: motorbike=0.8327955227955229 mAP=0.8327955227955229
[Epoch 21] Training cost: 6.694, ObjLoss=4.565,BoxCenterLoss=3.155,BoxScaleLoss=0.843,ClassLoss=0.240
[Epoch 21] Validation: motorbike=0.8183071943862757 mAP=0.8183071943862757
[Epoch 22] Training cost: 6.480, ObjLoss=4.810,BoxCenterLoss=3.167,BoxScaleLoss=0.779,ClassLoss=0.235
[Epoch 22] Validation: motorbike=0.825344916139773 mAP=0.825344916139773
[Epoch 23] Training cost: 5.669, ObjLoss=4.322,BoxCenterLoss=3.086,BoxScaleLoss=0.849,ClassLoss=0.241
[Epoch 23] Validation: motorbike=0.8337312937860133 mAP=0.8337312937860133
[Epoch 24] Training cost: 4.986, ObjLoss=4.178,BoxCenterLoss=3.228,BoxScaleLoss=0.837,ClassLoss=0.265
[Epoch 24] Validation: motorbike=0.8357694936642305 mAP=0.8357694936642305
[Epoch 25] Training cost: 4.632, ObjLoss=3.685,BoxCenterLoss=3.091,BoxScaleLoss=0.758,ClassLoss=0.224
[Epoch 25] Validation: motorbike=0.7940471561838411 mAP=0.7940471561838411
[Epoch 26] Training cost: 4.726, ObjLoss=4.200,BoxCenterLoss=3.150,BoxScaleLoss=0.747,ClassLoss=0.261
[Epoch 26] Validation: motorbike=0.8068852796474727 mAP=0.8068852796474727
[Epoch 27] Training cost: 2.961, ObjLoss=4.661,BoxCenterLoss=3.219,BoxScaleLoss=0.847,ClassLoss=0.362
[Epoch 27] Validation: motorbike=0.8101055806938161 mAP=0.8101055806938161
[Epoch 28] Training cost: 4.572, ObjLoss=3.928,BoxCenterLoss=2.993,BoxScaleLoss=0.773,ClassLoss=0.210
[Epoch 28] Validation: motorbike=0.7991820830941763 mAP=0.7991820830941763
[Epoch 29] Training cost: 6.630, ObjLoss=4.048,BoxCenterLoss=3.108,BoxScaleLoss=0.742,ClassLoss=0.202
[Epoch 29] Validation: motorbike=0.8155565864618455 mAP=0.8155565864618455
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7fb5ba9747d0>, '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: 3.757, ObjLoss=715.075,BoxCenterLoss=4.020,BoxScaleLoss=2.854,ClassLoss=1.081
[Epoch 1] Training cost: 4.910, ObjLoss=14.581,BoxCenterLoss=3.625,BoxScaleLoss=1.969,ClassLoss=0.850
[Epoch 2] Training cost: 6.032, ObjLoss=13.531,BoxCenterLoss=3.810,BoxScaleLoss=1.641,ClassLoss=0.776
[Epoch 3] Training cost: 9.078, ObjLoss=10.329,BoxCenterLoss=3.737,BoxScaleLoss=1.573,ClassLoss=0.691
[Epoch 4] Training cost: 4.743, ObjLoss=8.253,BoxCenterLoss=3.789,BoxScaleLoss=1.377,ClassLoss=0.692
[Epoch 5] Training cost: 7.190, ObjLoss=7.275,BoxCenterLoss=3.742,BoxScaleLoss=1.172,ClassLoss=0.596
[Epoch 6] Training cost: 7.456, ObjLoss=6.624,BoxCenterLoss=3.628,BoxScaleLoss=1.176,ClassLoss=0.485
[Epoch 7] Training cost: 4.329, ObjLoss=6.336,BoxCenterLoss=3.615,BoxScaleLoss=1.223,ClassLoss=0.560
[Epoch 8] Training cost: 7.370, ObjLoss=6.429,BoxCenterLoss=3.782,BoxScaleLoss=1.164,ClassLoss=0.513
[Epoch 9] Training cost: 6.069, ObjLoss=5.378,BoxCenterLoss=3.432,BoxScaleLoss=0.991,ClassLoss=0.441
[Epoch 10] Training cost: 4.523, ObjLoss=5.150,BoxCenterLoss=3.557,BoxScaleLoss=1.030,ClassLoss=0.431
[Epoch 11] Training cost: 5.697, ObjLoss=5.161,BoxCenterLoss=3.464,BoxScaleLoss=0.964,ClassLoss=0.403
[Epoch 12] Training cost: 6.108, ObjLoss=5.002,BoxCenterLoss=3.499,BoxScaleLoss=1.001,ClassLoss=0.385
[Epoch 13] Training cost: 8.510, ObjLoss=5.705,BoxCenterLoss=3.622,BoxScaleLoss=0.953,ClassLoss=0.310
[Epoch 14] Training cost: 6.393, ObjLoss=5.575,BoxCenterLoss=3.531,BoxScaleLoss=1.003,ClassLoss=0.363
[Epoch 15] Training cost: 4.911, ObjLoss=4.675,BoxCenterLoss=3.467,BoxScaleLoss=0.917,ClassLoss=0.329
[Epoch 16] Training cost: 3.946, ObjLoss=4.993,BoxCenterLoss=3.501,BoxScaleLoss=1.031,ClassLoss=0.393
[Epoch 17] Training cost: 3.913, ObjLoss=4.807,BoxCenterLoss=3.541,BoxScaleLoss=0.962,ClassLoss=0.370
[Epoch 18] Training cost: 7.313, ObjLoss=5.182,BoxCenterLoss=3.659,BoxScaleLoss=0.935,ClassLoss=0.270
[Epoch 19] Training cost: 3.839, ObjLoss=4.702,BoxCenterLoss=3.499,BoxScaleLoss=0.957,ClassLoss=0.348
[Epoch 20] Training cost: 5.475, ObjLoss=4.677,BoxCenterLoss=3.628,BoxScaleLoss=1.006,ClassLoss=0.313
[Epoch 21] Training cost: 5.817, ObjLoss=4.387,BoxCenterLoss=3.435,BoxScaleLoss=0.945,ClassLoss=0.246
[Epoch 22] Training cost: 5.349, ObjLoss=4.398,BoxCenterLoss=3.377,BoxScaleLoss=0.831,ClassLoss=0.250
[Epoch 23] Training cost: 5.309, ObjLoss=4.320,BoxCenterLoss=3.435,BoxScaleLoss=0.835,ClassLoss=0.258
[Epoch 24] Training cost: 6.157, ObjLoss=4.146,BoxCenterLoss=3.206,BoxScaleLoss=0.772,ClassLoss=0.185
[Epoch 25] Training cost: 7.675, ObjLoss=4.484,BoxCenterLoss=3.526,BoxScaleLoss=0.841,ClassLoss=0.190
[Epoch 26] Training cost: 5.375, ObjLoss=4.302,BoxCenterLoss=3.593,BoxScaleLoss=0.779,ClassLoss=0.236
[Epoch 27] Training cost: 5.985, ObjLoss=4.156,BoxCenterLoss=3.199,BoxScaleLoss=0.773,ClassLoss=0.194
[Epoch 28] Training cost: 7.970, ObjLoss=4.511,BoxCenterLoss=3.535,BoxScaleLoss=0.841,ClassLoss=0.175
[Epoch 29] Training cost: 4.217, ObjLoss=4.648,BoxCenterLoss=3.497,BoxScaleLoss=0.915,ClassLoss=0.267
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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.8174088933810136

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)