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, 60457.06KB/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/493/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 0x7f598bb9d3d0>, '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.330, ObjLoss=881.454,BoxCenterLoss=3.987,BoxScaleLoss=2.721,ClassLoss=1.004
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 3.924, ObjLoss=18.364,BoxCenterLoss=3.792,BoxScaleLoss=1.610,ClassLoss=0.793
[Epoch 1] Validation: motorbike=0.5524598630944916 mAP=0.5524598630944916
[Epoch 2] Training cost: 4.520, ObjLoss=10.120,BoxCenterLoss=3.569,BoxScaleLoss=1.216,ClassLoss=0.625
[Epoch 2] Validation: motorbike=0.14052734858103985 mAP=0.14052734858103985
[Epoch 3] Training cost: 7.636, ObjLoss=10.535,BoxCenterLoss=4.005,BoxScaleLoss=1.302,ClassLoss=0.603
[Epoch 3] Validation: motorbike=0.5472426860127395 mAP=0.5472426860127395
[Epoch 4] Training cost: 3.955, ObjLoss=14.122,BoxCenterLoss=3.810,BoxScaleLoss=1.316,ClassLoss=0.538
[Epoch 4] Validation: motorbike=0.42105264001471315 mAP=0.42105264001471315
[Epoch 5] Training cost: 7.017, ObjLoss=9.834,BoxCenterLoss=3.545,BoxScaleLoss=1.138,ClassLoss=0.375
[Epoch 5] Validation: motorbike=0.7447226585157619 mAP=0.7447226585157619
[Epoch 6] Training cost: 4.763, ObjLoss=9.948,BoxCenterLoss=3.617,BoxScaleLoss=1.004,ClassLoss=0.347
[Epoch 6] Validation: motorbike=0.7908772740669292 mAP=0.7908772740669292
[Epoch 7] Training cost: 4.819, ObjLoss=8.137,BoxCenterLoss=3.782,BoxScaleLoss=1.112,ClassLoss=0.378
[Epoch 7] Validation: motorbike=0.7175434243176179 mAP=0.7175434243176179
[Epoch 8] Training cost: 3.396, ObjLoss=7.771,BoxCenterLoss=3.506,BoxScaleLoss=1.022,ClassLoss=0.356
[Epoch 8] Validation: motorbike=0.8298135634040262 mAP=0.8298135634040262
[Epoch 9] Training cost: 6.390, ObjLoss=6.238,BoxCenterLoss=3.616,BoxScaleLoss=0.937,ClassLoss=0.251
[Epoch 9] Validation: motorbike=0.7775497595963968 mAP=0.7775497595963968
[Epoch 10] Training cost: 5.664, ObjLoss=5.899,BoxCenterLoss=3.664,BoxScaleLoss=0.936,ClassLoss=0.253
[Epoch 10] Validation: motorbike=0.8483606114622158 mAP=0.8483606114622158
[Epoch 11] Training cost: 3.932, ObjLoss=7.954,BoxCenterLoss=3.669,BoxScaleLoss=1.057,ClassLoss=0.309
[Epoch 11] Validation: motorbike=0.8856240284811715 mAP=0.8856240284811715
[Epoch 12] Training cost: 6.956, ObjLoss=7.344,BoxCenterLoss=3.625,BoxScaleLoss=1.005,ClassLoss=0.228
[Epoch 12] Validation: motorbike=0.7479290924703194 mAP=0.7479290924703194
[Epoch 13] Training cost: 7.207, ObjLoss=14.448,BoxCenterLoss=3.636,BoxScaleLoss=0.940,ClassLoss=0.228
[Epoch 13] Validation: motorbike=0.8463553215077607 mAP=0.8463553215077607
[Epoch 14] Training cost: 6.588, ObjLoss=13.872,BoxCenterLoss=3.670,BoxScaleLoss=1.068,ClassLoss=0.259
[Epoch 14] Validation: motorbike=0.8188898601398603 mAP=0.8188898601398603
[Epoch 15] Training cost: 4.278, ObjLoss=10.850,BoxCenterLoss=3.463,BoxScaleLoss=1.018,ClassLoss=0.254
[Epoch 15] Validation: motorbike=0.7064962206028037 mAP=0.7064962206028037
[Epoch 16] Training cost: 5.203, ObjLoss=7.976,BoxCenterLoss=3.575,BoxScaleLoss=0.930,ClassLoss=0.257
[Epoch 16] Validation: motorbike=0.7708491542642886 mAP=0.7708491542642886
[Epoch 17] Training cost: 5.251, ObjLoss=6.492,BoxCenterLoss=3.676,BoxScaleLoss=0.915,ClassLoss=0.293
[Epoch 17] Validation: motorbike=0.813453506917399 mAP=0.813453506917399
[Epoch 18] Training cost: 3.725, ObjLoss=6.100,BoxCenterLoss=3.501,BoxScaleLoss=0.920,ClassLoss=0.321
[Epoch 18] Validation: motorbike=0.859615814161269 mAP=0.859615814161269
[Epoch 19] Training cost: 4.633, ObjLoss=5.495,BoxCenterLoss=3.428,BoxScaleLoss=0.794,ClassLoss=0.204
[Epoch 19] Validation: motorbike=0.8588516746411484 mAP=0.8588516746411484
[Epoch 20] Training cost: 4.029, ObjLoss=5.803,BoxCenterLoss=3.420,BoxScaleLoss=0.782,ClassLoss=0.222
[Epoch 20] Validation: motorbike=0.8848684210526317 mAP=0.8848684210526317
[Epoch 21] Training cost: 3.573, ObjLoss=5.918,BoxCenterLoss=3.488,BoxScaleLoss=0.935,ClassLoss=0.212
[Epoch 21] Validation: motorbike=0.8902064119455424 mAP=0.8902064119455424
[Epoch 22] Training cost: 4.870, ObjLoss=4.702,BoxCenterLoss=3.385,BoxScaleLoss=0.838,ClassLoss=0.184
[Epoch 22] Validation: motorbike=0.8676937053461445 mAP=0.8676937053461445
[Epoch 23] Training cost: 4.073, ObjLoss=4.871,BoxCenterLoss=3.279,BoxScaleLoss=0.750,ClassLoss=0.168
[Epoch 23] Validation: motorbike=0.8606052050716083 mAP=0.8606052050716083
[Epoch 24] Training cost: 7.130, ObjLoss=6.471,BoxCenterLoss=3.470,BoxScaleLoss=0.851,ClassLoss=0.140
[Epoch 24] Validation: motorbike=0.7713498622589532 mAP=0.7713498622589532
[Epoch 25] Training cost: 7.042, ObjLoss=5.009,BoxCenterLoss=3.399,BoxScaleLoss=0.858,ClassLoss=0.140
[Epoch 25] Validation: motorbike=0.8742690058479533 mAP=0.8742690058479533
[Epoch 26] Training cost: 6.995, ObjLoss=5.464,BoxCenterLoss=3.673,BoxScaleLoss=0.818,ClassLoss=0.148
[Epoch 26] Validation: motorbike=0.8202908567579509 mAP=0.8202908567579509
[Epoch 27] Training cost: 7.462, ObjLoss=4.903,BoxCenterLoss=3.484,BoxScaleLoss=0.710,ClassLoss=0.151
[Epoch 27] Validation: motorbike=0.8554564503658549 mAP=0.8554564503658549
[Epoch 28] Training cost: 4.331, ObjLoss=4.092,BoxCenterLoss=3.354,BoxScaleLoss=0.866,ClassLoss=0.176
[Epoch 28] Validation: motorbike=0.760592541842542 mAP=0.760592541842542
[Epoch 29] Training cost: 3.108, ObjLoss=5.514,BoxCenterLoss=3.421,BoxScaleLoss=0.939,ClassLoss=0.254
[Epoch 29] Validation: motorbike=0.7939883090070825 mAP=0.7939883090070825
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f58e694c050>, '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.661, ObjLoss=1014.297,BoxCenterLoss=4.016,BoxScaleLoss=3.272,ClassLoss=1.042
[Epoch 0] Validation: motorbike=0.0507399577167019 mAP=0.0507399577167019
[Epoch 1] Training cost: 4.255, ObjLoss=16.226,BoxCenterLoss=3.991,BoxScaleLoss=2.132,ClassLoss=0.887
[Epoch 1] Validation: motorbike=0.09090909090909091 mAP=0.09090909090909091
[Epoch 2] Training cost: 4.755, ObjLoss=14.739,BoxCenterLoss=3.672,BoxScaleLoss=2.018,ClassLoss=0.784
[Epoch 2] Validation: motorbike=0.25874125874125875 mAP=0.25874125874125875
[Epoch 3] Training cost: 7.963, ObjLoss=14.197,BoxCenterLoss=3.969,BoxScaleLoss=1.612,ClassLoss=0.812
[Epoch 3] Validation: motorbike=0.48886545416022614 mAP=0.48886545416022614
[Epoch 4] Training cost: 3.760, ObjLoss=10.519,BoxCenterLoss=3.721,BoxScaleLoss=1.541,ClassLoss=0.723
[Epoch 4] Validation: motorbike=0.4861989684956192 mAP=0.4861989684956192
[Epoch 5] Training cost: 7.562, ObjLoss=8.125,BoxCenterLoss=3.909,BoxScaleLoss=1.400,ClassLoss=0.704
[Epoch 5] Validation: motorbike=0.49240312416125936 mAP=0.49240312416125936
[Epoch 6] Training cost: 4.971, ObjLoss=6.993,BoxCenterLoss=3.671,BoxScaleLoss=1.248,ClassLoss=0.577
[Epoch 6] Validation: motorbike=0.5168931583880038 mAP=0.5168931583880038
[Epoch 7] Training cost: 5.263, ObjLoss=6.557,BoxCenterLoss=3.786,BoxScaleLoss=1.245,ClassLoss=0.566
[Epoch 7] Validation: motorbike=0.6213590368762782 mAP=0.6213590368762782
[Epoch 8] Training cost: 3.699, ObjLoss=6.628,BoxCenterLoss=3.813,BoxScaleLoss=1.252,ClassLoss=0.637
[Epoch 8] Validation: motorbike=0.7841716134195956 mAP=0.7841716134195956
[Epoch 9] Training cost: 6.967, ObjLoss=6.193,BoxCenterLoss=3.581,BoxScaleLoss=1.080,ClassLoss=0.423
[Epoch 9] Validation: motorbike=0.6811830384446792 mAP=0.6811830384446792
[Epoch 10] Training cost: 6.117, ObjLoss=6.140,BoxCenterLoss=3.867,BoxScaleLoss=1.119,ClassLoss=0.497
[Epoch 10] Validation: motorbike=0.7341541720871093 mAP=0.7341541720871093
[Epoch 11] Training cost: 4.349, ObjLoss=5.881,BoxCenterLoss=3.814,BoxScaleLoss=1.172,ClassLoss=0.521
[Epoch 11] Validation: motorbike=0.7563454457257514 mAP=0.7563454457257514
[Epoch 12] Training cost: 7.011, ObjLoss=6.269,BoxCenterLoss=3.739,BoxScaleLoss=1.018,ClassLoss=0.434
[Epoch 12] Validation: motorbike=0.7376201034737621 mAP=0.7376201034737621
[Epoch 13] Training cost: 7.553, ObjLoss=5.849,BoxCenterLoss=3.718,BoxScaleLoss=1.027,ClassLoss=0.333
[Epoch 13] Validation: motorbike=0.834409957119725 mAP=0.834409957119725
[Epoch 14] Training cost: 6.772, ObjLoss=5.769,BoxCenterLoss=3.768,BoxScaleLoss=1.149,ClassLoss=0.378
[Epoch 14] Validation: motorbike=0.8500509906759908 mAP=0.8500509906759908
[Epoch 15] Training cost: 4.292, ObjLoss=5.732,BoxCenterLoss=3.795,BoxScaleLoss=1.057,ClassLoss=0.429
[Epoch 15] Validation: motorbike=0.8596736596736598 mAP=0.8596736596736598
[Epoch 16] Training cost: 5.318, ObjLoss=5.091,BoxCenterLoss=3.615,BoxScaleLoss=0.943,ClassLoss=0.360
[Epoch 16] Validation: motorbike=0.8852272727272729 mAP=0.8852272727272729
[Epoch 17] Training cost: 5.181, ObjLoss=5.049,BoxCenterLoss=3.590,BoxScaleLoss=1.078,ClassLoss=0.354
[Epoch 17] Validation: motorbike=0.8559209624225105 mAP=0.8559209624225105
[Epoch 18] Training cost: 3.647, ObjLoss=5.373,BoxCenterLoss=3.899,BoxScaleLoss=1.070,ClassLoss=0.477
[Epoch 18] Validation: motorbike=0.8803997421018697 mAP=0.8803997421018697
[Epoch 19] Training cost: 4.607, ObjLoss=4.890,BoxCenterLoss=3.486,BoxScaleLoss=0.929,ClassLoss=0.356
[Epoch 19] Validation: motorbike=0.900634249471459 mAP=0.900634249471459
[Epoch 20] Training cost: 4.238, ObjLoss=4.735,BoxCenterLoss=3.662,BoxScaleLoss=1.029,ClassLoss=0.345
[Epoch 20] Validation: motorbike=0.8633373205741627 mAP=0.8633373205741627
[Epoch 21] Training cost: 3.625, ObjLoss=4.853,BoxCenterLoss=3.433,BoxScaleLoss=0.986,ClassLoss=0.334
[Epoch 21] Validation: motorbike=0.8924485125858124 mAP=0.8924485125858124
[Epoch 22] Training cost: 4.899, ObjLoss=4.626,BoxCenterLoss=3.459,BoxScaleLoss=0.884,ClassLoss=0.286
[Epoch 22] Validation: motorbike=0.8689976689976688 mAP=0.8689976689976688
[Epoch 23] Training cost: 4.149, ObjLoss=4.731,BoxCenterLoss=3.534,BoxScaleLoss=0.943,ClassLoss=0.325
[Epoch 23] Validation: motorbike=0.8921850079744817 mAP=0.8921850079744817
[Epoch 24] Training cost: 7.333, ObjLoss=5.343,BoxCenterLoss=3.663,BoxScaleLoss=0.921,ClassLoss=0.269
[Epoch 24] Validation: motorbike=0.8695448695448698 mAP=0.8695448695448698
[Epoch 25] Training cost: 6.987, ObjLoss=5.075,BoxCenterLoss=3.569,BoxScaleLoss=0.892,ClassLoss=0.226
[Epoch 25] Validation: motorbike=0.861838161838162 mAP=0.861838161838162
[Epoch 26] Training cost: 7.032, ObjLoss=4.971,BoxCenterLoss=3.346,BoxScaleLoss=0.822,ClassLoss=0.198
[Epoch 26] Validation: motorbike=0.906818181818182 mAP=0.906818181818182
[Epoch 27] Training cost: 7.464, ObjLoss=5.162,BoxCenterLoss=3.551,BoxScaleLoss=0.813,ClassLoss=0.228
[Epoch 27] Validation: motorbike=0.906818181818182 mAP=0.906818181818182
[Epoch 28] Training cost: 4.454, ObjLoss=4.584,BoxCenterLoss=3.595,BoxScaleLoss=0.902,ClassLoss=0.293
[Epoch 28] Validation: motorbike=0.9048625792811841 mAP=0.9048625792811841
[Epoch 29] Training cost: 2.882, ObjLoss=5.027,BoxCenterLoss=3.355,BoxScaleLoss=0.940,ClassLoss=0.347
[Epoch 29] Validation: motorbike=0.8709302325581397 mAP=0.8709302325581397
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f58ee4b35d0>, '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.719, ObjLoss=713.663,BoxCenterLoss=3.979,BoxScaleLoss=2.871,ClassLoss=1.088
[Epoch 1] Training cost: 4.705, ObjLoss=15.337,BoxCenterLoss=3.825,BoxScaleLoss=2.138,ClassLoss=0.902
[Epoch 2] Training cost: 6.041, ObjLoss=12.610,BoxCenterLoss=3.689,BoxScaleLoss=1.621,ClassLoss=0.754
[Epoch 3] Training cost: 8.994, ObjLoss=9.575,BoxCenterLoss=3.744,BoxScaleLoss=1.476,ClassLoss=0.674
[Epoch 4] Training cost: 4.690, ObjLoss=7.959,BoxCenterLoss=3.729,BoxScaleLoss=1.395,ClassLoss=0.667
[Epoch 5] Training cost: 7.316, ObjLoss=7.075,BoxCenterLoss=3.730,BoxScaleLoss=1.190,ClassLoss=0.570
[Epoch 6] Training cost: 7.557, ObjLoss=6.793,BoxCenterLoss=3.557,BoxScaleLoss=1.122,ClassLoss=0.502
[Epoch 7] Training cost: 4.504, ObjLoss=6.164,BoxCenterLoss=3.652,BoxScaleLoss=1.192,ClassLoss=0.556
[Epoch 8] Training cost: 7.149, ObjLoss=6.402,BoxCenterLoss=3.713,BoxScaleLoss=1.089,ClassLoss=0.441
[Epoch 9] Training cost: 6.167, ObjLoss=5.592,BoxCenterLoss=3.514,BoxScaleLoss=1.059,ClassLoss=0.400
[Epoch 10] Training cost: 4.546, ObjLoss=5.393,BoxCenterLoss=3.424,BoxScaleLoss=0.945,ClassLoss=0.428
[Epoch 11] Training cost: 5.720, ObjLoss=5.547,BoxCenterLoss=3.680,BoxScaleLoss=1.042,ClassLoss=0.402
[Epoch 12] Training cost: 6.185, ObjLoss=4.997,BoxCenterLoss=3.508,BoxScaleLoss=0.944,ClassLoss=0.365
[Epoch 13] Training cost: 8.204, ObjLoss=6.012,BoxCenterLoss=3.629,BoxScaleLoss=1.049,ClassLoss=0.324
[Epoch 14] Training cost: 6.387, ObjLoss=5.330,BoxCenterLoss=3.591,BoxScaleLoss=1.030,ClassLoss=0.335
[Epoch 15] Training cost: 4.936, ObjLoss=4.803,BoxCenterLoss=3.509,BoxScaleLoss=0.890,ClassLoss=0.337
[Epoch 16] Training cost: 3.914, ObjLoss=5.213,BoxCenterLoss=3.699,BoxScaleLoss=1.073,ClassLoss=0.429
[Epoch 17] Training cost: 3.782, ObjLoss=5.064,BoxCenterLoss=3.605,BoxScaleLoss=0.954,ClassLoss=0.384
[Epoch 18] Training cost: 7.400, ObjLoss=5.126,BoxCenterLoss=3.429,BoxScaleLoss=0.887,ClassLoss=0.201
[Epoch 19] Training cost: 3.789, ObjLoss=4.855,BoxCenterLoss=3.399,BoxScaleLoss=0.981,ClassLoss=0.353
[Epoch 20] Training cost: 5.649, ObjLoss=4.769,BoxCenterLoss=3.484,BoxScaleLoss=0.919,ClassLoss=0.320
[Epoch 21] Training cost: 5.578, ObjLoss=4.666,BoxCenterLoss=3.657,BoxScaleLoss=0.913,ClassLoss=0.254
[Epoch 22] Training cost: 5.199, ObjLoss=4.337,BoxCenterLoss=3.437,BoxScaleLoss=0.855,ClassLoss=0.261
[Epoch 23] Training cost: 5.146, ObjLoss=4.086,BoxCenterLoss=3.386,BoxScaleLoss=0.815,ClassLoss=0.239
[Epoch 24] Training cost: 6.078, ObjLoss=4.666,BoxCenterLoss=3.513,BoxScaleLoss=0.898,ClassLoss=0.225
[Epoch 25] Training cost: 7.806, ObjLoss=4.534,BoxCenterLoss=3.435,BoxScaleLoss=0.836,ClassLoss=0.179
[Epoch 26] Training cost: 5.539, ObjLoss=4.584,BoxCenterLoss=3.587,BoxScaleLoss=0.939,ClassLoss=0.225
[Epoch 27] Training cost: 5.819, ObjLoss=3.911,BoxCenterLoss=3.231,BoxScaleLoss=0.742,ClassLoss=0.190
[Epoch 28] Training cost: 8.185, ObjLoss=5.059,BoxCenterLoss=3.556,BoxScaleLoss=0.868,ClassLoss=0.196
[Epoch 29] Training cost: 4.126, ObjLoss=4.421,BoxCenterLoss=3.426,BoxScaleLoss=0.910,ClassLoss=0.237
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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.8581526976014031

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)