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, 54285.23KB/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
scheduler: FIFOScheduler(
DistributedResourceManager{
(Remote: Remote REMOTE_ID: 0,
    <Remote: 'inproc://172.31.35.213/24287/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 0x7fa7140ee310>, '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.072, ObjLoss=623.908,BoxCenterLoss=4.145,BoxScaleLoss=2.644,ClassLoss=1.007
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 4.365, ObjLoss=14.427,BoxCenterLoss=3.751,BoxScaleLoss=1.836,ClassLoss=0.745
[Epoch 1] Validation: motorbike=0.36733240767281516 mAP=0.36733240767281516
[Epoch 2] Training cost: 5.769, ObjLoss=10.230,BoxCenterLoss=3.848,BoxScaleLoss=1.439,ClassLoss=0.658
[Epoch 2] Validation: motorbike=0.5233566983763679 mAP=0.5233566983763679
[Epoch 3] Training cost: 4.095, ObjLoss=11.344,BoxCenterLoss=3.990,BoxScaleLoss=1.308,ClassLoss=0.633
[Epoch 3] Validation: motorbike=0.49664010232192046 mAP=0.49664010232192046
[Epoch 4] Training cost: 5.961, ObjLoss=13.198,BoxCenterLoss=3.610,BoxScaleLoss=1.167,ClassLoss=0.397
[Epoch 4] Validation: motorbike=0.6839470977022152 mAP=0.6839470977022152
[Epoch 5] Training cost: 3.176, ObjLoss=15.345,BoxCenterLoss=3.775,BoxScaleLoss=1.193,ClassLoss=0.509
[Epoch 5] Validation: motorbike=0.6833077070920623 mAP=0.6833077070920623
[Epoch 6] Training cost: 5.821, ObjLoss=7.623,BoxCenterLoss=3.856,BoxScaleLoss=1.257,ClassLoss=0.346
[Epoch 6] Validation: motorbike=0.5606444037514462 mAP=0.5606444037514462
[Epoch 7] Training cost: 7.019, ObjLoss=6.657,BoxCenterLoss=3.684,BoxScaleLoss=1.062,ClassLoss=0.291
[Epoch 7] Validation: motorbike=0.717076167076167 mAP=0.717076167076167
[Epoch 8] Training cost: 6.314, ObjLoss=6.239,BoxCenterLoss=3.757,BoxScaleLoss=0.953,ClassLoss=0.267
[Epoch 8] Validation: motorbike=0.6861855137717207 mAP=0.6861855137717207
[Epoch 9] Training cost: 6.018, ObjLoss=5.695,BoxCenterLoss=3.835,BoxScaleLoss=1.000,ClassLoss=0.280
[Epoch 9] Validation: motorbike=0.7716522692993281 mAP=0.7716522692993281
[Epoch 10] Training cost: 3.742, ObjLoss=6.274,BoxCenterLoss=3.801,BoxScaleLoss=1.065,ClassLoss=0.320
[Epoch 10] Validation: motorbike=0.6866282852257608 mAP=0.6866282852257608
[Epoch 11] Training cost: 3.947, ObjLoss=6.676,BoxCenterLoss=3.552,BoxScaleLoss=0.899,ClassLoss=0.246
[Epoch 11] Validation: motorbike=0.7500439734756312 mAP=0.7500439734756312
[Epoch 12] Training cost: 4.724, ObjLoss=6.351,BoxCenterLoss=3.782,BoxScaleLoss=0.850,ClassLoss=0.253
[Epoch 12] Validation: motorbike=0.8204284682660675 mAP=0.8204284682660675
[Epoch 13] Training cost: 2.966, ObjLoss=5.924,BoxCenterLoss=3.582,BoxScaleLoss=1.060,ClassLoss=0.349
[Epoch 13] Validation: motorbike=0.7277486537852391 mAP=0.7277486537852391
[Epoch 14] Training cost: 6.345, ObjLoss=6.020,BoxCenterLoss=3.572,BoxScaleLoss=1.039,ClassLoss=0.203
[Epoch 14] Validation: motorbike=0.7682219214477279 mAP=0.7682219214477279
[Epoch 15] Training cost: 3.212, ObjLoss=5.339,BoxCenterLoss=3.557,BoxScaleLoss=1.030,ClassLoss=0.270
[Epoch 15] Validation: motorbike=0.6508925613560446 mAP=0.6508925613560446
[Epoch 16] Training cost: 5.816, ObjLoss=5.603,BoxCenterLoss=3.799,BoxScaleLoss=1.059,ClassLoss=0.182
[Epoch 16] Validation: motorbike=0.736586906287585 mAP=0.736586906287585
[Epoch 17] Training cost: 5.035, ObjLoss=4.362,BoxCenterLoss=3.561,BoxScaleLoss=1.074,ClassLoss=0.175
[Epoch 17] Validation: motorbike=0.7934823155567837 mAP=0.7934823155567837
[Epoch 18] Training cost: 4.300, ObjLoss=4.166,BoxCenterLoss=3.572,BoxScaleLoss=0.967,ClassLoss=0.164
[Epoch 18] Validation: motorbike=0.7520550038197097 mAP=0.7520550038197097
[Epoch 19] Training cost: 6.581, ObjLoss=4.694,BoxCenterLoss=3.456,BoxScaleLoss=0.791,ClassLoss=0.143
[Epoch 19] Validation: motorbike=0.8735475051264526 mAP=0.8735475051264526
[Epoch 20] Training cost: 4.855, ObjLoss=4.161,BoxCenterLoss=3.404,BoxScaleLoss=0.807,ClassLoss=0.143
[Epoch 20] Validation: motorbike=0.8690564690564692 mAP=0.8690564690564692
[Epoch 21] Training cost: 4.748, ObjLoss=4.070,BoxCenterLoss=3.576,BoxScaleLoss=0.838,ClassLoss=0.160
[Epoch 21] Validation: motorbike=0.7958186516326051 mAP=0.7958186516326051
[Epoch 22] Training cost: 3.476, ObjLoss=4.178,BoxCenterLoss=3.483,BoxScaleLoss=0.974,ClassLoss=0.208
[Epoch 22] Validation: motorbike=0.8508394044979412 mAP=0.8508394044979412
[Epoch 23] Training cost: 3.247, ObjLoss=4.167,BoxCenterLoss=3.581,BoxScaleLoss=0.954,ClassLoss=0.230
[Epoch 23] Validation: motorbike=0.8314072708197556 mAP=0.8314072708197556
[Epoch 24] Training cost: 2.874, ObjLoss=4.341,BoxCenterLoss=3.522,BoxScaleLoss=0.893,ClassLoss=0.209
[Epoch 24] Validation: motorbike=0.8363740200404964 mAP=0.8363740200404964
[Epoch 25] Training cost: 7.284, ObjLoss=4.853,BoxCenterLoss=3.504,BoxScaleLoss=0.880,ClassLoss=0.113
[Epoch 25] Validation: motorbike=0.7763566701497736 mAP=0.7763566701497736
[Epoch 26] Training cost: 5.958, ObjLoss=3.797,BoxCenterLoss=3.447,BoxScaleLoss=0.886,ClassLoss=0.112
[Epoch 26] Validation: motorbike=0.7923227560136789 mAP=0.7923227560136789
[Epoch 27] Training cost: 4.975, ObjLoss=3.720,BoxCenterLoss=3.514,BoxScaleLoss=0.817,ClassLoss=0.133
[Epoch 27] Validation: motorbike=0.7801329250808 mAP=0.7801329250808
[Epoch 28] Training cost: 6.770, ObjLoss=4.192,BoxCenterLoss=3.715,BoxScaleLoss=0.902,ClassLoss=0.121
[Epoch 28] Validation: motorbike=0.8515397381523143 mAP=0.8515397381523143
[Epoch 29] Training cost: 7.060, ObjLoss=4.196,BoxCenterLoss=3.527,BoxScaleLoss=0.737,ClassLoss=0.088
[Epoch 29] Validation: motorbike=0.8352562901697415 mAP=0.8352562901697415
Finished Task with config: {'lr.choice': 0, 'net.choice': 0} and reward: 0.8352562901697415
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7fa6feb96890>, '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.262, ObjLoss=774.378,BoxCenterLoss=3.969,BoxScaleLoss=3.193,ClassLoss=1.064
[Epoch 0] Validation: motorbike=0.0148231748575898 mAP=0.0148231748575898
[Epoch 1] Training cost: 4.408, ObjLoss=17.081,BoxCenterLoss=3.908,BoxScaleLoss=2.331,ClassLoss=0.946
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 6.236, ObjLoss=13.802,BoxCenterLoss=3.844,BoxScaleLoss=1.954,ClassLoss=0.831
[Epoch 2] Validation: motorbike=0.3028024606971976 mAP=0.3028024606971976
[Epoch 3] Training cost: 3.971, ObjLoss=13.316,BoxCenterLoss=3.958,BoxScaleLoss=1.838,ClassLoss=0.753
[Epoch 3] Validation: motorbike=0.5006717561166343 mAP=0.5006717561166343
[Epoch 4] Training cost: 6.039, ObjLoss=9.988,BoxCenterLoss=3.993,BoxScaleLoss=1.617,ClassLoss=0.709
[Epoch 4] Validation: motorbike=0.4964972145536409 mAP=0.4964972145536409
[Epoch 5] Training cost: 3.328, ObjLoss=8.281,BoxCenterLoss=3.871,BoxScaleLoss=1.444,ClassLoss=0.699
[Epoch 5] Validation: motorbike=0.61982684536444 mAP=0.61982684536444
[Epoch 6] Training cost: 5.994, ObjLoss=7.607,BoxCenterLoss=3.883,BoxScaleLoss=1.259,ClassLoss=0.626
[Epoch 6] Validation: motorbike=0.6336608751352534 mAP=0.6336608751352534
[Epoch 7] Training cost: 7.644, ObjLoss=6.617,BoxCenterLoss=3.717,BoxScaleLoss=1.227,ClassLoss=0.487
[Epoch 7] Validation: motorbike=0.6377886002886004 mAP=0.6377886002886004
[Epoch 8] Training cost: 6.715, ObjLoss=6.802,BoxCenterLoss=3.760,BoxScaleLoss=1.183,ClassLoss=0.518
[Epoch 8] Validation: motorbike=0.6629217213369369 mAP=0.6629217213369369
[Epoch 9] Training cost: 6.498, ObjLoss=6.143,BoxCenterLoss=3.771,BoxScaleLoss=1.183,ClassLoss=0.478
[Epoch 9] Validation: motorbike=0.6428575029160586 mAP=0.6428575029160586
[Epoch 10] Training cost: 3.690, ObjLoss=5.371,BoxCenterLoss=3.621,BoxScaleLoss=1.096,ClassLoss=0.469
[Epoch 10] Validation: motorbike=0.7017241213102744 mAP=0.7017241213102744
[Epoch 11] Training cost: 3.895, ObjLoss=5.307,BoxCenterLoss=3.676,BoxScaleLoss=1.135,ClassLoss=0.444
[Epoch 11] Validation: motorbike=0.7489041356965886 mAP=0.7489041356965886
[Epoch 12] Training cost: 4.904, ObjLoss=5.503,BoxCenterLoss=3.852,BoxScaleLoss=1.106,ClassLoss=0.435
[Epoch 12] Validation: motorbike=0.7341701479632515 mAP=0.7341701479632515
[Epoch 13] Training cost: 3.075, ObjLoss=6.082,BoxCenterLoss=3.857,BoxScaleLoss=1.126,ClassLoss=0.592
[Epoch 13] Validation: motorbike=0.7472057485143923 mAP=0.7472057485143923
[Epoch 14] Training cost: 6.485, ObjLoss=5.937,BoxCenterLoss=3.863,BoxScaleLoss=1.092,ClassLoss=0.386
[Epoch 14] Validation: motorbike=0.7475659824046922 mAP=0.7475659824046922
[Epoch 15] Training cost: 3.325, ObjLoss=5.620,BoxCenterLoss=3.809,BoxScaleLoss=1.145,ClassLoss=0.499
[Epoch 15] Validation: motorbike=0.7706611570247935 mAP=0.7706611570247935
[Epoch 16] Training cost: 6.027, ObjLoss=5.670,BoxCenterLoss=3.627,BoxScaleLoss=1.014,ClassLoss=0.327
[Epoch 16] Validation: motorbike=0.7492132867132866 mAP=0.7492132867132866
[Epoch 17] Training cost: 5.479, ObjLoss=4.827,BoxCenterLoss=3.522,BoxScaleLoss=1.010,ClassLoss=0.330
[Epoch 17] Validation: motorbike=0.7780830849478392 mAP=0.7780830849478392
[Epoch 18] Training cost: 4.618, ObjLoss=5.138,BoxCenterLoss=3.699,BoxScaleLoss=1.108,ClassLoss=0.368
[Epoch 18] Validation: motorbike=0.7686950146627567 mAP=0.7686950146627567
[Epoch 19] Training cost: 6.869, ObjLoss=5.246,BoxCenterLoss=3.752,BoxScaleLoss=0.910,ClassLoss=0.284
[Epoch 19] Validation: motorbike=0.7432988523104802 mAP=0.7432988523104802
[Epoch 20] Training cost: 4.834, ObjLoss=5.211,BoxCenterLoss=3.764,BoxScaleLoss=0.990,ClassLoss=0.311
[Epoch 20] Validation: motorbike=0.7257720748151371 mAP=0.7257720748151371
[Epoch 21] Training cost: 4.971, ObjLoss=4.493,BoxCenterLoss=3.590,BoxScaleLoss=0.951,ClassLoss=0.288
[Epoch 21] Validation: motorbike=0.7631755341432761 mAP=0.7631755341432761
[Epoch 22] Training cost: 3.684, ObjLoss=5.161,BoxCenterLoss=3.643,BoxScaleLoss=0.989,ClassLoss=0.391
[Epoch 22] Validation: motorbike=0.769349786784407 mAP=0.769349786784407
[Epoch 23] Training cost: 3.263, ObjLoss=4.702,BoxCenterLoss=3.541,BoxScaleLoss=0.979,ClassLoss=0.372
[Epoch 23] Validation: motorbike=0.7768595041322315 mAP=0.7768595041322315
[Epoch 24] Training cost: 2.896, ObjLoss=4.332,BoxCenterLoss=3.428,BoxScaleLoss=0.815,ClassLoss=0.328
[Epoch 24] Validation: motorbike=0.7543283740138721 mAP=0.7543283740138721
[Epoch 25] Training cost: 7.609, ObjLoss=5.605,BoxCenterLoss=3.775,BoxScaleLoss=0.931,ClassLoss=0.252
[Epoch 25] Validation: motorbike=0.7993739954214073 mAP=0.7993739954214073
[Epoch 26] Training cost: 5.780, ObjLoss=4.560,BoxCenterLoss=3.380,BoxScaleLoss=0.837,ClassLoss=0.209
[Epoch 26] Validation: motorbike=0.7223218169390417 mAP=0.7223218169390417
[Epoch 27] Training cost: 4.981, ObjLoss=5.080,BoxCenterLoss=3.844,BoxScaleLoss=0.981,ClassLoss=0.320
[Epoch 27] Validation: motorbike=0.8204064524099469 mAP=0.8204064524099469
[Epoch 28] Training cost: 7.232, ObjLoss=5.323,BoxCenterLoss=3.736,BoxScaleLoss=1.048,ClassLoss=0.244
[Epoch 28] Validation: motorbike=0.8452677459526776 mAP=0.8452677459526776
[Epoch 29] Training cost: 7.368, ObjLoss=5.245,BoxCenterLoss=3.644,BoxScaleLoss=0.862,ClassLoss=0.202
[Epoch 29] Validation: motorbike=0.809827763115046 mAP=0.809827763115046
Finished Task with config: {'lr.choice': 1, 'net.choice': 0} and reward: 0.809827763115046
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7fa6fd83f510>, '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.687, ObjLoss=599.558,BoxCenterLoss=3.744,BoxScaleLoss=2.428,ClassLoss=0.916
[Epoch 1] Training cost: 4.864, ObjLoss=34.541,BoxCenterLoss=3.661,BoxScaleLoss=1.403,ClassLoss=0.747
[Epoch 2] Training cost: 6.131, ObjLoss=16.444,BoxCenterLoss=3.722,BoxScaleLoss=1.291,ClassLoss=0.630
[Epoch 3] Training cost: 8.792, ObjLoss=11.367,BoxCenterLoss=3.680,BoxScaleLoss=1.167,ClassLoss=0.456
[Epoch 4] Training cost: 4.866, ObjLoss=12.378,BoxCenterLoss=3.711,BoxScaleLoss=1.153,ClassLoss=0.505
[Epoch 5] Training cost: 7.403, ObjLoss=7.399,BoxCenterLoss=3.701,BoxScaleLoss=1.158,ClassLoss=0.352
[Epoch 6] Training cost: 7.327, ObjLoss=7.211,BoxCenterLoss=3.561,BoxScaleLoss=1.044,ClassLoss=0.334
[Epoch 7] Training cost: 4.495, ObjLoss=6.609,BoxCenterLoss=3.547,BoxScaleLoss=1.056,ClassLoss=0.396
[Epoch 8] Training cost: 6.869, ObjLoss=6.072,BoxCenterLoss=3.602,BoxScaleLoss=0.936,ClassLoss=0.265
[Epoch 9] Training cost: 5.894, ObjLoss=5.271,BoxCenterLoss=3.421,BoxScaleLoss=0.885,ClassLoss=0.266
[Epoch 10] Training cost: 4.516, ObjLoss=5.794,BoxCenterLoss=3.628,BoxScaleLoss=0.982,ClassLoss=0.346
[Epoch 11] Training cost: 5.689, ObjLoss=5.515,BoxCenterLoss=3.480,BoxScaleLoss=0.934,ClassLoss=0.265
[Epoch 12] Training cost: 6.039, ObjLoss=4.832,BoxCenterLoss=3.459,BoxScaleLoss=0.871,ClassLoss=0.238
[Epoch 13] Training cost: 7.858, ObjLoss=5.453,BoxCenterLoss=3.545,BoxScaleLoss=0.946,ClassLoss=0.202
[Epoch 14] Training cost: 6.382, ObjLoss=5.535,BoxCenterLoss=3.618,BoxScaleLoss=1.078,ClassLoss=0.244
[Epoch 15] Training cost: 4.929, ObjLoss=5.262,BoxCenterLoss=3.459,BoxScaleLoss=0.993,ClassLoss=0.224
[Epoch 16] Training cost: 3.805, ObjLoss=4.845,BoxCenterLoss=3.376,BoxScaleLoss=0.830,ClassLoss=0.260
[Epoch 17] Training cost: 3.877, ObjLoss=4.742,BoxCenterLoss=3.419,BoxScaleLoss=0.910,ClassLoss=0.281
[Epoch 18] Training cost: 7.344, ObjLoss=5.294,BoxCenterLoss=3.462,BoxScaleLoss=0.850,ClassLoss=0.193
[Epoch 19] Training cost: 3.691, ObjLoss=5.250,BoxCenterLoss=3.588,BoxScaleLoss=1.021,ClassLoss=0.260
[Epoch 20] Training cost: 5.296, ObjLoss=4.262,BoxCenterLoss=3.388,BoxScaleLoss=0.839,ClassLoss=0.192
[Epoch 21] Training cost: 5.733, ObjLoss=4.619,BoxCenterLoss=3.510,BoxScaleLoss=0.894,ClassLoss=0.167
[Epoch 22] Training cost: 5.091, ObjLoss=4.026,BoxCenterLoss=3.309,BoxScaleLoss=0.904,ClassLoss=0.179
[Epoch 23] Training cost: 5.251, ObjLoss=3.923,BoxCenterLoss=3.422,BoxScaleLoss=0.861,ClassLoss=0.173
[Epoch 24] Training cost: 5.855, ObjLoss=3.843,BoxCenterLoss=3.215,BoxScaleLoss=0.751,ClassLoss=0.136
[Epoch 25] Training cost: 7.809, ObjLoss=4.126,BoxCenterLoss=3.337,BoxScaleLoss=0.838,ClassLoss=0.117
[Epoch 26] Training cost: 5.635, ObjLoss=3.780,BoxCenterLoss=3.393,BoxScaleLoss=0.813,ClassLoss=0.146
[Epoch 27] Training cost: 5.784, ObjLoss=4.251,BoxCenterLoss=3.156,BoxScaleLoss=0.781,ClassLoss=0.131
[Epoch 28] Training cost: 8.012, ObjLoss=4.905,BoxCenterLoss=3.481,BoxScaleLoss=0.782,ClassLoss=0.112
[Epoch 29] Training cost: 4.257, ObjLoss=4.406,BoxCenterLoss=3.355,BoxScaleLoss=0.847,ClassLoss=0.163
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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.8603085593651632

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