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 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)
/var/lib/jenkins/miniconda3/envs/autogluon_docs-v0_0_14/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: should_run_async will not call transform_cell automatically in the future. Please pass the result to transformed_cell argument and any exception that happen during thetransform in preprocessing_exc_tuple in IPython 7.17 and above. and should_run_async(code) Downloading ./tiny_motorbike.zip from https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip... 21273KB [00:00, 68556.69KB/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 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_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.38.222/6039/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='')))
Time out (secs) is 18000
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f3e5896f490>, '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.498, ObjLoss=1025.454,BoxCenterLoss=3.902,BoxScaleLoss=2.679,ClassLoss=0.960
[Epoch 0] Validation: motorbike=0.0 mAP=0.0
[Epoch 1] Training cost: 3.192, ObjLoss=50.286,BoxCenterLoss=3.748,BoxScaleLoss=1.747,ClassLoss=0.817
[Epoch 1] Validation: motorbike=0.25805335968379445 mAP=0.25805335968379445
[Epoch 2] Training cost: 3.663, ObjLoss=44.153,BoxCenterLoss=3.879,BoxScaleLoss=1.409,ClassLoss=0.795
[Epoch 2] Validation: motorbike=0.22545970290143547 mAP=0.22545970290143547
[Epoch 3] Training cost: 3.705, ObjLoss=20.912,BoxCenterLoss=3.735,BoxScaleLoss=1.253,ClassLoss=0.713
[Epoch 3] Validation: motorbike=0.45215372650437585 mAP=0.45215372650437585
[Epoch 4] Training cost: 6.700, ObjLoss=19.972,BoxCenterLoss=3.940,BoxScaleLoss=1.348,ClassLoss=0.593
[Epoch 4] Validation: motorbike=0.2655610261081359 mAP=0.2655610261081359
[Epoch 5] Training cost: 3.458, ObjLoss=27.336,BoxCenterLoss=3.674,BoxScaleLoss=1.197,ClassLoss=0.583
[Epoch 5] Validation: motorbike=0.49526464591009595 mAP=0.49526464591009595
[Epoch 6] Training cost: 4.373, ObjLoss=11.639,BoxCenterLoss=3.706,BoxScaleLoss=0.959,ClassLoss=0.452
[Epoch 6] Validation: motorbike=0.6510550310439446 mAP=0.6510550310439446
[Epoch 7] Training cost: 4.918, ObjLoss=7.306,BoxCenterLoss=3.698,BoxScaleLoss=0.956,ClassLoss=0.399
[Epoch 7] Validation: motorbike=0.6929605834182423 mAP=0.6929605834182423
[Epoch 8] Training cost: 5.208, ObjLoss=6.204,BoxCenterLoss=3.314,BoxScaleLoss=0.840,ClassLoss=0.298
[Epoch 8] Validation: motorbike=0.6210590664565561 mAP=0.6210590664565561
[Epoch 9] Training cost: 6.409, ObjLoss=8.218,BoxCenterLoss=3.733,BoxScaleLoss=0.968,ClassLoss=0.317
[Epoch 9] Validation: motorbike=0.7245960187646812 mAP=0.7245960187646812
[Epoch 10] Training cost: 4.658, ObjLoss=8.827,BoxCenterLoss=3.513,BoxScaleLoss=0.881,ClassLoss=0.299
[Epoch 10] Validation: motorbike=0.7181649081294904 mAP=0.7181649081294904
[Epoch 11] Training cost: 8.086, ObjLoss=9.836,BoxCenterLoss=3.727,BoxScaleLoss=0.986,ClassLoss=0.283
[Epoch 11] Validation: motorbike=0.6872805471066662 mAP=0.6872805471066662
[Epoch 12] Training cost: 4.996, ObjLoss=7.732,BoxCenterLoss=3.593,BoxScaleLoss=1.030,ClassLoss=0.297
[Epoch 12] Validation: motorbike=0.5931856022765114 mAP=0.5931856022765114
[Epoch 13] Training cost: 3.559, ObjLoss=6.444,BoxCenterLoss=3.397,BoxScaleLoss=0.988,ClassLoss=0.337
[Epoch 13] Validation: motorbike=0.732785267403659 mAP=0.732785267403659
[Epoch 14] Training cost: 4.321, ObjLoss=6.204,BoxCenterLoss=3.470,BoxScaleLoss=0.983,ClassLoss=0.251
[Epoch 14] Validation: motorbike=0.698246408796794 mAP=0.698246408796794
[Epoch 15] Training cost: 7.256, ObjLoss=6.813,BoxCenterLoss=3.601,BoxScaleLoss=1.062,ClassLoss=0.219
[Epoch 15] Validation: motorbike=0.7532769765390087 mAP=0.7532769765390087
[Epoch 16] Training cost: 5.233, ObjLoss=8.107,BoxCenterLoss=3.600,BoxScaleLoss=1.043,ClassLoss=0.258
[Epoch 16] Validation: motorbike=0.7676291049349719 mAP=0.7676291049349719
[Epoch 17] Training cost: 6.697, ObjLoss=9.619,BoxCenterLoss=3.368,BoxScaleLoss=0.923,ClassLoss=0.212
[Epoch 17] Validation: motorbike=0.7250780159316744 mAP=0.7250780159316744
[Epoch 18] Training cost: 7.596, ObjLoss=12.269,BoxCenterLoss=3.757,BoxScaleLoss=0.980,ClassLoss=0.245
[Epoch 18] Validation: motorbike=0.5712212428091604 mAP=0.5712212428091604
[Epoch 19] Training cost: 5.817, ObjLoss=11.338,BoxCenterLoss=3.429,BoxScaleLoss=0.880,ClassLoss=0.200
[Epoch 19] Validation: motorbike=0.7399654317728755 mAP=0.7399654317728755
[Epoch 20] Training cost: 5.937, ObjLoss=6.246,BoxCenterLoss=3.239,BoxScaleLoss=0.838,ClassLoss=0.135
[Epoch 20] Validation: motorbike=0.795410204787109 mAP=0.795410204787109
[Epoch 21] Training cost: 3.954, ObjLoss=13.077,BoxCenterLoss=3.679,BoxScaleLoss=1.127,ClassLoss=0.267
[Epoch 21] Validation: motorbike=0.7484125739642304 mAP=0.7484125739642304
[Epoch 22] Training cost: 6.124, ObjLoss=10.075,BoxCenterLoss=3.417,BoxScaleLoss=0.887,ClassLoss=0.191
[Epoch 22] Validation: motorbike=0.7607159254886529 mAP=0.7607159254886529
[Epoch 23] Training cost: 7.006, ObjLoss=8.514,BoxCenterLoss=3.495,BoxScaleLoss=0.906,ClassLoss=0.170
[Epoch 23] Validation: motorbike=0.7690300130491519 mAP=0.7690300130491519
[Epoch 24] Training cost: 5.283, ObjLoss=8.640,BoxCenterLoss=3.449,BoxScaleLoss=0.861,ClassLoss=0.182
[Epoch 24] Validation: motorbike=0.778901542608902 mAP=0.778901542608902
[Epoch 25] Training cost: 7.403, ObjLoss=7.586,BoxCenterLoss=3.632,BoxScaleLoss=0.946,ClassLoss=0.155
[Epoch 25] Validation: motorbike=0.7514640023642275 mAP=0.7514640023642275
[Epoch 26] Training cost: 7.026, ObjLoss=6.051,BoxCenterLoss=3.490,BoxScaleLoss=0.888,ClassLoss=0.137
[Epoch 26] Validation: motorbike=0.7945326594028405 mAP=0.7945326594028405
[Epoch 27] Training cost: 3.388, ObjLoss=6.969,BoxCenterLoss=3.426,BoxScaleLoss=0.996,ClassLoss=0.242
[Epoch 27] Validation: motorbike=0.7064152367899023 mAP=0.7064152367899023
[Epoch 28] Training cost: 3.107, ObjLoss=5.414,BoxCenterLoss=3.347,BoxScaleLoss=1.001,ClassLoss=0.237
[Epoch 28] Validation: motorbike=0.723562296289569 mAP=0.723562296289569
[Epoch 29] Training cost: 6.201, ObjLoss=5.060,BoxCenterLoss=3.447,BoxScaleLoss=0.943,ClassLoss=0.129
[Epoch 29] Validation: motorbike=0.7365525338689375 mAP=0.7365525338689375
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f3e589b5310>, '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.760, ObjLoss=1151.588,BoxCenterLoss=4.097,BoxScaleLoss=3.375,ClassLoss=1.103
[Epoch 0] Validation: motorbike=0.012987012987012986 mAP=0.012987012987012986
[Epoch 1] Training cost: 3.607, ObjLoss=20.500,BoxCenterLoss=4.026,BoxScaleLoss=2.251,ClassLoss=0.999
[Epoch 1] Validation: motorbike=0.0 mAP=0.0
[Epoch 2] Training cost: 3.854, ObjLoss=16.795,BoxCenterLoss=3.707,BoxScaleLoss=1.889,ClassLoss=0.820
[Epoch 2] Validation: motorbike=0.09090909090909091 mAP=0.09090909090909091
[Epoch 3] Training cost: 4.194, ObjLoss=13.536,BoxCenterLoss=3.794,BoxScaleLoss=1.600,ClassLoss=0.807
[Epoch 3] Validation: motorbike=0.2644628099173554 mAP=0.2644628099173554
[Epoch 4] Training cost: 7.033, ObjLoss=9.471,BoxCenterLoss=3.820,BoxScaleLoss=1.598,ClassLoss=0.747
[Epoch 4] Validation: motorbike=0.35180547537026485 mAP=0.35180547537026485
[Epoch 5] Training cost: 3.970, ObjLoss=7.597,BoxCenterLoss=3.582,BoxScaleLoss=1.306,ClassLoss=0.713
[Epoch 5] Validation: motorbike=0.29622646124096796 mAP=0.29622646124096796
[Epoch 6] Training cost: 4.523, ObjLoss=7.333,BoxCenterLoss=3.717,BoxScaleLoss=1.233,ClassLoss=0.684
[Epoch 6] Validation: motorbike=0.37566586480295167 mAP=0.37566586480295167
[Epoch 7] Training cost: 4.929, ObjLoss=6.630,BoxCenterLoss=3.799,BoxScaleLoss=1.176,ClassLoss=0.606
[Epoch 7] Validation: motorbike=0.47997421912443333 mAP=0.47997421912443333
[Epoch 8] Training cost: 5.214, ObjLoss=5.987,BoxCenterLoss=3.622,BoxScaleLoss=1.109,ClassLoss=0.553
[Epoch 8] Validation: motorbike=0.6321567539998206 mAP=0.6321567539998206
[Epoch 9] Training cost: 6.791, ObjLoss=7.007,BoxCenterLoss=3.882,BoxScaleLoss=1.193,ClassLoss=0.578
[Epoch 9] Validation: motorbike=0.6615142858776135 mAP=0.6615142858776135
[Epoch 10] Training cost: 5.155, ObjLoss=5.927,BoxCenterLoss=3.707,BoxScaleLoss=1.116,ClassLoss=0.527
[Epoch 10] Validation: motorbike=0.6624736398308392 mAP=0.6624736398308392
[Epoch 11] Training cost: 8.806, ObjLoss=6.595,BoxCenterLoss=3.783,BoxScaleLoss=1.078,ClassLoss=0.460
[Epoch 11] Validation: motorbike=0.7427963994739973 mAP=0.7427963994739973
[Epoch 12] Training cost: 4.980, ObjLoss=5.492,BoxCenterLoss=3.518,BoxScaleLoss=1.143,ClassLoss=0.423
[Epoch 12] Validation: motorbike=0.7236296698722448 mAP=0.7236296698722448
[Epoch 13] Training cost: 3.668, ObjLoss=5.877,BoxCenterLoss=3.625,BoxScaleLoss=1.175,ClassLoss=0.549
[Epoch 13] Validation: motorbike=0.6901738275756935 mAP=0.6901738275756935
[Epoch 14] Training cost: 4.413, ObjLoss=5.336,BoxCenterLoss=3.605,BoxScaleLoss=1.032,ClassLoss=0.439
[Epoch 14] Validation: motorbike=0.7549708568887945 mAP=0.7549708568887945
[Epoch 15] Training cost: 7.632, ObjLoss=6.107,BoxCenterLoss=3.594,BoxScaleLoss=0.995,ClassLoss=0.356
[Epoch 15] Validation: motorbike=0.7536818923102914 mAP=0.7536818923102914
[Epoch 16] Training cost: 5.474, ObjLoss=4.926,BoxCenterLoss=3.501,BoxScaleLoss=0.977,ClassLoss=0.355
[Epoch 16] Validation: motorbike=0.7540266916853993 mAP=0.7540266916853993
[Epoch 17] Training cost: 6.983, ObjLoss=5.620,BoxCenterLoss=3.743,BoxScaleLoss=1.074,ClassLoss=0.396
[Epoch 17] Validation: motorbike=0.7605190411660873 mAP=0.7605190411660873
[Epoch 18] Training cost: 7.956, ObjLoss=5.313,BoxCenterLoss=3.616,BoxScaleLoss=0.990,ClassLoss=0.318
[Epoch 18] Validation: motorbike=0.8035724461705374 mAP=0.8035724461705374
[Epoch 19] Training cost: 6.549, ObjLoss=4.953,BoxCenterLoss=3.656,BoxScaleLoss=0.950,ClassLoss=0.366
[Epoch 19] Validation: motorbike=0.7991164066399177 mAP=0.7991164066399177
[Epoch 20] Training cost: 6.476, ObjLoss=5.226,BoxCenterLoss=3.420,BoxScaleLoss=0.936,ClassLoss=0.293
[Epoch 20] Validation: motorbike=0.8020221540139826 mAP=0.8020221540139826
[Epoch 21] Training cost: 3.768, ObjLoss=5.273,BoxCenterLoss=3.494,BoxScaleLoss=1.022,ClassLoss=0.403
[Epoch 21] Validation: motorbike=0.8289112607294425 mAP=0.8289112607294425
[Epoch 22] Training cost: 6.299, ObjLoss=5.225,BoxCenterLoss=3.509,BoxScaleLoss=0.952,ClassLoss=0.273
[Epoch 22] Validation: motorbike=0.8223121204404628 mAP=0.8223121204404628
[Epoch 23] Training cost: 6.840, ObjLoss=4.596,BoxCenterLoss=3.534,BoxScaleLoss=0.915,ClassLoss=0.262
[Epoch 23] Validation: motorbike=0.8468347823465348 mAP=0.8468347823465348
[Epoch 24] Training cost: 5.203, ObjLoss=4.571,BoxCenterLoss=3.454,BoxScaleLoss=0.820,ClassLoss=0.292
[Epoch 24] Validation: motorbike=0.8407881907177496 mAP=0.8407881907177496
[Epoch 25] Training cost: 7.693, ObjLoss=5.122,BoxCenterLoss=3.507,BoxScaleLoss=0.842,ClassLoss=0.277
[Epoch 25] Validation: motorbike=0.8037132566343147 mAP=0.8037132566343147
[Epoch 26] Training cost: 6.658, ObjLoss=4.778,BoxCenterLoss=3.585,BoxScaleLoss=0.865,ClassLoss=0.251
[Epoch 26] Validation: motorbike=0.8482568604103786 mAP=0.8482568604103786
[Epoch 27] Training cost: 3.483, ObjLoss=5.148,BoxCenterLoss=3.642,BoxScaleLoss=1.117,ClassLoss=0.420
[Epoch 27] Validation: motorbike=0.7496659865331904 mAP=0.7496659865331904
[Epoch 28] Training cost: 3.503, ObjLoss=4.697,BoxCenterLoss=3.415,BoxScaleLoss=0.999,ClassLoss=0.374
[Epoch 28] Validation: motorbike=0.8301298220832072 mAP=0.8301298220832072
[Epoch 29] Training cost: 6.327, ObjLoss=4.554,BoxCenterLoss=3.657,BoxScaleLoss=0.866,ClassLoss=0.259
[Epoch 29] Validation: motorbike=0.8722433176978633 mAP=0.8722433176978633
{'meta_arch': 'yolo3', 'dataset': <autogluon.task.object_detection.dataset.voc.CustomVOCDetection object at 0x7f3d90f43710>, '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: 6.677, ObjLoss=713.689,BoxCenterLoss=3.950,BoxScaleLoss=2.860,ClassLoss=1.007
[Epoch 1] Training cost: 5.418, ObjLoss=16.084,BoxCenterLoss=3.990,BoxScaleLoss=2.084,ClassLoss=0.897
[Epoch 2] Training cost: 7.040, ObjLoss=12.924,BoxCenterLoss=3.697,BoxScaleLoss=1.690,ClassLoss=0.731
[Epoch 3] Training cost: 10.106, ObjLoss=9.975,BoxCenterLoss=3.702,BoxScaleLoss=1.409,ClassLoss=0.673
[Epoch 4] Training cost: 5.819, ObjLoss=8.130,BoxCenterLoss=3.601,BoxScaleLoss=1.287,ClassLoss=0.646
[Epoch 5] Training cost: 8.342, ObjLoss=7.863,BoxCenterLoss=3.925,BoxScaleLoss=1.384,ClassLoss=0.590
[Epoch 6] Training cost: 8.073, ObjLoss=6.681,BoxCenterLoss=3.579,BoxScaleLoss=1.220,ClassLoss=0.495
[Epoch 7] Training cost: 5.217, ObjLoss=5.882,BoxCenterLoss=3.461,BoxScaleLoss=1.143,ClassLoss=0.510
[Epoch 8] Training cost: 7.964, ObjLoss=5.989,BoxCenterLoss=3.547,BoxScaleLoss=1.079,ClassLoss=0.430
[Epoch 9] Training cost: 6.866, ObjLoss=5.435,BoxCenterLoss=3.379,BoxScaleLoss=1.014,ClassLoss=0.396
[Epoch 10] Training cost: 5.377, ObjLoss=5.241,BoxCenterLoss=3.557,BoxScaleLoss=1.112,ClassLoss=0.422
[Epoch 11] Training cost: 6.276, ObjLoss=5.432,BoxCenterLoss=3.689,BoxScaleLoss=1.074,ClassLoss=0.416
[Epoch 12] Training cost: 6.577, ObjLoss=5.386,BoxCenterLoss=3.659,BoxScaleLoss=1.012,ClassLoss=0.390
[Epoch 13] Training cost: 9.108, ObjLoss=5.891,BoxCenterLoss=3.461,BoxScaleLoss=0.986,ClassLoss=0.328
[Epoch 14] Training cost: 6.985, ObjLoss=5.391,BoxCenterLoss=3.690,BoxScaleLoss=1.090,ClassLoss=0.324
[Epoch 15] Training cost: 5.583, ObjLoss=4.804,BoxCenterLoss=3.519,BoxScaleLoss=0.961,ClassLoss=0.324
[Epoch 16] Training cost: 4.107, ObjLoss=4.853,BoxCenterLoss=3.529,BoxScaleLoss=0.971,ClassLoss=0.367
[Epoch 17] Training cost: 4.330, ObjLoss=5.026,BoxCenterLoss=3.548,BoxScaleLoss=0.984,ClassLoss=0.378
[Epoch 18] Training cost: 8.504, ObjLoss=5.087,BoxCenterLoss=3.422,BoxScaleLoss=0.878,ClassLoss=0.235
[Epoch 19] Training cost: 4.187, ObjLoss=5.020,BoxCenterLoss=3.592,BoxScaleLoss=1.006,ClassLoss=0.344
[Epoch 20] Training cost: 6.103, ObjLoss=4.491,BoxCenterLoss=3.346,BoxScaleLoss=0.955,ClassLoss=0.276
[Epoch 21] Training cost: 6.292, ObjLoss=4.601,BoxCenterLoss=3.556,BoxScaleLoss=0.876,ClassLoss=0.255
[Epoch 22] Training cost: 6.229, ObjLoss=4.677,BoxCenterLoss=3.550,BoxScaleLoss=0.939,ClassLoss=0.290
[Epoch 23] Training cost: 5.647, ObjLoss=4.656,BoxCenterLoss=3.557,BoxScaleLoss=0.904,ClassLoss=0.283
[Epoch 24] Training cost: 6.855, ObjLoss=4.747,BoxCenterLoss=3.552,BoxScaleLoss=0.900,ClassLoss=0.241
[Epoch 25] Training cost: 8.546, ObjLoss=4.464,BoxCenterLoss=3.448,BoxScaleLoss=0.793,ClassLoss=0.192
[Epoch 26] Training cost: 6.307, ObjLoss=4.541,BoxCenterLoss=3.594,BoxScaleLoss=0.907,ClassLoss=0.242
[Epoch 27] Training cost: 6.369, ObjLoss=4.088,BoxCenterLoss=3.426,BoxScaleLoss=0.869,ClassLoss=0.194
[Epoch 28] Training cost: 9.459, ObjLoss=4.722,BoxCenterLoss=3.555,BoxScaleLoss=0.875,ClassLoss=0.161
[Epoch 29] Training cost: 4.813, ObjLoss=4.574,BoxCenterLoss=3.531,BoxScaleLoss=0.987,ClassLoss=0.242
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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]))
/var/lib/jenkins/miniconda3/envs/autogluon_docs-v0_0_14/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: should_run_async will not call transform_cell automatically in the future. Please pass the result to transformed_cell argument and any exception that happen during thetransform in preprocessing_exc_tuple in IPython 7.17 and above. and should_run_async(code) >>> create dataset(VOC format)
mAP on test dataset: 0.814954969842188
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)