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 YOLOv3 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.vision and ObjectDetection module as your task:
import autogluon.core as ag
from autogluon.vision 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)
21273KB [00:00, 51860.57KB/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',))
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 YOLOv3 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 epochs.
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: FIFOScheduler(
DistributedResourceManager{
(Remote: Remote REMOTE_ID: 0,
<Remote: 'inproc://172.31.39.52/16082/1' processes=1 threads=8, memory=33.24 GB>, Resource: NodeResourceManager(8 CPUs, 1 GPUs))
})
HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=2.0), HTML(value='')))
INFO:root:{'meta_arch': 'yolo3', 'dataset': <autogluon.vision.object_detection.dataset.voc.CustomVOCDetection object at 0x7f991d11bb10>, '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}
INFO:root:[Epoch 0] Training cost: 9.302, ObjLoss=2162.023,BoxCenterLoss=3.928,BoxScaleLoss=2.349,ClassLoss=1.042
INFO:root:[Epoch 0] Validation: motorbike=0.0 mAP=0.0
INFO:root:[Epoch 1] Training cost: 3.598, ObjLoss=109.146,BoxCenterLoss=3.680,BoxScaleLoss=1.539,ClassLoss=0.874
INFO:root:[Epoch 1] Validation: motorbike=0.0011396877255631958 mAP=0.0011396877255631958
INFO:root:[Epoch 2] Training cost: 6.618, ObjLoss=68.573,BoxCenterLoss=3.626,BoxScaleLoss=1.326,ClassLoss=0.841
INFO:root:[Epoch 2] Validation: motorbike=0.0 mAP=0.0
INFO:root:[Epoch 3] Training cost: 5.492, ObjLoss=94.696,BoxCenterLoss=3.934,BoxScaleLoss=1.456,ClassLoss=0.909
INFO:root:[Epoch 3] Validation: motorbike=0.045454545454545456 mAP=0.045454545454545456
INFO:root:[Epoch 4] Training cost: 3.799, ObjLoss=64.299,BoxCenterLoss=3.795,BoxScaleLoss=1.357,ClassLoss=0.857
INFO:root:[Epoch 4] Validation: motorbike=0.002326076671880752 mAP=0.002326076671880752
INFO:root:[Epoch 5] Training cost: 7.012, ObjLoss=35.744,BoxCenterLoss=3.782,BoxScaleLoss=1.412,ClassLoss=0.732
INFO:root:[Epoch 5] Validation: motorbike=0.14422360248447205 mAP=0.14422360248447205
INFO:root:[Epoch 6] Training cost: 4.872, ObjLoss=32.356,BoxCenterLoss=3.778,BoxScaleLoss=1.227,ClassLoss=0.713
INFO:root:[Epoch 6] Validation: motorbike=0.01415233442646063 mAP=0.01415233442646063
INFO:root:[Epoch 7] Training cost: 3.304, ObjLoss=29.247,BoxCenterLoss=3.820,BoxScaleLoss=1.277,ClassLoss=0.740
INFO:root:[Epoch 7] Validation: motorbike=0.01473200914032398 mAP=0.01473200914032398
INFO:root:[Epoch 8] Training cost: 4.838, ObjLoss=13.009,BoxCenterLoss=3.678,BoxScaleLoss=1.206,ClassLoss=0.600
INFO:root:[Epoch 8] Validation: motorbike=0.16177564940297007 mAP=0.16177564940297007
INFO:root:[Epoch 9] Training cost: 6.258, ObjLoss=15.650,BoxCenterLoss=3.878,BoxScaleLoss=1.146,ClassLoss=0.608
INFO:root:[Epoch 9] Validation: motorbike=0.23323306978132546 mAP=0.23323306978132546
INFO:root:[Epoch 10] Training cost: 6.399, ObjLoss=13.556,BoxCenterLoss=3.613,BoxScaleLoss=1.234,ClassLoss=0.527
INFO:root:[Epoch 10] Validation: motorbike=0.1648214564166537 mAP=0.1648214564166537
INFO:root:[Epoch 11] Training cost: 7.775, ObjLoss=11.192,BoxCenterLoss=3.665,BoxScaleLoss=1.247,ClassLoss=0.527
INFO:root:[Epoch 11] Validation: motorbike=0.19866619866619867 mAP=0.19866619866619867
INFO:root:[Epoch 12] Training cost: 6.742, ObjLoss=27.773,BoxCenterLoss=3.853,BoxScaleLoss=1.178,ClassLoss=0.507
INFO:root:[Epoch 12] Validation: motorbike=0.24768368886015946 mAP=0.24768368886015946
INFO:root:[Epoch 13] Training cost: 7.681, ObjLoss=44.303,BoxCenterLoss=3.697,BoxScaleLoss=1.259,ClassLoss=0.472
INFO:root:[Epoch 13] Validation: motorbike=0.0748663101604278 mAP=0.0748663101604278
INFO:root:[Epoch 14] Training cost: 2.917, ObjLoss=72.715,BoxCenterLoss=3.683,BoxScaleLoss=1.190,ClassLoss=0.560
INFO:root:[Epoch 14] Validation: motorbike=0.2565701260391526 mAP=0.2565701260391526
INFO:root:[Epoch 15] Training cost: 5.206, ObjLoss=58.551,BoxCenterLoss=4.005,BoxScaleLoss=1.247,ClassLoss=0.524
INFO:root:[Epoch 15] Validation: motorbike=0.3341061798499506 mAP=0.3341061798499506
INFO:root:[Epoch 16] Training cost: 5.584, ObjLoss=34.114,BoxCenterLoss=3.850,BoxScaleLoss=1.254,ClassLoss=0.423
INFO:root:[Epoch 16] Validation: motorbike=0.45804298751928113 mAP=0.45804298751928113
INFO:root:[Epoch 17] Training cost: 4.398, ObjLoss=39.262,BoxCenterLoss=3.711,BoxScaleLoss=1.134,ClassLoss=0.437
INFO:root:[Epoch 17] Validation: motorbike=0.4088419448005407 mAP=0.4088419448005407
INFO:root:[Epoch 18] Training cost: 4.353, ObjLoss=44.303,BoxCenterLoss=3.777,BoxScaleLoss=1.051,ClassLoss=0.392
INFO:root:[Epoch 18] Validation: motorbike=0.4448653619108165 mAP=0.4448653619108165
INFO:root:[Epoch 19] Training cost: 3.655, ObjLoss=28.477,BoxCenterLoss=3.812,BoxScaleLoss=1.077,ClassLoss=0.451
INFO:root:[Epoch 19] Validation: motorbike=0.41639523175921317 mAP=0.41639523175921317
INFO:root:[Epoch 20] Training cost: 6.438, ObjLoss=21.827,BoxCenterLoss=3.847,BoxScaleLoss=1.324,ClassLoss=0.334
INFO:root:[Epoch 20] Validation: motorbike=0.46389400073610604 mAP=0.46389400073610604
INFO:root:[Epoch 21] Training cost: 6.966, ObjLoss=13.225,BoxCenterLoss=3.665,BoxScaleLoss=1.103,ClassLoss=0.320
INFO:root:[Epoch 21] Validation: motorbike=0.3406186833149963 mAP=0.3406186833149963
INFO:root:[Epoch 22] Training cost: 3.199, ObjLoss=23.693,BoxCenterLoss=3.818,BoxScaleLoss=1.327,ClassLoss=0.435
INFO:root:[Epoch 22] Validation: motorbike=0.38851991328443203 mAP=0.38851991328443203
INFO:root:[Epoch 23] Training cost: 4.817, ObjLoss=24.845,BoxCenterLoss=3.625,BoxScaleLoss=1.131,ClassLoss=0.344
INFO:root:[Epoch 23] Validation: motorbike=0.24415584415584418 mAP=0.24415584415584418
INFO:root:[Epoch 24] Training cost: 4.896, ObjLoss=63.700,BoxCenterLoss=3.733,BoxScaleLoss=1.199,ClassLoss=0.326
INFO:root:[Epoch 24] Validation: motorbike=0.1650548033526757 mAP=0.1650548033526757
INFO:root:[Epoch 25] Training cost: 4.025, ObjLoss=53.668,BoxCenterLoss=3.702,BoxScaleLoss=1.124,ClassLoss=0.352
INFO:root:[Epoch 25] Validation: motorbike=0.017337398407610994 mAP=0.017337398407610994
INFO:root:[Epoch 26] Training cost: 5.280, ObjLoss=56.195,BoxCenterLoss=3.901,BoxScaleLoss=1.194,ClassLoss=0.316
INFO:root:[Epoch 26] Validation: motorbike=0.28979779323711835 mAP=0.28979779323711835
INFO:root:[Epoch 27] Training cost: 6.361, ObjLoss=55.065,BoxCenterLoss=3.849,BoxScaleLoss=1.126,ClassLoss=0.301
INFO:root:[Epoch 27] Validation: motorbike=0.34747771341329436 mAP=0.34747771341329436
INFO:root:[Epoch 28] Training cost: 6.550, ObjLoss=26.290,BoxCenterLoss=3.713,BoxScaleLoss=1.098,ClassLoss=0.296
INFO:root:[Epoch 28] Validation: motorbike=0.3812998183836142 mAP=0.3812998183836142
INFO:root:[Epoch 29] Training cost: 6.723, ObjLoss=32.635,BoxCenterLoss=3.884,BoxScaleLoss=1.175,ClassLoss=0.325
INFO:root:[Epoch 29] Validation: motorbike=0.35543723804294186 mAP=0.35543723804294186
INFO:root:{'meta_arch': 'yolo3', 'dataset': <autogluon.vision.object_detection.dataset.voc.CustomVOCDetection object at 0x7f985c8d5710>, '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}
INFO:root:[Epoch 0] Training cost: 9.416, ObjLoss=2239.671,BoxCenterLoss=4.164,BoxScaleLoss=3.348,ClassLoss=1.265
INFO:root:[Epoch 0] Validation: motorbike=0.0 mAP=0.0
INFO:root:[Epoch 1] Training cost: 3.246, ObjLoss=28.387,BoxCenterLoss=3.707,BoxScaleLoss=2.191,ClassLoss=0.887
INFO:root:[Epoch 1] Validation: motorbike=0.0 mAP=0.0
INFO:root:[Epoch 2] Training cost: 6.912, ObjLoss=22.197,BoxCenterLoss=3.831,BoxScaleLoss=1.769,ClassLoss=0.866
INFO:root:[Epoch 2] Validation: motorbike=0.0 mAP=0.0
INFO:root:[Epoch 3] Training cost: 5.071, ObjLoss=14.813,BoxCenterLoss=3.737,BoxScaleLoss=1.504,ClassLoss=0.763
INFO:root:[Epoch 3] Validation: motorbike=0.3829245941641871 mAP=0.3829245941641871
INFO:root:[Epoch 4] Training cost: 3.937, ObjLoss=10.714,BoxCenterLoss=3.887,BoxScaleLoss=1.536,ClassLoss=0.832
INFO:root:[Epoch 4] Validation: motorbike=0.42201927284350294 mAP=0.42201927284350294
INFO:root:[Epoch 5] Training cost: 7.301, ObjLoss=10.229,BoxCenterLoss=3.719,BoxScaleLoss=1.266,ClassLoss=0.746
INFO:root:[Epoch 5] Validation: motorbike=0.44520912403687524 mAP=0.44520912403687524
INFO:root:[Epoch 6] Training cost: 4.987, ObjLoss=9.660,BoxCenterLoss=3.680,BoxScaleLoss=1.301,ClassLoss=0.710
INFO:root:[Epoch 6] Validation: motorbike=0.4155013319347587 mAP=0.4155013319347587
INFO:root:[Epoch 7] Training cost: 3.242, ObjLoss=9.052,BoxCenterLoss=3.778,BoxScaleLoss=1.196,ClassLoss=0.790
INFO:root:[Epoch 7] Validation: motorbike=0.5838328435480962 mAP=0.5838328435480962
INFO:root:[Epoch 8] Training cost: 4.907, ObjLoss=6.672,BoxCenterLoss=3.767,BoxScaleLoss=1.090,ClassLoss=0.629
INFO:root:[Epoch 8] Validation: motorbike=0.6709450817828335 mAP=0.6709450817828335
INFO:root:[Epoch 9] Training cost: 6.163, ObjLoss=6.033,BoxCenterLoss=3.696,BoxScaleLoss=0.933,ClassLoss=0.589
INFO:root:[Epoch 9] Validation: motorbike=0.6845302631498791 mAP=0.6845302631498791
INFO:root:[Epoch 10] Training cost: 6.576, ObjLoss=6.807,BoxCenterLoss=3.894,BoxScaleLoss=1.077,ClassLoss=0.605
INFO:root:[Epoch 10] Validation: motorbike=0.6988466079375172 mAP=0.6988466079375172
INFO:root:[Epoch 11] Training cost: 7.931, ObjLoss=7.751,BoxCenterLoss=3.744,BoxScaleLoss=0.991,ClassLoss=0.537
INFO:root:[Epoch 11] Validation: motorbike=0.6932379638072237 mAP=0.6932379638072237
INFO:root:[Epoch 12] Training cost: 6.681, ObjLoss=6.521,BoxCenterLoss=3.938,BoxScaleLoss=0.965,ClassLoss=0.526
INFO:root:[Epoch 12] Validation: motorbike=0.4645902438110231 mAP=0.4645902438110231
INFO:root:[Epoch 13] Training cost: 7.652, ObjLoss=7.504,BoxCenterLoss=3.801,BoxScaleLoss=0.993,ClassLoss=0.474
INFO:root:[Epoch 13] Validation: motorbike=0.7409767000676092 mAP=0.7409767000676092
INFO:root:[Epoch 14] Training cost: 3.250, ObjLoss=10.473,BoxCenterLoss=3.428,BoxScaleLoss=1.104,ClassLoss=0.521
INFO:root:[Epoch 14] Validation: motorbike=0.7926579047359243 mAP=0.7926579047359243
INFO:root:[Epoch 15] Training cost: 4.682, ObjLoss=6.460,BoxCenterLoss=3.670,BoxScaleLoss=0.971,ClassLoss=0.481
INFO:root:[Epoch 15] Validation: motorbike=0.7671846846846847 mAP=0.7671846846846847
INFO:root:[Epoch 16] Training cost: 5.798, ObjLoss=5.825,BoxCenterLoss=3.557,BoxScaleLoss=0.923,ClassLoss=0.383
INFO:root:[Epoch 16] Validation: motorbike=0.6903152450552899 mAP=0.6903152450552899
INFO:root:[Epoch 17] Training cost: 4.225, ObjLoss=5.635,BoxCenterLoss=3.678,BoxScaleLoss=0.939,ClassLoss=0.441
INFO:root:[Epoch 17] Validation: motorbike=0.7430873035616118 mAP=0.7430873035616118
INFO:root:[Epoch 18] Training cost: 4.908, ObjLoss=5.450,BoxCenterLoss=3.761,BoxScaleLoss=0.974,ClassLoss=0.430
INFO:root:[Epoch 18] Validation: motorbike=0.7888923314143257 mAP=0.7888923314143257
INFO:root:[Epoch 19] Training cost: 3.968, ObjLoss=5.217,BoxCenterLoss=3.398,BoxScaleLoss=0.860,ClassLoss=0.439
INFO:root:[Epoch 19] Validation: motorbike=0.8112327821223957 mAP=0.8112327821223957
INFO:root:[Epoch 20] Training cost: 6.837, ObjLoss=5.636,BoxCenterLoss=3.794,BoxScaleLoss=0.872,ClassLoss=0.381
INFO:root:[Epoch 20] Validation: motorbike=0.7510903075419206 mAP=0.7510903075419206
INFO:root:[Epoch 21] Training cost: 7.358, ObjLoss=5.612,BoxCenterLoss=3.755,BoxScaleLoss=0.990,ClassLoss=0.360
INFO:root:[Epoch 21] Validation: motorbike=0.7670957518783605 mAP=0.7670957518783605
INFO:root:[Epoch 22] Training cost: 3.221, ObjLoss=5.811,BoxCenterLoss=3.775,BoxScaleLoss=1.093,ClassLoss=0.494
INFO:root:[Epoch 22] Validation: motorbike=0.7541885015569225 mAP=0.7541885015569225
INFO:root:[Epoch 23] Training cost: 4.676, ObjLoss=5.246,BoxCenterLoss=3.718,BoxScaleLoss=0.952,ClassLoss=0.408
INFO:root:[Epoch 23] Validation: motorbike=0.854446135006125 mAP=0.854446135006125
INFO:root:[Epoch 24] Training cost: 5.072, ObjLoss=4.855,BoxCenterLoss=3.525,BoxScaleLoss=0.785,ClassLoss=0.325
INFO:root:[Epoch 24] Validation: motorbike=0.8062382195157314 mAP=0.8062382195157314
INFO:root:[Epoch 25] Training cost: 3.740, ObjLoss=4.896,BoxCenterLoss=3.596,BoxScaleLoss=0.882,ClassLoss=0.377
INFO:root:[Epoch 25] Validation: motorbike=0.8147300221584888 mAP=0.8147300221584888
INFO:root:[Epoch 26] Training cost: 5.927, ObjLoss=4.830,BoxCenterLoss=3.660,BoxScaleLoss=0.847,ClassLoss=0.303
INFO:root:[Epoch 26] Validation: motorbike=0.8455349574667756 mAP=0.8455349574667756
INFO:root:[Epoch 27] Training cost: 6.977, ObjLoss=5.034,BoxCenterLoss=3.716,BoxScaleLoss=0.937,ClassLoss=0.290
INFO:root:[Epoch 27] Validation: motorbike=0.7717542992857639 mAP=0.7717542992857639
INFO:root:[Epoch 28] Training cost: 6.734, ObjLoss=4.772,BoxCenterLoss=3.595,BoxScaleLoss=0.844,ClassLoss=0.293
INFO:root:[Epoch 28] Validation: motorbike=0.798989898989899 mAP=0.798989898989899
INFO:root:[Epoch 29] Training cost: 6.949, ObjLoss=4.871,BoxCenterLoss=3.755,BoxScaleLoss=0.830,ClassLoss=0.285
INFO:root:[Epoch 29] Validation: motorbike=0.7824798857056923 mAP=0.7824798857056923
INFO:root:{'meta_arch': 'yolo3', 'dataset': <autogluon.vision.object_detection.dataset.voc.CustomVOCDetection object at 0x7f991d10f1d0>, '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}
INFO:root:[Epoch 0] Training cost: 6.332, ObjLoss=713.205,BoxCenterLoss=3.782,BoxScaleLoss=2.716,ClassLoss=0.979
INFO:root:[Epoch 1] Training cost: 5.531, ObjLoss=15.086,BoxCenterLoss=3.605,BoxScaleLoss=1.958,ClassLoss=0.845
INFO:root:[Epoch 2] Training cost: 6.365, ObjLoss=13.005,BoxCenterLoss=3.626,BoxScaleLoss=1.808,ClassLoss=0.744
INFO:root:[Epoch 3] Training cost: 9.176, ObjLoss=10.654,BoxCenterLoss=3.677,BoxScaleLoss=1.448,ClassLoss=0.655
INFO:root:[Epoch 4] Training cost: 5.844, ObjLoss=7.643,BoxCenterLoss=3.679,BoxScaleLoss=1.427,ClassLoss=0.648
INFO:root:[Epoch 5] Training cost: 7.392, ObjLoss=7.259,BoxCenterLoss=3.768,BoxScaleLoss=1.240,ClassLoss=0.547
INFO:root:[Epoch 6] Training cost: 7.596, ObjLoss=6.237,BoxCenterLoss=3.427,BoxScaleLoss=1.051,ClassLoss=0.458
INFO:root:[Epoch 7] Training cost: 4.761, ObjLoss=6.542,BoxCenterLoss=3.689,BoxScaleLoss=1.184,ClassLoss=0.561
INFO:root:[Epoch 8] Training cost: 7.165, ObjLoss=5.696,BoxCenterLoss=3.514,BoxScaleLoss=0.981,ClassLoss=0.398
INFO:root:[Epoch 9] Training cost: 6.455, ObjLoss=5.475,BoxCenterLoss=3.458,BoxScaleLoss=1.042,ClassLoss=0.431
INFO:root:[Epoch 10] Training cost: 5.164, ObjLoss=5.424,BoxCenterLoss=3.417,BoxScaleLoss=1.031,ClassLoss=0.421
INFO:root:[Epoch 11] Training cost: 6.261, ObjLoss=5.231,BoxCenterLoss=3.495,BoxScaleLoss=1.052,ClassLoss=0.411
INFO:root:[Epoch 12] Training cost: 6.167, ObjLoss=5.104,BoxCenterLoss=3.447,BoxScaleLoss=0.993,ClassLoss=0.361
INFO:root:[Epoch 13] Training cost: 8.522, ObjLoss=5.560,BoxCenterLoss=3.614,BoxScaleLoss=0.970,ClassLoss=0.306
INFO:root:[Epoch 14] Training cost: 6.706, ObjLoss=5.314,BoxCenterLoss=3.588,BoxScaleLoss=1.053,ClassLoss=0.355
INFO:root:[Epoch 15] Training cost: 5.774, ObjLoss=5.481,BoxCenterLoss=3.605,BoxScaleLoss=1.002,ClassLoss=0.383
INFO:root:[Epoch 16] Training cost: 3.973, ObjLoss=5.125,BoxCenterLoss=3.537,BoxScaleLoss=1.027,ClassLoss=0.394
INFO:root:[Epoch 17] Training cost: 3.966, ObjLoss=4.399,BoxCenterLoss=3.424,BoxScaleLoss=0.968,ClassLoss=0.344
INFO:root:[Epoch 18] Training cost: 7.768, ObjLoss=5.346,BoxCenterLoss=3.423,BoxScaleLoss=0.973,ClassLoss=0.237
INFO:root:[Epoch 19] Training cost: 4.613, ObjLoss=5.052,BoxCenterLoss=3.503,BoxScaleLoss=1.034,ClassLoss=0.373
INFO:root:[Epoch 20] Training cost: 5.705, ObjLoss=4.562,BoxCenterLoss=3.488,BoxScaleLoss=0.961,ClassLoss=0.311
INFO:root:[Epoch 21] Training cost: 5.800, ObjLoss=4.453,BoxCenterLoss=3.566,BoxScaleLoss=0.971,ClassLoss=0.264
INFO:root:[Epoch 22] Training cost: 6.192, ObjLoss=4.617,BoxCenterLoss=3.596,BoxScaleLoss=0.977,ClassLoss=0.298
INFO:root:[Epoch 23] Training cost: 5.075, ObjLoss=4.338,BoxCenterLoss=3.465,BoxScaleLoss=0.875,ClassLoss=0.273
INFO:root:[Epoch 24] Training cost: 6.559, ObjLoss=4.583,BoxCenterLoss=3.554,BoxScaleLoss=0.867,ClassLoss=0.224
INFO:root:[Epoch 25] Training cost: 7.935, ObjLoss=4.748,BoxCenterLoss=3.531,BoxScaleLoss=0.883,ClassLoss=0.228
INFO:root:[Epoch 26] Training cost: 5.809, ObjLoss=4.458,BoxCenterLoss=3.561,BoxScaleLoss=0.893,ClassLoss=0.259
INFO:root:[Epoch 27] Training cost: 6.225, ObjLoss=4.256,BoxCenterLoss=3.297,BoxScaleLoss=0.865,ClassLoss=0.214
INFO:root:[Epoch 28] Training cost: 8.544, ObjLoss=4.781,BoxCenterLoss=3.561,BoxScaleLoss=0.898,ClassLoss=0.199
INFO:root:[Epoch 29] Training cost: 4.389, ObjLoss=4.033,BoxCenterLoss=3.284,BoxScaleLoss=0.929,ClassLoss=0.239
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]))
mAP on test dataset: 0.7716102349689552
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.vision import Detector
new_detector = Detector.load(savefile)