.. _sec_object_detection_quick: 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 :ref:`sec_imgquick` 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: .. code:: python 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``. .. code:: python root = './' filename_zip = ag.download('https://autogluon.s3.amazonaws.com/datasets/tiny_motorbike.zip', path=root) filename = ag.unzip(filename_zip, root=root) .. parsed-literal:: :class: output 21273KB [00:00, 64530.27KB/s] When we retrieve the dataset, we can create a dataset instance with its path and classes if it is a custom dataset. .. code:: python 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. .. code:: python 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) .. parsed-literal:: :class: output scheduler: FIFOScheduler( DistributedResourceManager{ (Remote: Remote REMOTE_ID: 0, , Resource: NodeResourceManager(8 CPUs, 1 GPUs)) }) .. parsed-literal:: :class: output HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=2.0), HTML(value=''))) .. parsed-literal:: :class: output INFO:root:{'meta_arch': 'yolo3', 'dataset': , '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: 5.550, ObjLoss=743.047,BoxCenterLoss=3.541,BoxScaleLoss=2.480,ClassLoss=0.916 INFO:root:[Epoch 0] Validation: motorbike=0.0 mAP=0.0 INFO:root:[Epoch 1] Training cost: 4.211, ObjLoss=33.338,BoxCenterLoss=3.683,BoxScaleLoss=1.624,ClassLoss=0.835 INFO:root:[Epoch 1] Validation: motorbike=0.0303030303030303 mAP=0.0303030303030303 INFO:root:[Epoch 2] Training cost: 6.221, ObjLoss=21.797,BoxCenterLoss=3.657,BoxScaleLoss=1.409,ClassLoss=0.717 INFO:root:[Epoch 2] Validation: motorbike=0.15229127960619673 mAP=0.15229127960619673 INFO:root:[Epoch 3] Training cost: 3.538, ObjLoss=20.184,BoxCenterLoss=3.721,BoxScaleLoss=1.396,ClassLoss=0.694 INFO:root:[Epoch 3] Validation: motorbike=0.18229599979355463 mAP=0.18229599979355463 INFO:root:[Epoch 4] Training cost: 3.730, ObjLoss=17.578,BoxCenterLoss=3.625,BoxScaleLoss=1.335,ClassLoss=0.606 INFO:root:[Epoch 4] Validation: motorbike=0.4485862052408224 mAP=0.4485862052408224 INFO:root:[Epoch 5] Training cost: 3.703, ObjLoss=14.644,BoxCenterLoss=3.744,BoxScaleLoss=1.205,ClassLoss=0.646 INFO:root:[Epoch 5] Validation: motorbike=0.35256400485131256 mAP=0.35256400485131256 INFO:root:[Epoch 6] Training cost: 6.271, ObjLoss=13.078,BoxCenterLoss=3.590,BoxScaleLoss=1.235,ClassLoss=0.498 INFO:root:[Epoch 6] Validation: motorbike=0.3853689638378634 mAP=0.3853689638378634 INFO:root:[Epoch 7] Training cost: 4.607, ObjLoss=14.107,BoxCenterLoss=3.406,BoxScaleLoss=1.114,ClassLoss=0.452 INFO:root:[Epoch 7] Validation: motorbike=0.5105032902302911 mAP=0.5105032902302911 INFO:root:[Epoch 8] Training cost: 6.793, ObjLoss=10.122,BoxCenterLoss=3.493,BoxScaleLoss=1.056,ClassLoss=0.321 INFO:root:[Epoch 8] Validation: motorbike=0.6566899150232484 mAP=0.6566899150232484 INFO:root:[Epoch 9] Training cost: 6.640, ObjLoss=10.550,BoxCenterLoss=3.332,BoxScaleLoss=0.899,ClassLoss=0.312 INFO:root:[Epoch 9] Validation: motorbike=0.5967563113264563 mAP=0.5967563113264563 INFO:root:[Epoch 10] Training cost: 6.787, ObjLoss=8.834,BoxCenterLoss=3.437,BoxScaleLoss=0.944,ClassLoss=0.277 INFO:root:[Epoch 10] Validation: motorbike=0.6796814296814296 mAP=0.6796814296814296 INFO:root:[Epoch 11] Training cost: 3.996, ObjLoss=12.229,BoxCenterLoss=3.472,BoxScaleLoss=1.033,ClassLoss=0.368 INFO:root:[Epoch 11] Validation: motorbike=0.7030695814005539 mAP=0.7030695814005539 INFO:root:[Epoch 12] Training cost: 5.385, ObjLoss=6.838,BoxCenterLoss=3.458,BoxScaleLoss=0.854,ClassLoss=0.275 INFO:root:[Epoch 12] Validation: motorbike=0.6964525119209569 mAP=0.6964525119209569 INFO:root:[Epoch 13] Training cost: 3.461, ObjLoss=9.435,BoxCenterLoss=3.334,BoxScaleLoss=0.964,ClassLoss=0.362 INFO:root:[Epoch 13] Validation: motorbike=0.5928087324861518 mAP=0.5928087324861518 INFO:root:[Epoch 14] Training cost: 3.659, ObjLoss=9.404,BoxCenterLoss=3.517,BoxScaleLoss=0.953,ClassLoss=0.310 INFO:root:[Epoch 14] Validation: motorbike=0.685586711484716 mAP=0.685586711484716 INFO:root:[Epoch 15] Training cost: 4.722, ObjLoss=8.980,BoxCenterLoss=3.307,BoxScaleLoss=0.811,ClassLoss=0.321 INFO:root:[Epoch 15] Validation: motorbike=0.7307586316122902 mAP=0.7307586316122902 INFO:root:[Epoch 16] Training cost: 4.014, ObjLoss=7.042,BoxCenterLoss=3.343,BoxScaleLoss=0.853,ClassLoss=0.264 INFO:root:[Epoch 16] Validation: motorbike=0.6871621621621622 mAP=0.6871621621621622 INFO:root:[Epoch 17] Training cost: 3.963, ObjLoss=5.720,BoxCenterLoss=3.283,BoxScaleLoss=0.856,ClassLoss=0.265 INFO:root:[Epoch 17] Validation: motorbike=0.7054391987793628 mAP=0.7054391987793628 INFO:root:[Epoch 18] Training cost: 3.491, ObjLoss=5.835,BoxCenterLoss=3.557,BoxScaleLoss=0.921,ClassLoss=0.266 INFO:root:[Epoch 18] Validation: motorbike=0.7255157708439132 mAP=0.7255157708439132 INFO:root:[Epoch 19] Training cost: 3.419, ObjLoss=6.228,BoxCenterLoss=3.513,BoxScaleLoss=0.877,ClassLoss=0.289 INFO:root:[Epoch 19] Validation: motorbike=0.7673262466783052 mAP=0.7673262466783052 INFO:root:[Epoch 20] Training cost: 3.772, ObjLoss=5.422,BoxCenterLoss=3.262,BoxScaleLoss=0.828,ClassLoss=0.228 INFO:root:[Epoch 20] Validation: motorbike=0.7142471821264391 mAP=0.7142471821264391 INFO:root:[Epoch 21] Training cost: 6.505, ObjLoss=5.785,BoxCenterLoss=3.386,BoxScaleLoss=0.909,ClassLoss=0.150 INFO:root:[Epoch 21] Validation: motorbike=0.797701964859583 mAP=0.797701964859583 INFO:root:[Epoch 22] Training cost: 5.254, ObjLoss=5.973,BoxCenterLoss=3.554,BoxScaleLoss=0.896,ClassLoss=0.183 INFO:root:[Epoch 22] Validation: motorbike=0.7634377602665129 mAP=0.7634377602665129 INFO:root:[Epoch 23] Training cost: 3.650, ObjLoss=5.175,BoxCenterLoss=3.372,BoxScaleLoss=0.832,ClassLoss=0.195 INFO:root:[Epoch 23] Validation: motorbike=0.724888125573057 mAP=0.724888125573057 INFO:root:[Epoch 24] Training cost: 4.904, ObjLoss=5.621,BoxCenterLoss=3.623,BoxScaleLoss=0.948,ClassLoss=0.200 INFO:root:[Epoch 24] Validation: motorbike=0.7301328939259975 mAP=0.7301328939259975 INFO:root:[Epoch 25] Training cost: 4.366, ObjLoss=5.174,BoxCenterLoss=3.317,BoxScaleLoss=0.819,ClassLoss=0.195 INFO:root:[Epoch 25] Validation: motorbike=0.8037408433876359 mAP=0.8037408433876359 INFO:root:[Epoch 26] Training cost: 4.785, ObjLoss=4.920,BoxCenterLoss=3.256,BoxScaleLoss=0.842,ClassLoss=0.153 INFO:root:[Epoch 26] Validation: motorbike=0.7520477415214258 mAP=0.7520477415214258 INFO:root:[Epoch 27] Training cost: 5.787, ObjLoss=5.384,BoxCenterLoss=3.339,BoxScaleLoss=0.717,ClassLoss=0.132 INFO:root:[Epoch 27] Validation: motorbike=0.8062521877835017 mAP=0.8062521877835017 INFO:root:[Epoch 28] Training cost: 4.132, ObjLoss=4.931,BoxCenterLoss=3.181,BoxScaleLoss=0.758,ClassLoss=0.128 INFO:root:[Epoch 28] Validation: motorbike=0.8308813566260375 mAP=0.8308813566260375 INFO:root:[Epoch 29] Training cost: 5.582, ObjLoss=4.901,BoxCenterLoss=3.319,BoxScaleLoss=0.827,ClassLoss=0.112 INFO:root:[Epoch 29] Validation: motorbike=0.752907541779015 mAP=0.752907541779015 .. parsed-literal:: :class: output .. parsed-literal:: :class: output INFO:root:{'meta_arch': 'yolo3', 'dataset': , '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: 5.788, ObjLoss=887.231,BoxCenterLoss=3.610,BoxScaleLoss=2.740,ClassLoss=1.016 INFO:root:[Epoch 0] Validation: motorbike=0.012692634262756212 mAP=0.012692634262756212 INFO:root:[Epoch 1] Training cost: 4.289, ObjLoss=14.288,BoxCenterLoss=3.433,BoxScaleLoss=2.089,ClassLoss=0.914 INFO:root:[Epoch 1] Validation: motorbike=0.0 mAP=0.0 INFO:root:[Epoch 2] Training cost: 6.410, ObjLoss=14.401,BoxCenterLoss=3.805,BoxScaleLoss=1.889,ClassLoss=0.838 INFO:root:[Epoch 2] Validation: motorbike=0.15584415584415584 mAP=0.15584415584415584 INFO:root:[Epoch 3] Training cost: 3.862, ObjLoss=15.998,BoxCenterLoss=3.835,BoxScaleLoss=1.797,ClassLoss=0.769 INFO:root:[Epoch 3] Validation: motorbike=0.3375879165225412 mAP=0.3375879165225412 INFO:root:[Epoch 4] Training cost: 3.913, ObjLoss=9.353,BoxCenterLoss=3.757,BoxScaleLoss=1.570,ClassLoss=0.707 INFO:root:[Epoch 4] Validation: motorbike=0.3652805794975243 mAP=0.3652805794975243 INFO:root:[Epoch 5] Training cost: 3.575, ObjLoss=8.162,BoxCenterLoss=3.613,BoxScaleLoss=1.372,ClassLoss=0.713 INFO:root:[Epoch 5] Validation: motorbike=0.44498872046886784 mAP=0.44498872046886784 INFO:root:[Epoch 6] Training cost: 6.561, ObjLoss=7.205,BoxCenterLoss=3.814,BoxScaleLoss=1.249,ClassLoss=0.587 INFO:root:[Epoch 6] Validation: motorbike=0.4495434154924295 mAP=0.4495434154924295 INFO:root:[Epoch 7] Training cost: 4.627, ObjLoss=6.068,BoxCenterLoss=3.469,BoxScaleLoss=1.187,ClassLoss=0.553 INFO:root:[Epoch 7] Validation: motorbike=0.6412523856072242 mAP=0.6412523856072242 INFO:root:[Epoch 8] Training cost: 7.046, ObjLoss=6.776,BoxCenterLoss=3.643,BoxScaleLoss=1.114,ClassLoss=0.512 INFO:root:[Epoch 8] Validation: motorbike=0.6233064962036925 mAP=0.6233064962036925 INFO:root:[Epoch 9] Training cost: 6.995, ObjLoss=6.000,BoxCenterLoss=3.550,BoxScaleLoss=1.110,ClassLoss=0.447 INFO:root:[Epoch 9] Validation: motorbike=0.5812085703846757 mAP=0.5812085703846757 INFO:root:[Epoch 10] Training cost: 6.900, ObjLoss=5.855,BoxCenterLoss=3.344,BoxScaleLoss=0.926,ClassLoss=0.391 INFO:root:[Epoch 10] Validation: motorbike=0.652847267441619 mAP=0.652847267441619 INFO:root:[Epoch 11] Training cost: 4.017, ObjLoss=6.185,BoxCenterLoss=3.682,BoxScaleLoss=1.180,ClassLoss=0.535 INFO:root:[Epoch 11] Validation: motorbike=0.6612478073223106 mAP=0.6612478073223106 INFO:root:[Epoch 12] Training cost: 5.256, ObjLoss=5.306,BoxCenterLoss=3.348,BoxScaleLoss=1.014,ClassLoss=0.368 INFO:root:[Epoch 12] Validation: motorbike=0.7191117400479203 mAP=0.7191117400479203 INFO:root:[Epoch 13] Training cost: 3.227, ObjLoss=5.569,BoxCenterLoss=3.519,BoxScaleLoss=1.106,ClassLoss=0.534 INFO:root:[Epoch 13] Validation: motorbike=0.6957360820997184 mAP=0.6957360820997184 INFO:root:[Epoch 14] Training cost: 4.036, ObjLoss=5.235,BoxCenterLoss=3.521,BoxScaleLoss=0.994,ClassLoss=0.413 INFO:root:[Epoch 14] Validation: motorbike=0.7275157275157275 mAP=0.7275157275157275 INFO:root:[Epoch 15] Training cost: 4.545, ObjLoss=4.926,BoxCenterLoss=3.411,BoxScaleLoss=0.957,ClassLoss=0.410 INFO:root:[Epoch 15] Validation: motorbike=0.7640561458743278 mAP=0.7640561458743278 INFO:root:[Epoch 16] Training cost: 4.503, ObjLoss=5.069,BoxCenterLoss=3.626,BoxScaleLoss=0.979,ClassLoss=0.404 INFO:root:[Epoch 16] Validation: motorbike=0.7610060394151305 mAP=0.7610060394151305 INFO:root:[Epoch 17] Training cost: 3.892, ObjLoss=4.888,BoxCenterLoss=3.515,BoxScaleLoss=1.061,ClassLoss=0.391 INFO:root:[Epoch 17] Validation: motorbike=0.7631065903793176 mAP=0.7631065903793176 INFO:root:[Epoch 18] Training cost: 3.495, ObjLoss=4.825,BoxCenterLoss=3.517,BoxScaleLoss=0.984,ClassLoss=0.365 INFO:root:[Epoch 18] Validation: motorbike=0.7979947759065183 mAP=0.7979947759065183 INFO:root:[Epoch 19] Training cost: 3.564, ObjLoss=4.675,BoxCenterLoss=3.507,BoxScaleLoss=1.033,ClassLoss=0.380 INFO:root:[Epoch 19] Validation: motorbike=0.7857805624254514 mAP=0.7857805624254514 INFO:root:[Epoch 20] Training cost: 3.550, ObjLoss=4.226,BoxCenterLoss=3.223,BoxScaleLoss=0.847,ClassLoss=0.315 INFO:root:[Epoch 20] Validation: motorbike=0.8069452792901995 mAP=0.8069452792901995 INFO:root:[Epoch 21] Training cost: 6.567, ObjLoss=5.112,BoxCenterLoss=3.406,BoxScaleLoss=0.909,ClassLoss=0.272 INFO:root:[Epoch 21] Validation: motorbike=0.7986070282721 mAP=0.7986070282721 INFO:root:[Epoch 22] Training cost: 5.198, ObjLoss=4.847,BoxCenterLoss=3.548,BoxScaleLoss=0.964,ClassLoss=0.278 INFO:root:[Epoch 22] Validation: motorbike=0.8159504102717108 mAP=0.8159504102717108 INFO:root:[Epoch 23] Training cost: 3.508, ObjLoss=4.396,BoxCenterLoss=3.299,BoxScaleLoss=0.932,ClassLoss=0.324 INFO:root:[Epoch 23] Validation: motorbike=0.8112025528815524 mAP=0.8112025528815524 INFO:root:[Epoch 24] Training cost: 4.728, ObjLoss=4.640,BoxCenterLoss=3.524,BoxScaleLoss=0.919,ClassLoss=0.280 INFO:root:[Epoch 24] Validation: motorbike=0.8241794439151704 mAP=0.8241794439151704 INFO:root:[Epoch 25] Training cost: 4.696, ObjLoss=4.223,BoxCenterLoss=3.474,BoxScaleLoss=0.953,ClassLoss=0.262 INFO:root:[Epoch 25] Validation: motorbike=0.8242634262639366 mAP=0.8242634262639366 INFO:root:[Epoch 26] Training cost: 4.629, ObjLoss=4.398,BoxCenterLoss=3.582,BoxScaleLoss=0.852,ClassLoss=0.270 INFO:root:[Epoch 26] Validation: motorbike=0.8561498310302138 mAP=0.8561498310302138 INFO:root:[Epoch 27] Training cost: 6.108, ObjLoss=4.261,BoxCenterLoss=3.357,BoxScaleLoss=0.905,ClassLoss=0.215 INFO:root:[Epoch 27] Validation: motorbike=0.8323144130766638 mAP=0.8323144130766638 INFO:root:[Epoch 28] Training cost: 4.251, ObjLoss=4.186,BoxCenterLoss=3.146,BoxScaleLoss=0.778,ClassLoss=0.215 INFO:root:[Epoch 28] Validation: motorbike=0.828824126431782 mAP=0.828824126431782 INFO:root:[Epoch 29] Training cost: 5.650, ObjLoss=4.612,BoxCenterLoss=3.527,BoxScaleLoss=0.901,ClassLoss=0.238 INFO:root:[Epoch 29] Validation: motorbike=0.8320460895292883 mAP=0.8320460895292883 INFO:root:{'meta_arch': 'yolo3', 'dataset': , '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.367, ObjLoss=713.653,BoxCenterLoss=3.844,BoxScaleLoss=2.822,ClassLoss=1.006 INFO:root:[Epoch 1] Training cost: 5.245, ObjLoss=15.767,BoxCenterLoss=3.840,BoxScaleLoss=2.086,ClassLoss=0.910 INFO:root:[Epoch 2] Training cost: 6.454, ObjLoss=13.244,BoxCenterLoss=3.711,BoxScaleLoss=1.675,ClassLoss=0.746 INFO:root:[Epoch 3] Training cost: 9.119, ObjLoss=9.872,BoxCenterLoss=3.644,BoxScaleLoss=1.539,ClassLoss=0.644 INFO:root:[Epoch 4] Training cost: 5.116, ObjLoss=7.835,BoxCenterLoss=3.812,BoxScaleLoss=1.476,ClassLoss=0.714 INFO:root:[Epoch 5] Training cost: 7.344, ObjLoss=6.980,BoxCenterLoss=3.646,BoxScaleLoss=1.266,ClassLoss=0.574 INFO:root:[Epoch 6] Training cost: 7.595, ObjLoss=6.505,BoxCenterLoss=3.471,BoxScaleLoss=1.134,ClassLoss=0.477 INFO:root:[Epoch 7] Training cost: 4.916, ObjLoss=6.412,BoxCenterLoss=3.677,BoxScaleLoss=1.178,ClassLoss=0.555 INFO:root:[Epoch 8] Training cost: 7.097, ObjLoss=6.043,BoxCenterLoss=3.763,BoxScaleLoss=1.089,ClassLoss=0.454 INFO:root:[Epoch 9] Training cost: 6.154, ObjLoss=5.690,BoxCenterLoss=3.519,BoxScaleLoss=1.110,ClassLoss=0.422 INFO:root:[Epoch 10] Training cost: 4.791, ObjLoss=5.472,BoxCenterLoss=3.662,BoxScaleLoss=1.072,ClassLoss=0.453 INFO:root:[Epoch 11] Training cost: 5.970, ObjLoss=5.234,BoxCenterLoss=3.605,BoxScaleLoss=1.059,ClassLoss=0.411 INFO:root:[Epoch 12] Training cost: 6.086, ObjLoss=4.999,BoxCenterLoss=3.718,BoxScaleLoss=1.040,ClassLoss=0.392 INFO:root:[Epoch 13] Training cost: 8.256, ObjLoss=5.373,BoxCenterLoss=3.504,BoxScaleLoss=0.941,ClassLoss=0.315 INFO:root:[Epoch 14] Training cost: 6.383, ObjLoss=5.360,BoxCenterLoss=3.724,BoxScaleLoss=1.014,ClassLoss=0.353 INFO:root:[Epoch 15] Training cost: 5.257, ObjLoss=5.411,BoxCenterLoss=3.624,BoxScaleLoss=1.036,ClassLoss=0.351 INFO:root:[Epoch 16] Training cost: 3.830, ObjLoss=4.875,BoxCenterLoss=3.457,BoxScaleLoss=0.917,ClassLoss=0.363 INFO:root:[Epoch 17] Training cost: 4.103, ObjLoss=4.808,BoxCenterLoss=3.487,BoxScaleLoss=0.923,ClassLoss=0.393 INFO:root:[Epoch 18] Training cost: 7.804, ObjLoss=5.314,BoxCenterLoss=3.476,BoxScaleLoss=0.958,ClassLoss=0.271 INFO:root:[Epoch 19] Training cost: 4.236, ObjLoss=5.220,BoxCenterLoss=3.606,BoxScaleLoss=1.041,ClassLoss=0.365 INFO:root:[Epoch 20] Training cost: 5.314, ObjLoss=4.575,BoxCenterLoss=3.587,BoxScaleLoss=0.971,ClassLoss=0.326 INFO:root:[Epoch 21] Training cost: 6.062, ObjLoss=4.537,BoxCenterLoss=3.535,BoxScaleLoss=0.888,ClassLoss=0.278 INFO:root:[Epoch 22] Training cost: 5.910, ObjLoss=4.299,BoxCenterLoss=3.287,BoxScaleLoss=0.824,ClassLoss=0.256 INFO:root:[Epoch 23] Training cost: 5.279, ObjLoss=4.495,BoxCenterLoss=3.482,BoxScaleLoss=0.886,ClassLoss=0.277 INFO:root:[Epoch 24] Training cost: 6.433, ObjLoss=4.542,BoxCenterLoss=3.560,BoxScaleLoss=0.816,ClassLoss=0.215 INFO:root:[Epoch 25] Training cost: 7.763, ObjLoss=4.627,BoxCenterLoss=3.465,BoxScaleLoss=0.874,ClassLoss=0.219 INFO:root:[Epoch 26] Training cost: 5.843, ObjLoss=4.568,BoxCenterLoss=3.552,BoxScaleLoss=0.890,ClassLoss=0.270 INFO:root:[Epoch 27] Training cost: 5.966, ObjLoss=4.022,BoxCenterLoss=3.189,BoxScaleLoss=0.818,ClassLoss=0.198 INFO:root:[Epoch 28] Training cost: 8.171, ObjLoss=4.460,BoxCenterLoss=3.438,BoxScaleLoss=0.867,ClassLoss=0.163 INFO:root:[Epoch 29] Training cost: 4.489, ObjLoss=4.575,BoxCenterLoss=3.582,BoxScaleLoss=0.854,ClassLoss=0.295 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``. Also note that hyperparameter tuning defaults to random search. Model-based variants, such as ``search_strategy='bayesopt'`` or ``search_strategy='bayesopt_hyperband'`` can be a lot more sample-efficient. 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(). .. code:: python 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])) .. parsed-literal:: :class: output mAP on test dataset: 0.799905155044474 Below, we randomly select an image from test dataset and show the predicted box and probability over the origin image. .. code:: python image = '000467.jpg' image_path = os.path.join(data_root, 'JPEGImages', image) ind, prob, loc = detector.predict(image_path) .. figure:: output_beginner_1fd7a6_11_0.png We can also save the trained model, and use it later. .. code:: python savefile = 'model.pkl' detector.save(savefile) from autogluon.vision import Detector new_detector = Detector.load(savefile)