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, 37062.94KB/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/17406/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 0x7fbfb4922550>, '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: 6.317, ObjLoss=742.273,BoxCenterLoss=3.678,BoxScaleLoss=2.496,ClassLoss=0.969
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 3.254, ObjLoss=19.993,BoxCenterLoss=3.316,BoxScaleLoss=1.324,ClassLoss=0.677
[Epoch 1] Validation: motorbike=0.11652681368126581 mAP=0.11652681368126581
[Epoch 2] Training cost: 3.445, ObjLoss=16.531,BoxCenterLoss=3.605,BoxScaleLoss=1.189,ClassLoss=0.691
[Epoch 2] Validation: motorbike=0.44191579939078857 mAP=0.44191579939078857
[Epoch 3] Training cost: 3.506, ObjLoss=15.999,BoxCenterLoss=3.304,BoxScaleLoss=0.970,ClassLoss=0.576
[Epoch 3] Validation: motorbike=0.4005381454211213 mAP=0.4005381454211213
[Epoch 4] Training cost: 4.452, ObjLoss=8.307,BoxCenterLoss=3.243,BoxScaleLoss=1.097,ClassLoss=0.462
[Epoch 4] Validation: motorbike=0.34625277664869514 mAP=0.34625277664869514
[Epoch 5] Training cost: 3.917, ObjLoss=7.082,BoxCenterLoss=3.312,BoxScaleLoss=1.083,ClassLoss=0.403
[Epoch 5] Validation: motorbike=0.5405995906418553 mAP=0.5405995906418553
[Epoch 6] Training cost: 3.381, ObjLoss=7.858,BoxCenterLoss=3.435,BoxScaleLoss=1.010,ClassLoss=0.406
[Epoch 6] Validation: motorbike=0.3503842294393576 mAP=0.3503842294393576
[Epoch 7] Training cost: 7.500, ObjLoss=7.052,BoxCenterLoss=3.344,BoxScaleLoss=1.124,ClassLoss=0.267
[Epoch 7] Validation: motorbike=0.7113820320429172 mAP=0.7113820320429172
[Epoch 8] Training cost: 3.717, ObjLoss=7.402,BoxCenterLoss=3.250,BoxScaleLoss=1.006,ClassLoss=0.278
[Epoch 8] Validation: motorbike=0.6892281854429896 mAP=0.6892281854429896
[Epoch 9] Training cost: 3.819, ObjLoss=6.911,BoxCenterLoss=3.246,BoxScaleLoss=0.944,ClassLoss=0.309
[Epoch 9] Validation: motorbike=0.6555779403148795 mAP=0.6555779403148795
[Epoch 10] Training cost: 4.522, ObjLoss=5.065,BoxCenterLoss=3.300,BoxScaleLoss=0.910,ClassLoss=0.240
[Epoch 10] Validation: motorbike=0.6935134384754147 mAP=0.6935134384754147
[Epoch 11] Training cost: 7.545, ObjLoss=5.461,BoxCenterLoss=3.298,BoxScaleLoss=0.938,ClassLoss=0.188
[Epoch 11] Validation: motorbike=0.7428622866099039 mAP=0.7428622866099039
[Epoch 12] Training cost: 4.851, ObjLoss=4.413,BoxCenterLoss=3.321,BoxScaleLoss=0.905,ClassLoss=0.231
[Epoch 12] Validation: motorbike=0.7026473005944952 mAP=0.7026473005944952
[Epoch 13] Training cost: 6.437, ObjLoss=4.856,BoxCenterLoss=3.209,BoxScaleLoss=0.915,ClassLoss=0.167
[Epoch 13] Validation: motorbike=0.7913189325181589 mAP=0.7913189325181589
[Epoch 14] Training cost: 3.335, ObjLoss=6.084,BoxCenterLoss=3.376,BoxScaleLoss=0.961,ClassLoss=0.296
[Epoch 14] Validation: motorbike=0.7685544708644559 mAP=0.7685544708644559
[Epoch 15] Training cost: 3.927, ObjLoss=4.423,BoxCenterLoss=3.264,BoxScaleLoss=0.871,ClassLoss=0.234
[Epoch 15] Validation: motorbike=0.772038567493113 mAP=0.772038567493113
[Epoch 16] Training cost: 4.669, ObjLoss=4.548,BoxCenterLoss=3.376,BoxScaleLoss=0.869,ClassLoss=0.167
[Epoch 16] Validation: motorbike=0.753265423793965 mAP=0.753265423793965
[Epoch 17] Training cost: 7.240, ObjLoss=4.609,BoxCenterLoss=3.309,BoxScaleLoss=0.939,ClassLoss=0.161
[Epoch 17] Validation: motorbike=0.7154576555739076 mAP=0.7154576555739076
[Epoch 18] Training cost: 3.273, ObjLoss=4.647,BoxCenterLoss=3.221,BoxScaleLoss=0.862,ClassLoss=0.234
[Epoch 18] Validation: motorbike=0.6888236222651806 mAP=0.6888236222651806
[Epoch 19] Training cost: 3.302, ObjLoss=5.049,BoxCenterLoss=3.177,BoxScaleLoss=0.775,ClassLoss=0.249
[Epoch 19] Validation: motorbike=0.799781219318173 mAP=0.799781219318173
[Epoch 20] Training cost: 6.359, ObjLoss=4.488,BoxCenterLoss=3.258,BoxScaleLoss=0.818,ClassLoss=0.130
[Epoch 20] Validation: motorbike=0.783035912312139 mAP=0.783035912312139
[Epoch 21] Training cost: 4.958, ObjLoss=3.908,BoxCenterLoss=3.315,BoxScaleLoss=0.847,ClassLoss=0.150
[Epoch 21] Validation: motorbike=0.8031718281718281 mAP=0.8031718281718281
[Epoch 22] Training cost: 3.721, ObjLoss=3.692,BoxCenterLoss=3.182,BoxScaleLoss=0.784,ClassLoss=0.187
[Epoch 22] Validation: motorbike=0.7802455481709208 mAP=0.7802455481709208
[Epoch 23] Training cost: 3.502, ObjLoss=4.525,BoxCenterLoss=3.245,BoxScaleLoss=0.841,ClassLoss=0.212
[Epoch 23] Validation: motorbike=0.8190802174986888 mAP=0.8190802174986888
[Epoch 24] Training cost: 5.926, ObjLoss=3.993,BoxCenterLoss=3.216,BoxScaleLoss=0.925,ClassLoss=0.116
[Epoch 24] Validation: motorbike=0.7692152464627493 mAP=0.7692152464627493
[Epoch 25] Training cost: 4.152, ObjLoss=3.838,BoxCenterLoss=3.033,BoxScaleLoss=0.805,ClassLoss=0.155
[Epoch 25] Validation: motorbike=0.776063480331773 mAP=0.776063480331773
[Epoch 26] Training cost: 4.833, ObjLoss=3.472,BoxCenterLoss=3.190,BoxScaleLoss=0.759,ClassLoss=0.116
[Epoch 26] Validation: motorbike=0.8288879329461234 mAP=0.8288879329461234
[Epoch 27] Training cost: 3.915, ObjLoss=3.477,BoxCenterLoss=3.149,BoxScaleLoss=0.695,ClassLoss=0.150
[Epoch 27] Validation: motorbike=0.8329584332002128 mAP=0.8329584332002128
[Epoch 28] Training cost: 4.168, ObjLoss=3.506,BoxCenterLoss=3.264,BoxScaleLoss=0.725,ClassLoss=0.144
[Epoch 28] Validation: motorbike=0.8018337724925726 mAP=0.8018337724925726
[Epoch 29] Training cost: 6.484, ObjLoss=4.021,BoxCenterLoss=3.184,BoxScaleLoss=0.833,ClassLoss=0.087
[Epoch 29] Validation: motorbike=0.8349700953489224 mAP=0.8349700953489224
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7fbef4252910>, '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: 6.215, ObjLoss=887.175,BoxCenterLoss=3.744,BoxScaleLoss=3.009,ClassLoss=1.052
[Epoch 0] Validation: motorbike=0.02238916415029432 mAP=0.02238916415029432
[Epoch 1] Training cost: 3.452, ObjLoss=15.011,BoxCenterLoss=3.568,BoxScaleLoss=1.998,ClassLoss=0.856
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 3.482, ObjLoss=15.056,BoxCenterLoss=3.711,BoxScaleLoss=1.644,ClassLoss=0.806
[Epoch 2] Validation: motorbike=0.09090909090909091 mAP=0.09090909090909091
[Epoch 3] Training cost: 3.237, ObjLoss=11.306,BoxCenterLoss=3.256,BoxScaleLoss=1.312,ClassLoss=0.708
[Epoch 3] Validation: motorbike=0.21673139415074896 mAP=0.21673139415074896
[Epoch 4] Training cost: 4.566, ObjLoss=8.241,BoxCenterLoss=3.292,BoxScaleLoss=1.382,ClassLoss=0.652
[Epoch 4] Validation: motorbike=0.4806934043189632 mAP=0.4806934043189632
[Epoch 5] Training cost: 4.234, ObjLoss=6.783,BoxCenterLoss=3.405,BoxScaleLoss=1.337,ClassLoss=0.634
[Epoch 5] Validation: motorbike=0.5276090482127894 mAP=0.5276090482127894
[Epoch 6] Training cost: 3.420, ObjLoss=6.433,BoxCenterLoss=3.374,BoxScaleLoss=1.253,ClassLoss=0.615
[Epoch 6] Validation: motorbike=0.44149140497927886 mAP=0.44149140497927886
[Epoch 7] Training cost: 8.036, ObjLoss=6.733,BoxCenterLoss=3.509,BoxScaleLoss=1.284,ClassLoss=0.533
[Epoch 7] Validation: motorbike=0.5697608800549977 mAP=0.5697608800549977
[Epoch 8] Training cost: 4.273, ObjLoss=5.621,BoxCenterLoss=3.455,BoxScaleLoss=1.244,ClassLoss=0.526
[Epoch 8] Validation: motorbike=0.6109726862434792 mAP=0.6109726862434792
[Epoch 9] Training cost: 4.024, ObjLoss=5.340,BoxCenterLoss=3.414,BoxScaleLoss=1.090,ClassLoss=0.514
[Epoch 9] Validation: motorbike=0.5760766715902489 mAP=0.5760766715902489
[Epoch 10] Training cost: 4.722, ObjLoss=5.236,BoxCenterLoss=3.395,BoxScaleLoss=1.129,ClassLoss=0.465
[Epoch 10] Validation: motorbike=0.7013957084211094 mAP=0.7013957084211094
[Epoch 11] Training cost: 8.291, ObjLoss=5.693,BoxCenterLoss=3.336,BoxScaleLoss=0.980,ClassLoss=0.361
[Epoch 11] Validation: motorbike=0.7253634762458903 mAP=0.7253634762458903
[Epoch 12] Training cost: 5.026, ObjLoss=5.339,BoxCenterLoss=3.385,BoxScaleLoss=0.981,ClassLoss=0.398
[Epoch 12] Validation: motorbike=0.7353288077119231 mAP=0.7353288077119231
[Epoch 13] Training cost: 6.660, ObjLoss=5.494,BoxCenterLoss=3.455,BoxScaleLoss=0.957,ClassLoss=0.384
[Epoch 13] Validation: motorbike=0.7132656752367889 mAP=0.7132656752367889
[Epoch 14] Training cost: 3.457, ObjLoss=5.486,BoxCenterLoss=3.538,BoxScaleLoss=1.033,ClassLoss=0.491
[Epoch 14] Validation: motorbike=0.6955883474751399 mAP=0.6955883474751399
[Epoch 15] Training cost: 4.073, ObjLoss=4.618,BoxCenterLoss=3.251,BoxScaleLoss=0.930,ClassLoss=0.396
[Epoch 15] Validation: motorbike=0.7115608547272384 mAP=0.7115608547272384
[Epoch 16] Training cost: 4.839, ObjLoss=4.757,BoxCenterLoss=3.450,BoxScaleLoss=0.961,ClassLoss=0.342
[Epoch 16] Validation: motorbike=0.7485559207882257 mAP=0.7485559207882257
[Epoch 17] Training cost: 7.479, ObjLoss=4.912,BoxCenterLoss=3.293,BoxScaleLoss=0.839,ClassLoss=0.255
[Epoch 17] Validation: motorbike=0.7452677876960112 mAP=0.7452677876960112
[Epoch 18] Training cost: 3.463, ObjLoss=4.776,BoxCenterLoss=3.474,BoxScaleLoss=0.941,ClassLoss=0.419
[Epoch 18] Validation: motorbike=0.7660665317040618 mAP=0.7660665317040618
[Epoch 19] Training cost: 3.066, ObjLoss=4.837,BoxCenterLoss=3.426,BoxScaleLoss=1.001,ClassLoss=0.427
[Epoch 19] Validation: motorbike=0.7379353489647608 mAP=0.7379353489647608
[Epoch 20] Training cost: 6.590, ObjLoss=4.537,BoxCenterLoss=3.265,BoxScaleLoss=0.897,ClassLoss=0.251
[Epoch 20] Validation: motorbike=0.7771404886974091 mAP=0.7771404886974091
[Epoch 21] Training cost: 5.383, ObjLoss=4.543,BoxCenterLoss=3.327,BoxScaleLoss=0.917,ClassLoss=0.282
[Epoch 21] Validation: motorbike=0.7824391790919616 mAP=0.7824391790919616
[Epoch 22] Training cost: 3.801, ObjLoss=4.558,BoxCenterLoss=3.370,BoxScaleLoss=0.891,ClassLoss=0.346
[Epoch 22] Validation: motorbike=0.7881531287603394 mAP=0.7881531287603394
[Epoch 23] Training cost: 3.359, ObjLoss=4.305,BoxCenterLoss=3.300,BoxScaleLoss=0.995,ClassLoss=0.367
[Epoch 23] Validation: motorbike=0.7272464604697859 mAP=0.7272464604697859
[Epoch 24] Training cost: 6.065, ObjLoss=4.630,BoxCenterLoss=3.406,BoxScaleLoss=0.894,ClassLoss=0.216
[Epoch 24] Validation: motorbike=0.8113351560719981 mAP=0.8113351560719981
[Epoch 25] Training cost: 4.226, ObjLoss=3.964,BoxCenterLoss=3.118,BoxScaleLoss=0.860,ClassLoss=0.262
[Epoch 25] Validation: motorbike=0.8207630427991254 mAP=0.8207630427991254
[Epoch 26] Training cost: 4.761, ObjLoss=4.085,BoxCenterLoss=3.229,BoxScaleLoss=0.776,ClassLoss=0.212
[Epoch 26] Validation: motorbike=0.8231975384007657 mAP=0.8231975384007657
[Epoch 27] Training cost: 3.918, ObjLoss=4.234,BoxCenterLoss=3.253,BoxScaleLoss=0.780,ClassLoss=0.280
[Epoch 27] Validation: motorbike=0.7579793088267666 mAP=0.7579793088267666
[Epoch 28] Training cost: 4.287, ObjLoss=3.833,BoxCenterLoss=3.349,BoxScaleLoss=0.790,ClassLoss=0.261
[Epoch 28] Validation: motorbike=0.7218606163270196 mAP=0.7218606163270196
[Epoch 29] Training cost: 6.620, ObjLoss=4.451,BoxCenterLoss=3.146,BoxScaleLoss=0.783,ClassLoss=0.197
[Epoch 29] Validation: motorbike=0.7799440397001371 mAP=0.7799440397001371
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7fbfb4939510>, '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: 6.419, ObjLoss=600.827,BoxCenterLoss=3.992,BoxScaleLoss=2.345,ClassLoss=0.966
[Epoch 1] Training cost: 5.077, ObjLoss=19.631,BoxCenterLoss=3.575,BoxScaleLoss=1.585,ClassLoss=0.733
[Epoch 2] Training cost: 6.215, ObjLoss=19.196,BoxCenterLoss=3.804,BoxScaleLoss=1.210,ClassLoss=0.599
[Epoch 3] Training cost: 9.019, ObjLoss=15.758,BoxCenterLoss=3.705,BoxScaleLoss=1.111,ClassLoss=0.484
[Epoch 4] Training cost: 5.235, ObjLoss=30.685,BoxCenterLoss=3.607,BoxScaleLoss=1.181,ClassLoss=0.510
[Epoch 5] Training cost: 7.983, ObjLoss=16.480,BoxCenterLoss=3.635,BoxScaleLoss=0.964,ClassLoss=0.440
[Epoch 6] Training cost: 7.686, ObjLoss=10.434,BoxCenterLoss=3.552,BoxScaleLoss=0.904,ClassLoss=0.345
[Epoch 7] Training cost: 4.817, ObjLoss=9.733,BoxCenterLoss=3.715,BoxScaleLoss=1.100,ClassLoss=0.414
[Epoch 8] Training cost: 7.356, ObjLoss=7.807,BoxCenterLoss=3.664,BoxScaleLoss=1.068,ClassLoss=0.290
[Epoch 9] Training cost: 6.578, ObjLoss=6.162,BoxCenterLoss=3.443,BoxScaleLoss=0.919,ClassLoss=0.296
[Epoch 10] Training cost: 4.801, ObjLoss=5.404,BoxCenterLoss=3.406,BoxScaleLoss=0.921,ClassLoss=0.297
[Epoch 11] Training cost: 6.095, ObjLoss=5.693,BoxCenterLoss=3.508,BoxScaleLoss=0.929,ClassLoss=0.279
[Epoch 12] Training cost: 6.352, ObjLoss=5.427,BoxCenterLoss=3.352,BoxScaleLoss=0.789,ClassLoss=0.236
[Epoch 13] Training cost: 8.626, ObjLoss=6.111,BoxCenterLoss=3.461,BoxScaleLoss=0.938,ClassLoss=0.179
[Epoch 14] Training cost: 6.787, ObjLoss=6.046,BoxCenterLoss=3.414,BoxScaleLoss=0.868,ClassLoss=0.177
[Epoch 15] Training cost: 5.291, ObjLoss=5.817,BoxCenterLoss=3.461,BoxScaleLoss=0.857,ClassLoss=0.230
[Epoch 16] Training cost: 3.775, ObjLoss=5.310,BoxCenterLoss=3.599,BoxScaleLoss=0.903,ClassLoss=0.261
[Epoch 17] Training cost: 4.230, ObjLoss=5.103,BoxCenterLoss=3.514,BoxScaleLoss=0.886,ClassLoss=0.285
[Epoch 18] Training cost: 8.170, ObjLoss=5.762,BoxCenterLoss=3.623,BoxScaleLoss=0.877,ClassLoss=0.193
[Epoch 19] Training cost: 4.026, ObjLoss=5.216,BoxCenterLoss=3.540,BoxScaleLoss=0.871,ClassLoss=0.238
[Epoch 20] Training cost: 5.715, ObjLoss=6.187,BoxCenterLoss=3.484,BoxScaleLoss=0.741,ClassLoss=0.188
[Epoch 21] Training cost: 6.175, ObjLoss=5.079,BoxCenterLoss=3.546,BoxScaleLoss=0.850,ClassLoss=0.150
[Epoch 22] Training cost: 5.652, ObjLoss=5.205,BoxCenterLoss=3.606,BoxScaleLoss=0.840,ClassLoss=0.204
[Epoch 23] Training cost: 5.229, ObjLoss=4.646,BoxCenterLoss=3.355,BoxScaleLoss=0.834,ClassLoss=0.167
[Epoch 24] Training cost: 6.611, ObjLoss=4.975,BoxCenterLoss=3.540,BoxScaleLoss=0.853,ClassLoss=0.150
[Epoch 25] Training cost: 8.073, ObjLoss=4.816,BoxCenterLoss=3.555,BoxScaleLoss=0.888,ClassLoss=0.149
[Epoch 26] Training cost: 5.975, ObjLoss=4.432,BoxCenterLoss=3.485,BoxScaleLoss=0.840,ClassLoss=0.182
[Epoch 27] Training cost: 5.895, ObjLoss=4.296,BoxCenterLoss=3.215,BoxScaleLoss=0.782,ClassLoss=0.127
[Epoch 28] Training cost: 8.773, ObjLoss=5.088,BoxCenterLoss=3.272,BoxScaleLoss=0.885,ClassLoss=0.122
[Epoch 29] Training cost: 4.287, ObjLoss=4.517,BoxCenterLoss=3.369,BoxScaleLoss=0.875,ClassLoss=0.204
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> finish model fitting
The best config: {'lr▁choice': 0, '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.8357329623565528
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)
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)