Note: TL;DR Using the DeepSparse engine leads to speedups of up to 375% when running YOLOv5 on a CPU.

Download the pistol dataset and explore the data

Download the Pistols dataset from Roboflow's public database.

Select YOLOv5 from the download formats and copy your unique terminal command into the cell below.

Tip: Click on "Open In Colab" tag above to run this notebook yourself.
! curl -L "https://public.roboflow.com/ds/xXg040ThIk?key=[YOUR_UNIQUE_KEY_HERE]" > data.zip \
  && unzip -q data.zip -d downloads \
  && rm data.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   901  100   901    0     0   1709      0 --:--:-- --:--:-- --:--:--  1706
100 58.4M  100 58.4M    0     0  21.0M      0  0:00:02  0:00:02 --:--:-- 37.1M

To explore the data we will use the dataset exploration toolset from Fiftyone.

To use Fiftyone with Colab we need to install opencv-python-headless==4.5.4.60.

! pip install -q opencv-python-headless==4.5.4.60 fiftyone
import fiftyone as fo

# Import dataset by explicitly providing paths to the source images and labels
dataset = fo.Dataset.from_dir(
    dataset_type=fo.types.YOLOv4Dataset,
    data_path="downloads/export/images",
    label_field="ground_truth",
    labels_path="downloads/export/labels",
    classes=["pistol"],
)

# View the data using the interactive dashboard
session = fo.launch_app(dataset)

image.png

The pistol images seem to be correctly labelled with a good variety of different pistols included in the dataset. The image size is 416x416 for all images.

Split the dataset into train/test/val subsets

Next we can use Fiftyone utilities to split the dataset into three subsets. We define a convenience function called "split_dataset" to help us process the data.

import fiftyone.utils.splits as fous
import os


def split_dataset(dataset, split_dict, output_path):
    fous.random_split(dataset, split_dict, seed=42)

    for tag in list(split_dict.keys()):
        view = dataset.match_tags(tag)
        # Export each split separately
        export_dir = os.path.join(output_path, tag)
        view.export(
            export_dir=export_dir,
            dataset_type=fo.types.YOLOv4Dataset,
            label_field="ground_truth",
        )


split_dataset(
    dataset=dataset,
    split_dict={"train": 0.8, "test": 0.1, "val": 0.1},
    output_path="dataset/guns/",
)
 100% |███████████████| 2377/2377 [2.7s elapsed, 0s remaining, 926.0 samples/s]      
 100% |█████████████████| 297/297 [334.7ms elapsed, 0s remaining, 887.5 samples/s]      
 100% |█████████████████| 297/297 [332.1ms elapsed, 0s remaining, 894.3 samples/s]      

To use the dataset with a YOLO training pipeline we need to define a *.yml file that points to the data locations. To read more about training on a custom dataset using YOLOv5, see Train Custom Data by the Ultralytics team.

content = """# Train/val/test sets
path: /content/dataset/guns  # dataset root dir
train: train/data  # train images (relative to 'path')
test: test/data  # test images (relative to 'path')
val: val/data  # val images (relative to 'path')

# classes
nc: 1 # number of classes
names: ['pistol']"""

with open("pistols.yml", "w") as f:
    f.write(content)

Remove the downloaded data to clean up the workspace.

! rm -r downloads

Install DeepSparse and SparseML libraries and train our model

To train our own custom model using the pistol dataset we will use the SparseML YOLOv5 Integration provided by Neuralmagic.

First, we install the required libraries and we grab the transfer learning recipe from their repo.

Note, you can also use the built-in recipe, like this:

--recipe zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned-aggressive_96

However, if you want to specify the number of epochs or the learning rate rather use the downloaded recipe saved to yolov5.transfer_learn_pruned.md.

! pip install -q deepsparse[yolo] sparseml[torchvision]
! curl -LO "https://raw.githubusercontent.com/neuralmagic/sparseml/main/integrations/ultralytics-yolov5/recipes/yolov5.transfer_learn_pruned.md"

Now we can train our model using transfer learning on YOLOv5s (small) and the downloaded recipe. We use the CLI and run sparseml.yolov5.train

The arguments we use with sparseml.yolov5.train are shown below. For more info on each argument, just run:

! sparseml.yolov5.train --help

For more information on the pre-trained weights you can use with YOLOv5 feel free to refer to the Sparse Transfer Learning With YOLOv5 example. Neuralmagic provides several pre-pruned and pre-quatized models in their SparseZoo. We will use the YOLOv5s Pruned model. A short description of the model quoted from the SparseZoo YOLOv5 page:

"Pruned YOLOv5s model with HardSwish activations sparsified using the ultralytics/yolov5 SparseML integration on the COCO dataset. Achieves 96% recovery of the performance for the dense baseline. The majority of layers are pruned between 60 and 80%, with some more senstive layers pruned to 50%. The final accuracy is 53.4 mAP@0.5 as reported by the Ultralytics training script. The model was trained for 240 epochs at FP16 across 4 A100 GPUs on the COCO dataset with a total batch size of 256. Full instructions to reproduce this model's training are found in the ultralytics/yolov5 SparseML integration."

We train our model for 50 epochs. Click on "Show Output" to view the results.

! sparseml.yolov5.train \
  --data pistols.yml \
  --cfg models_v5.0/yolov5s.yaml \
  --weights zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned-aggressive_96 \
  --hyp data/hyps/hyp.finetune.yaml \
  --batch-size -1 \
  --imgsz 416 \
  --recipe yolov5.transfer_learn_pruned.md

train: weights=zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned-aggressive_96, cfg=models_v5.0/yolov5s.yaml, data=pistols.yml, hyp=data/hyps/hyp.finetune.yaml, epochs=300, batch_size=-1, imgsz=416, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=yolov5_runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=0, freeze=[0], save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest, recipe=yolov5.transfer_learn_pruned.md, disable_ema=False, max_train_steps=-1, max_eval_steps=-1, one_shot=False, num_export_samples=0
github: skipping check (not a git repository), for updates see https://github.com/ultralytics/yolov5
fatal: not a git repository (or any of the parent directories): .git
YOLOv5 🚀 2022-7-1 torch 1.9.1+cu102 CUDA:0 (Tesla T4, 15110MiB)

hyperparameters: lr0=0.0032, lrf=0.12, momentum=0.843, weight_decay=0.00036, warmup_epochs=2.0, warmup_momentum=0.5, warmup_bias_lr=0.05, box=0.0296, cls=0.243, cls_pw=0.631, obj=0.301, obj_pw=0.911, iou_t=0.2, anchor_t=2.91, fl_gamma=0.0, hsv_h=0.0138, hsv_s=0.664, hsv_v=0.464, degrees=0.373, translate=0.245, scale=0.898, shear=0.602, perspective=0.0, flipud=0.00856, fliplr=0.5, mosaic=1.0, mixup=0.243, copy_paste=0.0
Weights & Biases: run 'pip install wandb' to automatically track and visualize YOLOv5 🚀 runs (RECOMMENDED)
TensorBoard: Start with 'tensorboard --logdir yolov5_runs/train', view at http://localhost:6006/
Obtaining new sparse zoo credentials token
Getting signed url for c13e55cb-dd6c-4492-a079-8986af0b65e6/model.pt
Downloading model file model.pt to /root/.cache/sparsezoo/c13e55cb-dd6c-4492-a079-8986af0b65e6/pytorch/model.pt
downloading...: 100% 14.1M/14.1M [00:00<00:00, 55.0MB/s]
Overriding model.yaml nc=80 with nc=1

                 from  n    params  module                                  arguments                     
  0                -1  1      3520  yolov5.models.common.Focus              [3, 32, 3]                    
  1                -1  1     18560  yolov5.models.common.Conv               [32, 64, 3, 2]                
  2                -1  1     18816  yolov5.models.common.C3                 [64, 64, 1]                   
  3                -1  1     73984  yolov5.models.common.Conv               [64, 128, 3, 2]               
  4                -1  3    156928  yolov5.models.common.C3                 [128, 128, 3]                 
  5                -1  1    295424  yolov5.models.common.Conv               [128, 256, 3, 2]              
  6                -1  3    625152  yolov5.models.common.C3                 [256, 256, 3]                 
  7                -1  1   1180672  yolov5.models.common.Conv               [256, 512, 3, 2]              
  8                -1  1    656896  yolov5.models.common.SPP                [512, 512, [5, 9, 13]]        
  9                -1  1   1182720  yolov5.models.common.C3                 [512, 512, 1, False]          
 10                -1  1    131584  yolov5.models.common.Conv               [512, 256, 1, 1]              
 11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 12           [-1, 6]  1         0  yolov5.models.common.Concat             [1]                           
 13                -1  1    361984  yolov5.models.common.C3                 [512, 256, 1, False]          
 14                -1  1     33024  yolov5.models.common.Conv               [256, 128, 1, 1]              
 15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 16           [-1, 4]  1         0  yolov5.models.common.Concat             [1]                           
 17                -1  1     90880  yolov5.models.common.C3                 [256, 128, 1, False]          
 18                -1  1    147712  yolov5.models.common.Conv               [128, 128, 3, 2]              
 19          [-1, 14]  1         0  yolov5.models.common.Concat             [1]                           
 20                -1  1    296448  yolov5.models.common.C3                 [256, 256, 1, False]          
 21                -1  1    590336  yolov5.models.common.Conv               [256, 256, 3, 2]              
 22          [-1, 10]  1         0  yolov5.models.common.Concat             [1]                           
 23                -1  1   1182720  yolov5.models.common.C3                 [512, 512, 1, False]          
 24      [17, 20, 23]  1     16182  yolov5.models.yolo.Detect               [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
overriding activations in model to Hardswish
YOLOv5s summary: 283 layers, 7063542 parameters, 7063542 gradients, 16.5 GFLOPs

Transferred 354/361 items from /root/.cache/sparsezoo/c13e55cb-dd6c-4492-a079-8986af0b65e6/pytorch/model.pt
AutoBatch: Computing optimal batch size for --imgsz 416
AutoBatch: CUDA:0 (Tesla T4) 14.76G total, 0.06G reserved, 0.05G allocated, 14.64G free
      Params      GFLOPs  GPU_mem (GB)  forward (ms) backward (ms)                   input                  output
     7063542       6.961         0.201         15.85         13.69        (1, 3, 416, 416)                    list
     7063542       13.92         0.310         17.51         15.12        (2, 3, 416, 416)                    list
     7063542       27.85         0.581          17.1         19.17        (4, 3, 416, 416)                    list
     7063542       55.69         1.126          18.6         26.43        (8, 3, 416, 416)                    list
     7063542       111.4         2.223         33.05         50.42       (16, 3, 416, 416)                    list
AutoBatch: Using batch-size 96 for CUDA:0 13.28G/14.76G (90%)
Scaled weight_decay = 0.00054
optimizer: SGD with parameter groups 59 weight (no decay), 62 weight, 62 bias
albumentations: version 1.0.3 required by YOLOv5, but version 0.1.12 is currently installed
train: Scanning '/content/dataset/guns/train/data' images and labels...2377 found, 0 missing, 0 empty, 0 corrupt: 100% 2377/2377 [00:01<00:00, 1400.75it/s]
train: New cache created: /content/dataset/guns/train/data.cache
val: Scanning '/content/dataset/guns/val/data' images and labels...297 found, 0 missing, 0 empty, 0 corrupt: 100% 297/297 [00:00<00:00, 705.94it/s]
val: New cache created: /content/dataset/guns/val/data.cache
Plotting labels to yolov5_runs/train/exp/labels.jpg... 

AutoAnchor: 2.95 anchors/target, 1.000 Best Possible Recall (BPR). Current anchors are a good fit to dataset ✅
Image sizes 416 train, 416 val
Using 2 dataloader workers
Logging results to yolov5_runs/train/exp
Starting training for 300 epochs...
Disabling LR scheduler, managing LR using SparseML recipe
Overriding number of epochs from SparseML manager to 50

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      0/49     12.2G   0.07144   0.00531         0       243       416: 100% 25/25 [00:34<00:00,  1.40s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:06<00:00,  3.47s/it]
                 all        297        357     0.0213      0.109     0.0107    0.00213

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      1/49     14.3G   0.05913  0.005632         0       237       416: 100% 25/25 [00:31<00:00,  1.24s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:04<00:00,  2.33s/it]
                 all        297        357      0.121      0.266     0.0873     0.0225

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      2/49     12.3G   0.05131  0.005878         0       186       416: 100% 25/25 [00:31<00:00,  1.24s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:04<00:00,  2.02s/it]
                 all        297        357      0.333      0.293      0.214      0.067

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      3/49     12.9G   0.04431    0.0061         0       195       416: 100% 25/25 [00:31<00:00,  1.27s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:03<00:00,  1.63s/it]
                 all        297        357      0.546      0.394      0.424      0.158

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      4/49     12.9G   0.03815  0.006068         0       233       416: 100% 25/25 [00:31<00:00,  1.28s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.47s/it]
                 all        297        357      0.698      0.482      0.587      0.282

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      5/49     12.9G   0.03429  0.005977         0       258       416: 100% 25/25 [00:32<00:00,  1.30s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.46s/it]
                 all        297        357      0.631      0.656       0.69      0.372

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      6/49     12.9G   0.03205  0.005747         0       207       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.46s/it]
                 all        297        357        0.7      0.686      0.727      0.395

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      7/49     12.9G   0.03029  0.005601         0       254       416: 100% 25/25 [00:32<00:00,  1.30s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.42s/it]
                 all        297        357      0.723      0.669       0.74      0.405

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      8/49     12.9G   0.02922  0.005544         0       235       416: 100% 25/25 [00:35<00:00,  1.40s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.43s/it]
                 all        297        357       0.71      0.714      0.764       0.45

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      9/49       13G   0.02812  0.005142         0       196       416: 100% 25/25 [00:32<00:00,  1.29s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.49s/it]
                 all        297        357       0.72      0.706      0.769      0.451

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     10/49       13G    0.0275  0.005156         0       247       416: 100% 25/25 [00:32<00:00,  1.32s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.36s/it]
                 all        297        357      0.703      0.745      0.785      0.453

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     11/49       13G   0.02701  0.005112         0       227       416: 100% 25/25 [00:31<00:00,  1.28s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.43s/it]
                 all        297        357      0.803      0.672       0.79      0.466

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     12/49       13G   0.02631  0.004879         0       265       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357      0.803      0.709      0.809      0.485

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     13/49       13G   0.02565  0.005036         0       196       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357      0.777      0.714      0.801      0.486

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     14/49       13G   0.02532  0.004817         0       232       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357      0.758      0.745      0.813      0.506

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     15/49       13G   0.02528  0.004854         0       230       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.35s/it]
                 all        297        357      0.835      0.703      0.816      0.504

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     16/49       13G   0.02504  0.004763         0       206       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.37s/it]
                 all        297        357      0.816      0.711       0.82      0.517

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     17/49       13G   0.02469  0.004672         0       267       416: 100% 25/25 [00:34<00:00,  1.39s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.44s/it]
                 all        297        357       0.85      0.683      0.819      0.522

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     18/49       13G   0.02449  0.004663         0       231       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.43s/it]
                 all        297        357      0.814      0.725      0.827       0.53

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     19/49       13G   0.02426  0.004759         0       235       416: 100% 25/25 [00:33<00:00,  1.33s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.43s/it]
                 all        297        357       0.84      0.723      0.824      0.533

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     20/49       13G   0.02373  0.004647         0       213       416: 100% 25/25 [00:32<00:00,  1.32s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357      0.857      0.706      0.824       0.53

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     21/49     13.6G   0.02399  0.004533         0       209       416: 100% 25/25 [00:34<00:00,  1.37s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357      0.851      0.706      0.824      0.522

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     22/49     13.6G   0.02351  0.004526         0       236       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.43s/it]
                 all        297        357      0.805      0.765      0.833      0.535

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     23/49     13.6G   0.02369  0.004616         0       264       416: 100% 25/25 [00:33<00:00,  1.32s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357       0.85      0.714      0.827      0.537

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     24/49     13.6G   0.02322  0.004491         0       238       416: 100% 25/25 [00:33<00:00,  1.33s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357       0.77      0.787      0.831       0.53

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     25/49     13.6G   0.02306  0.004363         0       213       416: 100% 25/25 [00:33<00:00,  1.35s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.43s/it]
                 all        297        357      0.792       0.77      0.839       0.54

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     26/49     13.6G   0.02326   0.00452         0       238       416: 100% 25/25 [00:34<00:00,  1.40s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.37s/it]
                 all        297        357      0.859      0.735      0.845      0.554

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     27/49     13.6G   0.02265  0.004289         0       250       416: 100% 25/25 [00:34<00:00,  1.37s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357      0.864      0.731      0.837      0.539

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     28/49     13.6G   0.02292  0.004501         0       245       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.37s/it]
                 all        297        357      0.804      0.781      0.841      0.541

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     29/49     13.6G   0.02248  0.004358         0       223       416: 100% 25/25 [00:33<00:00,  1.35s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357       0.86      0.739      0.835       0.55

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     30/49     13.6G    0.0226  0.004366         0       234       416: 100% 25/25 [00:33<00:00,  1.33s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357      0.835      0.765      0.844      0.548

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     31/49     13.6G   0.02214  0.004205         0       218       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.42s/it]
                 all        297        357      0.825      0.781      0.843      0.546

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     32/49     13.6G   0.02243  0.004422         0       258       416: 100% 25/25 [00:34<00:00,  1.37s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.34s/it]
                 all        297        357      0.827      0.765      0.842       0.56

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     33/49     13.6G   0.02185  0.004325         0       183       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.42s/it]
                 all        297        357       0.82      0.793      0.847       0.55

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     34/49     13.6G   0.02233  0.004242         0       217       416: 100% 25/25 [00:35<00:00,  1.40s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357      0.813      0.779      0.833      0.548

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     35/49     13.6G   0.02183  0.004277         0       234       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357      0.824      0.787      0.846      0.557

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     36/49     13.6G   0.02203  0.004313         0       260       416: 100% 25/25 [00:33<00:00,  1.35s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.35s/it]
                 all        297        357      0.833      0.769      0.845      0.555

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     37/49     13.6G   0.02222  0.004279         0       200       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.38s/it]
                 all        297        357      0.854      0.767      0.849      0.555

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     38/49     13.6G   0.02203  0.004221         0       210       416: 100% 25/25 [00:33<00:00,  1.35s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.37s/it]
                 all        297        357      0.787      0.798      0.836      0.555

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     39/49     13.6G   0.02192  0.004201         0       256       416: 100% 25/25 [00:34<00:00,  1.36s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.35s/it]
                 all        297        357       0.82      0.779      0.846       0.56

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     40/49     13.6G   0.02192  0.004292         0       246       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.34s/it]
                 all        297        357        0.8      0.796      0.841      0.557

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     41/49     13.6G   0.02162   0.00427         0       235       416: 100% 25/25 [00:32<00:00,  1.29s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.40s/it]
                 all        297        357      0.794      0.812      0.845       0.56

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     42/49     13.6G   0.02207  0.004227         0       247       416: 100% 25/25 [00:33<00:00,  1.35s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357      0.817       0.79      0.847      0.564

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     43/49     13.6G   0.02192  0.004293         0       263       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.31s/it]
                 all        297        357      0.825      0.782       0.85      0.562

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     44/49     13.6G   0.02203  0.004257         0       242       416: 100% 25/25 [00:33<00:00,  1.33s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.45s/it]
                 all        297        357      0.808      0.789      0.846       0.56

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     45/49     13.6G   0.02163  0.004191         0       209       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.39s/it]
                 all        297        357      0.844      0.759      0.848      0.558

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     46/49     13.6G   0.02166  0.004311         0       241       416: 100% 25/25 [00:32<00:00,  1.31s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.41s/it]
                 all        297        357      0.852      0.756      0.843       0.56

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     47/49     13.6G   0.02202  0.004219         0       231       416: 100% 25/25 [00:33<00:00,  1.33s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.41s/it]
                 all        297        357      0.802      0.796      0.849       0.56

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     48/49     13.6G   0.02156  0.004262         0       230       416: 100% 25/25 [00:33<00:00,  1.34s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.38s/it]
                 all        297        357      0.833       0.77      0.846      0.558

     Epoch   gpu_mem       box       obj       cls    labels  img_size
     49/49     13.6G   0.02169   0.00436         0       239       416: 100% 25/25 [00:33<00:00,  1.33s/it]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:02<00:00,  1.42s/it]
                 all        297        357      0.805      0.798      0.846      0.558

51 epochs completed in 0.523 hours.
Optimizer stripped from yolov5_runs/train/exp/weights/last.pt, 14.4MB
Optimizer stripped from yolov5_runs/train/exp/weights/best.pt, 14.4MB

Validating yolov5_runs/train/exp/weights/best.pt...
Fusing layers... 
YOLOv5s summary: 224 layers, 7053910 parameters, 0 gradients, 16.3 GFLOPs
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 2/2 [00:03<00:00,  1.89s/it]
                 all        297        357      0.814      0.787      0.845      0.565
Results saved to yolov5_runs/train/exp

After training for 50 epochs we reach a mAP:0.5 of around 85% which is decent for this use case. The last line of the training run is shown below.

image.png

Export the Sparse Model to ONNX format for CPU inference

The DeepSparse Engine accepts ONNX formats and is engineered to significantly speed up inference on CPUs for the sparsified models from this integration. To convert the YOLOv5 model to ONNX format run:

! sparseml.yolov5.export_onnx \
  --weights yolov5_runs/train/exp/weights/best.pt \
  --imgsz 416 \
  --dynamic

export: data=../usr/local/lib/python3.7/dist-packages/sparseml/yolov5/data/coco128.yaml, weights=['yolov5_runs/train/exp/weights/best.pt'], imgsz=[416], batch_size=1, device=cpu, half=False, inplace=False, train=False, optimize=False, int8=False, dynamic=True, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, remove_grid=False, include=['torchscript', 'onnx']
export: data=../usr/local/lib/python3.7/dist-packages/sparseml/yolov5/data/coco128.yaml, weights=['yolov5_runs/train/exp/weights/best.pt'], imgsz=[416], batch_size=1, device=cpu, half=False, inplace=False, train=False, optimize=False, int8=False, dynamic=True, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, remove_grid=False, include=['torchscript', 'onnx']
fatal: not a git repository (or any of the parent directories): .git
YOLOv5 🚀 2022-7-1 torch 1.9.1+cu102 CPU

Fusing layers... 
YOLOv5s summary: 224 layers, 7053910 parameters, 0 gradients, 16.3 GFLOPs

PyTorch: starting from yolov5_runs/train/exp/weights/best.pt with output shape (1, 10647, 6) (13.8 MB)

TorchScript: starting export with torch 1.9.1+cu102...
TorchScript: export success, saved as yolov5_runs/train/exp/weights/best.torchscript (27.2 MB)

ONNX: starting export with onnx 1.10.1...
ONNX: export success, saved as yolov5_runs/train/exp/weights/best.onnx (27.0 MB)

Export complete (7.08s)
Results saved to /content/yolov5_runs/train/exp/weights
Detect:          python detect.py --weights yolov5_runs/train/exp/weights/best.onnx
PyTorch Hub:     model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5_runs/train/exp/weights/best.onnx')
Validate:        python val.py --weights yolov5_runs/train/exp/weights/best.onnx
Visualize:       https://netron.app

DeepSparse Engine model deployment

To validate the model on our test set in the DeepSparse Engine we run the following command, again using the CLI interface.

Note that the DeepSparse engine uses the CPU for inference and it might take a minute or two to run through the test set.

! sparseml.yolov5.val_onnx \
  --model_path yolov5_runs/train/exp/weights/best.onnx \
  --batch-size 1 \
  --imgsz 416 \
  --task test \
  --data pistols.yml
val_onnx: data=pistols.yml, model_path=yolov5_runs/train/exp/weights/best.onnx, batch_size=1, imgsz=416, conf_thres=0.001, iou_thres=0.6, task=test, device=, workers=8, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project=../usr/local/lib/python3.7/dist-packages/sparseml/yolov5/runs/val, name=exp, exist_ok=False, half=False, dnn=False, engine=deepsparse, num_cores=None
val_onnx: data=pistols.yml, model_path=yolov5_runs/train/exp/weights/best.onnx, batch_size=1, imgsz=416, conf_thres=0.001, iou_thres=0.6, task=test, device=, workers=8, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project=../usr/local/lib/python3.7/dist-packages/sparseml/yolov5/runs/val, name=exp, exist_ok=False, half=False, dnn=False, engine=deepsparse, num_cores=None
fatal: not a git repository (or any of the parent directories): .git
YOLOv5 🚀 2022-7-1 torch 1.9.1+cu102 CUDA:0 (Tesla T4, 15110MiB)

DeepSparse Engine, Copyright 2021-present / Neuralmagic, Inc. version: 1.0.0 (8eaddc24) (release) (optimized) (system=avx2, binary=avx2)
test: Scanning '/content/dataset/guns/test/data.cache' images and labels... 297 found, 0 missing, 0 empty, 0 corrupt: 100% 297/297 [00:00<?, ?it/s]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 297/297 [00:33<00:00,  8.93it/s]
/usr/local/lib/python3.7/dist-packages/yolov5/utils/metrics.py:74: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  names = [v for k, v in names.items() if k in unique_classes]  # list: only classes that have data
                 all        297        351      0.942      0.746      0.884      0.576
Speed: 0.0ms pre-process, 106.9ms inference, 0.0ms NMS per image at shape (1, 3, 416, 416)
Results saved to ../usr/local/lib/python3.7/dist-packages/sparseml/yolov5/runs/val/exp2

After validating the model on the test set we see a mAP:0.5 of around 88% which is excellent. Using a batch size of 1 we see an inference time of 8.93 iterations per second of 112 ms per image.

Compare sparsified ONNX model with PyTorch version

We can also run the model trained with the Neuralmagic CLI using the Ultralytics YOLO library. We will compare the inference times for the ONNX model (*.onnx) run on the DeepSparse engine with the PyTorch version (*.pt) run on the CPU.

We clone the YOLOv5 library and install dependencies.

! git clone https://github.com/ultralytics/yolov5
! pip install -q -r yolov5/requirements.txt

Then run inference on the test set using the PyTorch model.

!python yolov5/detect.py \
  --weights yolov5_runs/train/exp/weights/best.pt \
  --source dataset/guns/test/data \
  --imgsz 416 \
  --device cpu

detect: weights=['yolov5_runs/train/exp/weights/best.pt'], source=dataset/guns/test/data, data=yolov5/data/coco128.yaml, imgsz=[416, 416], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=cpu, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=yolov5/runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False
YOLOv5 🚀 v6.1-272-g8983324 Python-3.7.13 torch-1.9.1+cu102 CPU

Fusing layers... 
YOLOv5s summary: 224 layers, 7053910 parameters, 0 gradients, 16.3 GFLOPs
image 1/297 /content/dataset/guns/test/data/armas (10)_jpg.rf.817ea7572107ee2a0f671f69a5e5937e.jpg: 416x416 1 pistol, Done. (0.191s)
image 2/297 /content/dataset/guns/test/data/armas (1003)_jpg.rf.b71eaa977fba3c9dfbc5928f92d185de.jpg: 416x416 1 pistol, Done. (0.174s)
image 3/297 /content/dataset/guns/test/data/armas (1005)_jpg.rf.6d8fbd12f1d77648ebe0597cb780fe09.jpg: 416x416 1 pistol, Done. (0.164s)
image 4/297 /content/dataset/guns/test/data/armas (1011)_jpg.rf.d140a06f57b2321fc63ff67e25235985.jpg: 416x416 1 pistol, Done. (0.164s)
image 5/297 /content/dataset/guns/test/data/armas (1019)_jpg.rf.df6b78103deaad3f9e042c85f7b93bb3.jpg: 416x416 Done. (0.174s)
image 6/297 /content/dataset/guns/test/data/armas (1028)_jpg.rf.7b45d77298a5be420aee47d08aab6d50.jpg: 416x416 Done. (0.169s)
image 7/297 /content/dataset/guns/test/data/armas (1033)_jpg.rf.66de75bd4167e2c9ededcfc2bf1103ac.jpg: 416x416 Done. (0.168s)
image 8/297 /content/dataset/guns/test/data/armas (1034)_jpg.rf.9b47eaf72b6ef20248bd4a515a0840c2.jpg: 416x416 1 pistol, Done. (0.165s)
image 9/297 /content/dataset/guns/test/data/armas (1087)_jpg.rf.477f4b2aa372546c45b0b0a4154bdee3.jpg: 416x416 1 pistol, Done. (0.170s)
image 10/297 /content/dataset/guns/test/data/armas (1090)_jpg.rf.2905fc57d57941f7a3498d7ce0380e5d.jpg: 416x416 1 pistol, Done. (0.170s)
image 11/297 /content/dataset/guns/test/data/armas (1091)_jpg.rf.59d75e4b0a88457400e29ab4dbd5ae62.jpg: 416x416 1 pistol, Done. (0.169s)
image 12/297 /content/dataset/guns/test/data/armas (1101)_jpg.rf.53cb10cc7705158adb60227aa482711d.jpg: 416x416 1 pistol, Done. (0.163s)
image 13/297 /content/dataset/guns/test/data/armas (1133)_jpg.rf.3a722f368a64021a9c7a2718c2ee68e0.jpg: 416x416 1 pistol, Done. (0.167s)
image 14/297 /content/dataset/guns/test/data/armas (1141)_jpg.rf.6c4eede2a7ce145112c4d5387d0cc9ee.jpg: 416x416 2 pistols, Done. (0.165s)
image 15/297 /content/dataset/guns/test/data/armas (1143)_jpg.rf.6f02465c73443ed0ced9744af14effa6.jpg: 416x416 2 pistols, Done. (0.166s)
image 16/297 /content/dataset/guns/test/data/armas (1147)_jpg.rf.37d18b16f5c2f0058010b0aa81d34bed.jpg: 416x416 1 pistol, Done. (0.178s)
image 17/297 /content/dataset/guns/test/data/armas (1148)_jpg.rf.b989e1fd209bb6c202bcae58d41fa93f.jpg: 416x416 5 pistols, Done. (0.173s)
image 18/297 /content/dataset/guns/test/data/armas (1155)_jpg.rf.6f4d073b0ba06a48aa27486f8e5a3ea6.jpg: 416x416 1 pistol, Done. (0.172s)
image 19/297 /content/dataset/guns/test/data/armas (1163)_jpg.rf.439a6c512199df89325c7b3cacfea743.jpg: 416x416 3 pistols, Done. (0.168s)
image 20/297 /content/dataset/guns/test/data/armas (1164)_jpg.rf.c2d29ce986c9d5c6a46c6c516756a540.jpg: 416x416 1 pistol, Done. (0.171s)
image 21/297 /content/dataset/guns/test/data/armas (1172)_jpg.rf.61a4fc9c5dacb40927e692be3c110f40.jpg: 416x416 1 pistol, Done. (0.165s)
image 22/297 /content/dataset/guns/test/data/armas (1187)_jpg.rf.a7319c7ceb91025436f45068fc90a991.jpg: 416x416 1 pistol, Done. (0.168s)
image 23/297 /content/dataset/guns/test/data/armas (119)_jpg.rf.08eb6455e1ce9ae158e3890419cfdcd7.jpg: 416x416 1 pistol, Done. (0.171s)
image 24/297 /content/dataset/guns/test/data/armas (1210)_jpg.rf.60a21f22651671f96e4bb88883fa8f2a.jpg: 416x416 1 pistol, Done. (0.169s)
image 25/297 /content/dataset/guns/test/data/armas (1212)_jpg.rf.bb560d05f2d2238e9333f41fa461dcea.jpg: 416x416 1 pistol, Done. (0.169s)
image 26/297 /content/dataset/guns/test/data/armas (1217)_jpg.rf.68012be0cb73bc14b3933e876966e527.jpg: 416x416 1 pistol, Done. (0.166s)
image 27/297 /content/dataset/guns/test/data/armas (1226)_jpg.rf.e256ae21f5a3eaec1e7cb4239bf43c21.jpg: 416x416 2 pistols, Done. (0.171s)
image 28/297 /content/dataset/guns/test/data/armas (1252)_jpg.rf.1cac8f31d9a166ec3347df27fa49e2c7.jpg: 416x416 2 pistols, Done. (0.177s)
image 29/297 /content/dataset/guns/test/data/armas (1254)_jpg.rf.9d6a88c9c1959092f261c32439a43664.jpg: 416x416 4 pistols, Done. (0.174s)
image 30/297 /content/dataset/guns/test/data/armas (1255)_jpg.rf.28c436e4752839158dadef1ad670ba28.jpg: 416x416 3 pistols, Done. (0.168s)
image 31/297 /content/dataset/guns/test/data/armas (126)_jpg.rf.f5153eae6b7f323b0b68ab36efbb8623.jpg: 416x416 1 pistol, Done. (0.172s)
image 32/297 /content/dataset/guns/test/data/armas (127)_jpg.rf.28948db675a38f4b0e8aaa8ce067f4e7.jpg: 416x416 1 pistol, Done. (0.170s)
image 33/297 /content/dataset/guns/test/data/armas (1270)_jpg.rf.2aef2bd996165f7cf7f988ca42f9ecd5.jpg: 416x416 1 pistol, Done. (0.178s)
image 34/297 /content/dataset/guns/test/data/armas (1272)_jpg.rf.fdbc07a0d825065f41f5e347c1cf93ca.jpg: 416x416 2 pistols, Done. (0.167s)
image 35/297 /content/dataset/guns/test/data/armas (1288)_jpg.rf.0fba67ab1da5a72e1567a3277c76a157.jpg: 416x416 Done. (0.173s)
image 36/297 /content/dataset/guns/test/data/armas (1298)_jpg.rf.66d6562fb071df8b5eef78fb3d5c9658.jpg: 416x416 1 pistol, Done. (0.171s)
image 37/297 /content/dataset/guns/test/data/armas (1303)_jpg.rf.4d83d0337e4647d037e2017bc15121b6.jpg: 416x416 1 pistol, Done. (0.172s)
image 38/297 /content/dataset/guns/test/data/armas (1314)_jpg.rf.b26764c9c541fc483653bec7e61a82a0.jpg: 416x416 1 pistol, Done. (0.166s)
image 39/297 /content/dataset/guns/test/data/armas (1342)_jpg.rf.3562493a1147f0e9bd800660d3011b2b.jpg: 416x416 1 pistol, Done. (0.178s)
image 40/297 /content/dataset/guns/test/data/armas (1370)_jpg.rf.1959eb215e92975d2d1c7901fd33e593.jpg: 416x416 1 pistol, Done. (0.170s)
image 41/297 /content/dataset/guns/test/data/armas (1381)_jpg.rf.3e47b4ec183b6ce43764bffa9ccd0a99.jpg: 416x416 1 pistol, Done. (0.169s)
image 42/297 /content/dataset/guns/test/data/armas (1384)_jpg.rf.905dde2996342335f27d4c732d0c20c9.jpg: 416x416 Done. (0.170s)
image 43/297 /content/dataset/guns/test/data/armas (1395)_jpg.rf.d0ed21d47cabeaea84c4072735243517.jpg: 416x416 2 pistols, Done. (0.170s)
image 44/297 /content/dataset/guns/test/data/armas (1397)_jpg.rf.f34d96705437db1263db0dc46792322b.jpg: 416x416 1 pistol, Done. (0.172s)
image 45/297 /content/dataset/guns/test/data/armas (140)_jpg.rf.c86ca83808c3b3071f7138585a48d2de.jpg: 416x416 1 pistol, Done. (0.185s)
image 46/297 /content/dataset/guns/test/data/armas (1401)_jpg.rf.5e09274c1344ef3307fa74eb62e0c730.jpg: 416x416 3 pistols, Done. (0.173s)
image 47/297 /content/dataset/guns/test/data/armas (1427)_jpg.rf.dfeb7191e51b2d1aa7853eaccdc36bbc.jpg: 416x416 1 pistol, Done. (0.170s)
image 48/297 /content/dataset/guns/test/data/armas (1428)_jpg.rf.44f29d091f6e1e9243757d179f0fc189.jpg: 416x416 1 pistol, Done. (0.180s)
image 49/297 /content/dataset/guns/test/data/armas (1444)_jpg.rf.234edf425a119e734396f05bbc8dd857.jpg: 416x416 3 pistols, Done. (0.182s)
image 50/297 /content/dataset/guns/test/data/armas (145)_jpg.rf.63e2b44cf6c855f476f580ea928a5ebd.jpg: 416x416 1 pistol, Done. (0.189s)
image 51/297 /content/dataset/guns/test/data/armas (1461)_jpg.rf.751eeef3413fe44cd8d6ed5e9cd1ad90.jpg: 416x416 1 pistol, Done. (0.171s)
image 52/297 /content/dataset/guns/test/data/armas (1471)_jpg.rf.45a2e0d5d97b54445ceb9b9a95bef129.jpg: 416x416 2 pistols, Done. (0.166s)
image 53/297 /content/dataset/guns/test/data/armas (1472)_jpg.rf.2efc4977276e221bf294bb5a8b4440f4.jpg: 416x416 1 pistol, Done. (0.168s)
image 54/297 /content/dataset/guns/test/data/armas (1484)_jpg.rf.7d0de6ce1773f744a7f191719ef483bd.jpg: 416x416 1 pistol, Done. (0.164s)
image 55/297 /content/dataset/guns/test/data/armas (1485)_jpg.rf.fd70a2cafdf50fd9ed2f989f36a1018b.jpg: 416x416 1 pistol, Done. (0.166s)
image 56/297 /content/dataset/guns/test/data/armas (1490)_jpg.rf.6d2b95c9add60ebbc8f4e873e82c8a29.jpg: 416x416 1 pistol, Done. (0.175s)
image 57/297 /content/dataset/guns/test/data/armas (1494)_jpg.rf.e8602ac557d31ee56faccf2d6e246d7f.jpg: 416x416 1 pistol, Done. (0.168s)
image 58/297 /content/dataset/guns/test/data/armas (1498)_jpg.rf.e82b73c69db338c8eb904e1957329b09.jpg: 416x416 1 pistol, Done. (0.162s)
image 59/297 /content/dataset/guns/test/data/armas (1545)_jpg.rf.78ab98ca5d6f3d095cbc6c23fa5955d0.jpg: 416x416 3 pistols, Done. (0.165s)
image 60/297 /content/dataset/guns/test/data/armas (1546)_jpg.rf.4a1a310129c4a557e702d07fc10c45f2.jpg: 416x416 1 pistol, Done. (0.168s)
image 61/297 /content/dataset/guns/test/data/armas (1548)_jpg.rf.00d7dfc810b19d523c00bce6bf952821.jpg: 416x416 1 pistol, Done. (0.167s)
image 62/297 /content/dataset/guns/test/data/armas (1551)_jpg.rf.6e812509e2902641485b607ef57abb94.jpg: 416x416 Done. (0.169s)
image 63/297 /content/dataset/guns/test/data/armas (1572)_jpg.rf.d99472fc0d67bddcd5b64eccb83c2b93.jpg: 416x416 1 pistol, Done. (0.170s)
image 64/297 /content/dataset/guns/test/data/armas (1573)_jpg.rf.157cea53e1e1f6d6fa9f670d8baee8c9.jpg: 416x416 2 pistols, Done. (0.167s)
image 65/297 /content/dataset/guns/test/data/armas (1582)_jpg.rf.a0504e73a424c3e4ce5ec3a77bc5eb54.jpg: 416x416 2 pistols, Done. (0.181s)
image 66/297 /content/dataset/guns/test/data/armas (1584)_jpg.rf.a4608d0cf6c9ac402046862e136e5958.jpg: 416x416 1 pistol, Done. (0.174s)
image 67/297 /content/dataset/guns/test/data/armas (1589)_jpg.rf.129db30e0fff1fe291323707b04df3f2.jpg: 416x416 1 pistol, Done. (0.179s)
image 68/297 /content/dataset/guns/test/data/armas (159)_jpg.rf.b8df581a8b2af79e6248f2951ec12592.jpg: 416x416 1 pistol, Done. (0.163s)
image 69/297 /content/dataset/guns/test/data/armas (1600)_jpg.rf.fa83a9b2f05de8f56c42dbefc8b8a40a.jpg: 416x416 2 pistols, Done. (0.169s)
image 70/297 /content/dataset/guns/test/data/armas (1628)_jpg.rf.93730bece1f3d4f1625675b6f7d1b04c.jpg: 416x416 1 pistol, Done. (0.161s)
image 71/297 /content/dataset/guns/test/data/armas (1643)_jpg.rf.9333d0dc73da3167ada3418c6cfd25cf.jpg: 416x416 1 pistol, Done. (0.171s)
image 72/297 /content/dataset/guns/test/data/armas (1651)_jpg.rf.8a1ec0b4df4777d7461c84acc3d531b8.jpg: 416x416 1 pistol, Done. (0.168s)
image 73/297 /content/dataset/guns/test/data/armas (1656)_jpg.rf.191db8bba318052ef8884f27b52abccb.jpg: 416x416 1 pistol, Done. (0.172s)
image 74/297 /content/dataset/guns/test/data/armas (1664)_jpg.rf.7633f03b4a1f8c7d3886e1409f495bbd.jpg: 416x416 Done. (0.171s)
image 75/297 /content/dataset/guns/test/data/armas (170)_jpg.rf.03e9fd3b285b2e94c6e1a36ab81f9092.jpg: 416x416 5 pistols, Done. (0.168s)
image 76/297 /content/dataset/guns/test/data/armas (1714)_jpg.rf.dee2a4c177e2a96496b7b099a05b9047.jpg: 416x416 1 pistol, Done. (0.169s)
image 77/297 /content/dataset/guns/test/data/armas (1715)_jpg.rf.593da0323a80164aad0fdf449b9a51a2.jpg: 416x416 1 pistol, Done. (0.171s)
image 78/297 /content/dataset/guns/test/data/armas (1721)_jpg.rf.d3d6385494040976180d10a89867e926.jpg: 416x416 2 pistols, Done. (0.177s)
image 79/297 /content/dataset/guns/test/data/armas (1727)_jpg.rf.1a9821c4bfa3b38fe092156e34ba9feb.jpg: 416x416 2 pistols, Done. (0.184s)
image 80/297 /content/dataset/guns/test/data/armas (1731)_jpg.rf.fc32d36dc895fbe9eb9bf7f76024b48f.jpg: 416x416 3 pistols, Done. (0.166s)
image 81/297 /content/dataset/guns/test/data/armas (1741)_jpg.rf.0baf4f5126f9895de524c2b860869260.jpg: 416x416 1 pistol, Done. (0.167s)
image 82/297 /content/dataset/guns/test/data/armas (1749)_jpg.rf.326464a3f8b9eb30696a3a6e8592745e.jpg: 416x416 1 pistol, Done. (0.169s)
image 83/297 /content/dataset/guns/test/data/armas (1750)_jpg.rf.19af24c3090d9f75b58fdba981fd31c6.jpg: 416x416 1 pistol, Done. (0.165s)
image 84/297 /content/dataset/guns/test/data/armas (1765)_jpg.rf.d47a158b866f15c5fd7d21f5649bbfd1.jpg: 416x416 1 pistol, Done. (0.168s)
image 85/297 /content/dataset/guns/test/data/armas (1768)_jpg.rf.d0a274ce9789f3ad0452da162a534ae6.jpg: 416x416 1 pistol, Done. (0.182s)
image 86/297 /content/dataset/guns/test/data/armas (179)_jpg.rf.7b57dbdf6db729e64f16cd0d6c41f2f7.jpg: 416x416 1 pistol, Done. (0.169s)
image 87/297 /content/dataset/guns/test/data/armas (1791)_jpg.rf.1a7cec7e38f77502549fc95d579381bf.jpg: 416x416 Done. (0.160s)
image 88/297 /content/dataset/guns/test/data/armas (1800)_jpg.rf.877e38a2ea854361e48acfd8a4eeb367.jpg: 416x416 1 pistol, Done. (0.165s)
image 89/297 /content/dataset/guns/test/data/armas (1817)_jpg.rf.d9fadb2ddacc7411581e03a9035e90a3.jpg: 416x416 2 pistols, Done. (0.161s)
image 90/297 /content/dataset/guns/test/data/armas (1821)_jpg.rf.8ca0057393095ffdf789483f0734d672.jpg: 416x416 1 pistol, Done. (0.181s)
image 91/297 /content/dataset/guns/test/data/armas (1835)_jpg.rf.fd1fcbfa5c7aa3b3a5359ffd539ab7c2.jpg: 416x416 1 pistol, Done. (0.165s)
image 92/297 /content/dataset/guns/test/data/armas (1837)_jpg.rf.adb1b77cbc03d5097f9f368698f5b197.jpg: 416x416 4 pistols, Done. (0.160s)
image 93/297 /content/dataset/guns/test/data/armas (1854)_jpg.rf.1d5d194978cc6169ebc56ca9b9cbf704.jpg: 416x416 1 pistol, Done. (0.167s)
image 94/297 /content/dataset/guns/test/data/armas (1881)_jpg.rf.a75f5d5eb27f2fd4ce391b2192999cd0.jpg: 416x416 1 pistol, Done. (0.168s)
image 95/297 /content/dataset/guns/test/data/armas (1883)_jpg.rf.e39d4ca48387dc23bc08a4a97727705d.jpg: 416x416 1 pistol, Done. (0.170s)
image 96/297 /content/dataset/guns/test/data/armas (1884)_jpg.rf.9c1b14b3e30208b563ac110dcbd00851.jpg: 416x416 1 pistol, Done. (0.172s)
image 97/297 /content/dataset/guns/test/data/armas (189)_jpg.rf.185de17d854458075ff3f8948d5589ec.jpg: 416x416 Done. (0.170s)
image 98/297 /content/dataset/guns/test/data/armas (1897)_jpg.rf.94e1041ca6844b742063722d3938323b.jpg: 416x416 1 pistol, Done. (0.161s)
image 99/297 /content/dataset/guns/test/data/armas (1899)_jpg.rf.d3ddefedde9922d486ec689e7284f66c.jpg: 416x416 1 pistol, Done. (0.166s)
image 100/297 /content/dataset/guns/test/data/armas (1916)_jpg.rf.4067853fc1ea760077c57446bce3b6c7.jpg: 416x416 2 pistols, Done. (0.167s)
image 101/297 /content/dataset/guns/test/data/armas (1917)_jpg.rf.02a4bd2fc7622e76045f30383143b6cc.jpg: 416x416 1 pistol, Done. (0.163s)
image 102/297 /content/dataset/guns/test/data/armas (1924)_jpg.rf.0ae2a955fbbeaba5bdc52043ebca6afa.jpg: 416x416 1 pistol, Done. (0.180s)
image 103/297 /content/dataset/guns/test/data/armas (1928)_jpg.rf.61ad43a26a25160c16802d82be9cf546.jpg: 416x416 1 pistol, Done. (0.170s)
image 104/297 /content/dataset/guns/test/data/armas (1931)_jpg.rf.b25784df3ec76abf6db2207d45c615bb.jpg: 416x416 1 pistol, Done. (0.171s)
image 105/297 /content/dataset/guns/test/data/armas (1935)_jpg.rf.710b8a636b501112d1f10cdef1d7bd36.jpg: 416x416 1 pistol, Done. (0.166s)
image 106/297 /content/dataset/guns/test/data/armas (1937)_jpg.rf.0edf9736da95bd0542c4c7f77a90d86b.jpg: 416x416 1 pistol, Done. (0.169s)
image 107/297 /content/dataset/guns/test/data/armas (1942)_jpg.rf.0a93bbb4f47542e9f2bf27a59692b9b3.jpg: 416x416 1 pistol, Done. (0.159s)
image 108/297 /content/dataset/guns/test/data/armas (1956)_jpg.rf.6ca6b182d4bc26b43401a0bb81444cf5.jpg: 416x416 2 pistols, Done. (0.170s)
image 109/297 /content/dataset/guns/test/data/armas (1972)_jpg.rf.ec945741d69aa30f3e394dc348870aad.jpg: 416x416 2 pistols, Done. (0.165s)
image 110/297 /content/dataset/guns/test/data/armas (1979)_jpg.rf.9f9f66c2436141392048cc33180a0b96.jpg: 416x416 1 pistol, Done. (0.162s)
image 111/297 /content/dataset/guns/test/data/armas (198)_jpg.rf.946986c4f38cb01c6a4afd6bb383869d.jpg: 416x416 Done. (0.160s)
image 112/297 /content/dataset/guns/test/data/armas (1982)_jpg.rf.f590aabe31a9971bca42a4a049283d4b.jpg: 416x416 1 pistol, Done. (0.166s)
image 113/297 /content/dataset/guns/test/data/armas (1990)_jpg.rf.fd1da98269df6d01f2b23bc21fb60e5b.jpg: 416x416 2 pistols, Done. (0.168s)
image 114/297 /content/dataset/guns/test/data/armas (1995)_jpg.rf.de7a45162b668f88e49fbfb6406bcded.jpg: 416x416 1 pistol, Done. (0.174s)
image 115/297 /content/dataset/guns/test/data/armas (1996)_jpg.rf.1970d86e4bf6273c9915f479d74290c5.jpg: 416x416 1 pistol, Done. (0.167s)
image 116/297 /content/dataset/guns/test/data/armas (2017)_jpg.rf.a9dd3edb28bccab2b9593d7399326c37.jpg: 416x416 2 pistols, Done. (0.167s)
image 117/297 /content/dataset/guns/test/data/armas (202)_jpg.rf.ed090002f64a1f2243f504467729e7af.jpg: 416x416 1 pistol, Done. (0.167s)
image 118/297 /content/dataset/guns/test/data/armas (2028)_jpg.rf.20c35706126ddc964465c31916175a43.jpg: 416x416 1 pistol, Done. (0.167s)
image 119/297 /content/dataset/guns/test/data/armas (2036)_jpg.rf.1cf75eb256d443b4ac6ec565527ac2a5.jpg: 416x416 1 pistol, Done. (0.170s)
image 120/297 /content/dataset/guns/test/data/armas (2038)_jpg.rf.f5e8b3da708b00177aa898dd9c345f6c.jpg: 416x416 1 pistol, Done. (0.171s)
image 121/297 /content/dataset/guns/test/data/armas (2043)_jpg.rf.f281a509dcbe06ff8baec0292ac37252.jpg: 416x416 1 pistol, Done. (0.163s)
image 122/297 /content/dataset/guns/test/data/armas (2045)_jpg.rf.7b1e80ffc90b388242d6e1559a39c732.jpg: 416x416 2 pistols, Done. (0.167s)
image 123/297 /content/dataset/guns/test/data/armas (2055)_jpg.rf.b9ce7e2147f612b9c58fece3f69cf90a.jpg: 416x416 1 pistol, Done. (0.166s)
image 124/297 /content/dataset/guns/test/data/armas (2062)_jpg.rf.ac91f6771605e135344d6a5d9584cf66.jpg: 416x416 1 pistol, Done. (0.172s)
image 125/297 /content/dataset/guns/test/data/armas (2067)_jpg.rf.9a9d090cd0ad4088c9d1522fadead7c8.jpg: 416x416 1 pistol, Done. (0.174s)
image 126/297 /content/dataset/guns/test/data/armas (2068)_jpg.rf.f64a6fe0bf94f234cce540b179dcbb29.jpg: 416x416 1 pistol, Done. (0.169s)
image 127/297 /content/dataset/guns/test/data/armas (207)_jpg.rf.ff0255af83c82a1d09d0f777b29917bc.jpg: 416x416 1 pistol, Done. (0.166s)
image 128/297 /content/dataset/guns/test/data/armas (2074)_jpg.rf.915fdbc0c173fb421a68931b4c2df574.jpg: 416x416 1 pistol, Done. (0.169s)
image 129/297 /content/dataset/guns/test/data/armas (2106)_jpg.rf.12460f4115e32e6b01d66d9af27dafc2.jpg: 416x416 1 pistol, Done. (0.171s)
image 130/297 /content/dataset/guns/test/data/armas (211)_jpg.rf.2ed228b885bf8308031c8b5b1e0a1509.jpg: 416x416 1 pistol, Done. (0.169s)
image 131/297 /content/dataset/guns/test/data/armas (2120)_jpg.rf.c535d877f12e8e0cbeeeadc515f11cd3.jpg: 416x416 1 pistol, Done. (0.175s)
image 132/297 /content/dataset/guns/test/data/armas (2122)_jpg.rf.82ec88a014ac60e368adfcb48b9018dc.jpg: 416x416 1 pistol, Done. (0.165s)
image 133/297 /content/dataset/guns/test/data/armas (2124)_jpg.rf.2cd6d10b42f278510722a38843133b6e.jpg: 416x416 1 pistol, Done. (0.163s)
image 134/297 /content/dataset/guns/test/data/armas (2126)_jpg.rf.54b90dcc851af527826e615329e74aec.jpg: 416x416 1 pistol, Done. (0.162s)
image 135/297 /content/dataset/guns/test/data/armas (2132)_jpg.rf.c393df9feb71f64ee710e8333cdacf77.jpg: 416x416 3 pistols, Done. (0.161s)
image 136/297 /content/dataset/guns/test/data/armas (2137)_jpg.rf.cb77350b1d1769545cc3dcd6d69e0fca.jpg: 416x416 1 pistol, Done. (0.173s)
image 137/297 /content/dataset/guns/test/data/armas (2142)_jpg.rf.c2670606d4351af58d35ba3b5b2de33b.jpg: 416x416 Done. (0.170s)
image 138/297 /content/dataset/guns/test/data/armas (2153)_jpg.rf.c0fe91df154e1073d84efdd1778ebb65.jpg: 416x416 1 pistol, Done. (0.162s)
image 139/297 /content/dataset/guns/test/data/armas (2157)_jpg.rf.c7664595ffd09be5497d730d1271e88f.jpg: 416x416 1 pistol, Done. (0.168s)
image 140/297 /content/dataset/guns/test/data/armas (2161)_jpg.rf.6239c916487621743818ad647677a342.jpg: 416x416 1 pistol, Done. (0.161s)
image 141/297 /content/dataset/guns/test/data/armas (2173)_jpg.rf.496fae7144c3c7caae2decbd9e089277.jpg: 416x416 1 pistol, Done. (0.165s)
image 142/297 /content/dataset/guns/test/data/armas (2174)_jpg.rf.2b90e506ac2ad566e28c2ca6a095d167.jpg: 416x416 1 pistol, Done. (0.166s)
image 143/297 /content/dataset/guns/test/data/armas (2175)_jpg.rf.c5cf55b677b07111b458ae3c0593e177.jpg: 416x416 1 pistol, Done. (0.192s)
image 144/297 /content/dataset/guns/test/data/armas (2183)_jpg.rf.b9f448002a65cd834e0497049076e4e9.jpg: 416x416 1 pistol, Done. (0.179s)
image 145/297 /content/dataset/guns/test/data/armas (2187)_jpg.rf.e73d37bcaac53ec0cfcfc64ef50a3d0c.jpg: 416x416 1 pistol, Done. (0.171s)
image 146/297 /content/dataset/guns/test/data/armas (2204)_jpg.rf.0729ad5993974e7324f8ec37280cd86f.jpg: 416x416 1 pistol, Done. (0.172s)
image 147/297 /content/dataset/guns/test/data/armas (222)_jpg.rf.1bad945239b35e2b08f4f759823dcb5e.jpg: 416x416 Done. (0.170s)
image 148/297 /content/dataset/guns/test/data/armas (2227)_jpg.rf.d62a9155e09dba2ce3c870cc84048ada.jpg: 416x416 1 pistol, Done. (0.175s)
image 149/297 /content/dataset/guns/test/data/armas (2234)_jpg.rf.0b1fc19eafd9d2e73c1d582ff499542b.jpg: 416x416 1 pistol, Done. (0.158s)
image 150/297 /content/dataset/guns/test/data/armas (2238)_jpg.rf.7a8705928e0e6b0fed052c1fea170ded.jpg: 416x416 1 pistol, Done. (0.169s)
image 151/297 /content/dataset/guns/test/data/armas (2241)_jpg.rf.03ed9bc63462d9de51611ae139a2d06c.jpg: 416x416 1 pistol, Done. (0.165s)
image 152/297 /content/dataset/guns/test/data/armas (2247)_jpg.rf.d2300afc39985580feb979e4f80ffbfd.jpg: 416x416 1 pistol, Done. (0.164s)
image 153/297 /content/dataset/guns/test/data/armas (2252)_jpg.rf.2e38c4b9b321216a3736dfc6fbd20024.jpg: 416x416 1 pistol, Done. (0.169s)
image 154/297 /content/dataset/guns/test/data/armas (2255)_jpg.rf.51f3acfd1480a0b9e60a8c4f785508a2.jpg: 416x416 1 pistol, Done. (0.174s)
image 155/297 /content/dataset/guns/test/data/armas (2281)_jpg.rf.a72f9d623ce2d0e276233a95a1d30b25.jpg: 416x416 1 pistol, Done. (0.173s)
image 156/297 /content/dataset/guns/test/data/armas (2291)_jpg.rf.610ea7b38c641ef2e2cd1c5021b66435.jpg: 416x416 1 pistol, Done. (0.166s)
image 157/297 /content/dataset/guns/test/data/armas (2303)_jpg.rf.283ce79e96c900356284292561587fbb.jpg: 416x416 1 pistol, Done. (0.166s)
image 158/297 /content/dataset/guns/test/data/armas (2306)_jpg.rf.969e5e946cd0d3fda380643f79e4cfb2.jpg: 416x416 1 pistol, Done. (0.166s)
image 159/297 /content/dataset/guns/test/data/armas (2311)_jpg.rf.1b41d91823aa73a15a498b7972c26ea9.jpg: 416x416 1 pistol, Done. (0.167s)
image 160/297 /content/dataset/guns/test/data/armas (2320)_jpg.rf.abb476f485c4826602fd2f8ff24f4713.jpg: 416x416 1 pistol, Done. (0.181s)
image 161/297 /content/dataset/guns/test/data/armas (2336)_jpg.rf.71b0d898062d594136059e9b5c51d37b.jpg: 416x416 1 pistol, Done. (0.161s)
image 162/297 /content/dataset/guns/test/data/armas (236)_jpg.rf.dbecfb0efcc2d51a5b8bc89e24a1389e.jpg: 416x416 2 pistols, Done. (0.166s)
image 163/297 /content/dataset/guns/test/data/armas (2361)_jpg.rf.67cbe829fd329b7442a7f0209037aa8d.jpg: 416x416 1 pistol, Done. (0.164s)
image 164/297 /content/dataset/guns/test/data/armas (2379)_jpg.rf.682ac22ea5a13d3a39f608ab5dafc9b2.jpg: 416x416 1 pistol, Done. (0.170s)
image 165/297 /content/dataset/guns/test/data/armas (238)_jpg.rf.42247895817283b6ae466daedc03fb62.jpg: 416x416 2 pistols, Done. (0.173s)
image 166/297 /content/dataset/guns/test/data/armas (2414)_jpg.rf.e8d3cbff1fa408ce7ea8fdafd7971ac4.jpg: 416x416 1 pistol, Done. (0.177s)
image 167/297 /content/dataset/guns/test/data/armas (2427)_jpg.rf.bdaf776d4b0e26b38831219a7fa6e1d2.jpg: 416x416 1 pistol, Done. (0.165s)
image 168/297 /content/dataset/guns/test/data/armas (2432)_jpg.rf.dd3e88aaaa6299cb9cc5ffc51a003c0c.jpg: 416x416 1 pistol, Done. (0.168s)
image 169/297 /content/dataset/guns/test/data/armas (2437)_jpg.rf.5302fbb80ff9b998c2f7107b4c16e2e6.jpg: 416x416 1 pistol, Done. (0.169s)
image 170/297 /content/dataset/guns/test/data/armas (2457)_jpg.rf.eaef0372dedb572ed7a2ce590d7a5569.jpg: 416x416 1 pistol, Done. (0.174s)
image 171/297 /content/dataset/guns/test/data/armas (2477)_jpg.rf.127cf4b79fcd8b1ced069975e241270a.jpg: 416x416 1 pistol, Done. (0.164s)
image 172/297 /content/dataset/guns/test/data/armas (2487)_jpg.rf.5eaaff66b63544b786227cc195280e55.jpg: 416x416 1 pistol, Done. (0.172s)
image 173/297 /content/dataset/guns/test/data/armas (2490)_jpg.rf.ff618bcee306ba6b618c050ff915d905.jpg: 416x416 1 pistol, Done. (0.164s)
image 174/297 /content/dataset/guns/test/data/armas (2491)_jpg.rf.98e7a8733389cd9feca10b2cdc46232e.jpg: 416x416 1 pistol, Done. (0.166s)
image 175/297 /content/dataset/guns/test/data/armas (2500)_jpg.rf.0f5ff9d02452f0f3f6c3bcee937568c9.jpg: 416x416 1 pistol, Done. (0.167s)
image 176/297 /content/dataset/guns/test/data/armas (2505)_jpg.rf.9e57b15d2b3a934d9994ec67c47d0351.jpg: 416x416 1 pistol, Done. (0.169s)
image 177/297 /content/dataset/guns/test/data/armas (2514)_jpg.rf.79f50d11e87ac3f949f998eb50549eb9.jpg: 416x416 1 pistol, Done. (0.176s)
image 178/297 /content/dataset/guns/test/data/armas (2522)_jpg.rf.ca4288f9d52a7f4a666104cd2e189de6.jpg: 416x416 1 pistol, Done. (0.161s)
image 179/297 /content/dataset/guns/test/data/armas (2535)_jpg.rf.7ca19cd241d6e59010715624641628c0.jpg: 416x416 1 pistol, Done. (0.170s)
image 180/297 /content/dataset/guns/test/data/armas (2537)_jpg.rf.46e0f12731b85e7ee70c86198423a8ce.jpg: 416x416 1 pistol, Done. (0.167s)
image 181/297 /content/dataset/guns/test/data/armas (2545)_jpg.rf.0d9c8f5acc17289e492ce6f0be2fff26.jpg: 416x416 1 pistol, Done. (0.167s)
image 182/297 /content/dataset/guns/test/data/armas (2563)_jpg.rf.31c836955b7aa24a46bd550021237120.jpg: 416x416 1 pistol, Done. (0.173s)
image 183/297 /content/dataset/guns/test/data/armas (2568)_jpg.rf.fb3d0f2eb4ccaeac9281c46950a401ef.jpg: 416x416 1 pistol, Done. (0.216s)
image 184/297 /content/dataset/guns/test/data/armas (2577)_jpg.rf.e16700b2b0e8c7a5c467df5a39cc1e2e.jpg: 416x416 1 pistol, Done. (0.217s)
image 185/297 /content/dataset/guns/test/data/armas (2585)_jpg.rf.594c7312b4bfbe5482e45d51f32e1b43.jpg: 416x416 1 pistol, Done. (0.166s)
image 186/297 /content/dataset/guns/test/data/armas (2590)_jpg.rf.e87af042ac62642dc5c0c40421c027b8.jpg: 416x416 1 pistol, Done. (0.199s)
image 187/297 /content/dataset/guns/test/data/armas (2594)_jpg.rf.580772d0de5f23cb938ecc8b76e50d9c.jpg: 416x416 1 pistol, Done. (0.166s)
image 188/297 /content/dataset/guns/test/data/armas (2601)_jpg.rf.e8338fc979ea003d1e6443f5c144a072.jpg: 416x416 1 pistol, Done. (0.176s)
image 189/297 /content/dataset/guns/test/data/armas (2607)_jpg.rf.be031924efddd1fa89363f297780deed.jpg: 416x416 1 pistol, Done. (0.168s)
image 190/297 /content/dataset/guns/test/data/armas (2619)_jpg.rf.7623140035bb4dc7ead5b40318ce6ee1.jpg: 416x416 1 pistol, Done. (0.162s)
image 191/297 /content/dataset/guns/test/data/armas (2625)_jpg.rf.1485195cfba55ad2036f28560c4c64a0.jpg: 416x416 1 pistol, Done. (0.164s)
image 192/297 /content/dataset/guns/test/data/armas (2626)_jpg.rf.541fe318eb665d964c76e1a592c47c9b.jpg: 416x416 1 pistol, Done. (0.172s)
image 193/297 /content/dataset/guns/test/data/armas (2639)_jpg.rf.dcb3ddbd960f2c1f6325b279b2028d48.jpg: 416x416 1 pistol, Done. (0.165s)
image 194/297 /content/dataset/guns/test/data/armas (2646)_jpg.rf.c0e59adc280ac597a95bab6b20f6941d.jpg: 416x416 1 pistol, Done. (0.172s)
image 195/297 /content/dataset/guns/test/data/armas (2648)_jpg.rf.026675065767a8dc65dcb239aef505a5.jpg: 416x416 1 pistol, Done. (0.165s)
image 196/297 /content/dataset/guns/test/data/armas (2649)_jpg.rf.b8e9d6f5627baf990c696f7574c1c9ef.jpg: 416x416 1 pistol, Done. (0.167s)
image 197/297 /content/dataset/guns/test/data/armas (2661)_jpg.rf.cb86113479d951edd649785252f6c971.jpg: 416x416 1 pistol, Done. (0.167s)
image 198/297 /content/dataset/guns/test/data/armas (2677)_jpg.rf.8a011d6b18c81ce4baf513e0b3eb8d5e.jpg: 416x416 1 pistol, Done. (0.167s)
image 199/297 /content/dataset/guns/test/data/armas (2695)_jpg.rf.e753c5d4286f697bcccc02d1e6f24336.jpg: 416x416 1 pistol, Done. (0.168s)
image 200/297 /content/dataset/guns/test/data/armas (2697)_jpg.rf.a3a71a0017657cce18b816ddef189998.jpg: 416x416 1 pistol, Done. (0.172s)
image 201/297 /content/dataset/guns/test/data/armas (270)_jpg.rf.840892fcb3b0c1934fe3667960777d9e.jpg: 416x416 2 pistols, Done. (0.164s)
image 202/297 /content/dataset/guns/test/data/armas (2702)_jpg.rf.d061e3c03dcf86fe3106718575de0948.jpg: 416x416 1 pistol, Done. (0.165s)
image 203/297 /content/dataset/guns/test/data/armas (2707)_jpg.rf.4d62eb350c521a113854326244880640.jpg: 416x416 1 pistol, Done. (0.167s)
image 204/297 /content/dataset/guns/test/data/armas (2714)_jpg.rf.bfebd2904a3d810b635a4b29dbb8139b.jpg: 416x416 1 pistol, Done. (0.168s)
image 205/297 /content/dataset/guns/test/data/armas (273)_jpg.rf.f16da1e022e0c6edb9ab26e8396b74c3.jpg: 416x416 3 pistols, Done. (0.166s)
image 206/297 /content/dataset/guns/test/data/armas (2730)_jpg.rf.daacff9b441fe4808babb6c5ca4da58d.jpg: 416x416 1 pistol, Done. (0.174s)
image 207/297 /content/dataset/guns/test/data/armas (2731)_jpg.rf.548565de471c87aa43474ad1d703b9fa.jpg: 416x416 1 pistol, Done. (0.162s)
image 208/297 /content/dataset/guns/test/data/armas (2752)_jpg.rf.e1f8c18adb2f365fffba8169662508f7.jpg: 416x416 1 pistol, Done. (0.163s)
image 209/297 /content/dataset/guns/test/data/armas (2762)_jpg.rf.18748fe79c6b39140482d7e72edab29b.jpg: 416x416 1 pistol, Done. (0.165s)
image 210/297 /content/dataset/guns/test/data/armas (2768)_jpg.rf.11a7e621c8665f92571d16b4b360ad66.jpg: 416x416 1 pistol, Done. (0.169s)
image 211/297 /content/dataset/guns/test/data/armas (2775)_jpg.rf.0757b6e0033b608d293dce100c3622c1.jpg: 416x416 1 pistol, Done. (0.157s)
image 212/297 /content/dataset/guns/test/data/armas (2803)_jpg.rf.da9cc8059ad9a1a1b56232e8f2c219c6.jpg: 416x416 1 pistol, Done. (0.171s)
image 213/297 /content/dataset/guns/test/data/armas (2811)_jpg.rf.25cdcdae4bc910981beda46df42b5472.jpg: 416x416 1 pistol, Done. (0.162s)
image 214/297 /content/dataset/guns/test/data/armas (284)_jpg.rf.1337486b85d49c28aef2e1afebdba77b.jpg: 416x416 1 pistol, Done. (0.159s)
image 215/297 /content/dataset/guns/test/data/armas (2871)_jpg.rf.d6ff2cef96816b08aff8a54c3b7ca051.jpg: 416x416 1 pistol, Done. (0.176s)
image 216/297 /content/dataset/guns/test/data/armas (2879)_jpg.rf.8857745c6712ea4522a7612fd4aac69c.jpg: 416x416 1 pistol, Done. (0.167s)
image 217/297 /content/dataset/guns/test/data/armas (2881)_jpg.rf.7aeeedb70a0def30c83274a49edc5568.jpg: 416x416 2 pistols, Done. (0.166s)
image 218/297 /content/dataset/guns/test/data/armas (2883)_jpg.rf.ccbdec269f7f3f0e33882c18ab887379.jpg: 416x416 2 pistols, Done. (0.168s)
image 219/297 /content/dataset/guns/test/data/armas (2888)_jpg.rf.04fac4682bf5260170088d179bd91a77.jpg: 416x416 1 pistol, Done. (0.163s)
image 220/297 /content/dataset/guns/test/data/armas (2890)_jpg.rf.b97e745b64323191bb311617eb93c255.jpg: 416x416 2 pistols, Done. (0.157s)
image 221/297 /content/dataset/guns/test/data/armas (2896)_jpg.rf.8507d2339933f643c7f8f1de16236b61.jpg: 416x416 1 pistol, Done. (0.173s)
image 222/297 /content/dataset/guns/test/data/armas (2901)_jpg.rf.12e8c129ed03388ba0085687f7d87911.jpg: 416x416 1 pistol, Done. (0.164s)
image 223/297 /content/dataset/guns/test/data/armas (2902)_jpg.rf.07a4bbda744148b8cdac48dafb7c4451.jpg: 416x416 1 pistol, Done. (0.174s)
image 224/297 /content/dataset/guns/test/data/armas (2918)_jpg.rf.ebca5119a6fb1167b1d1410d3bbac63c.jpg: 416x416 1 pistol, Done. (0.166s)
image 225/297 /content/dataset/guns/test/data/armas (2927)_jpg.rf.b713efc3464d2f7e08095ce5675225a6.jpg: 416x416 1 pistol, Done. (0.166s)
image 226/297 /content/dataset/guns/test/data/armas (2934)_jpg.rf.07bc28e41d50711000c41b6ca84a9516.jpg: 416x416 3 pistols, Done. (0.167s)
image 227/297 /content/dataset/guns/test/data/armas (294)_jpg.rf.314ac2c8129d8b90fa88cdd790ff6870.jpg: 416x416 1 pistol, Done. (0.170s)
image 228/297 /content/dataset/guns/test/data/armas (2945)_jpg.rf.fce5574a06bde99626c13579c653be18.jpg: 416x416 1 pistol, Done. (0.159s)
image 229/297 /content/dataset/guns/test/data/armas (2968)_jpg.rf.031d9219e3782dfb71ca1610ff63c40e.jpg: 416x416 1 pistol, Done. (0.167s)
image 230/297 /content/dataset/guns/test/data/armas (2976)_jpg.rf.c80298e56a0fb985e78ee6815d95f788.jpg: 416x416 1 pistol, Done. (0.167s)
image 231/297 /content/dataset/guns/test/data/armas (30)_jpg.rf.878ab965bebeb31cea56ae120e30d0ba.jpg: 416x416 1 pistol, Done. (0.169s)
image 232/297 /content/dataset/guns/test/data/armas (301)_jpg.rf.2a79b338c46b5f7f223d4967cfa92c56.jpg: 416x416 1 pistol, Done. (0.162s)
image 233/297 /content/dataset/guns/test/data/armas (315)_jpg.rf.7d7856bf87b0e9897ff8cb5b57d478aa.jpg: 416x416 1 pistol, Done. (0.167s)
image 234/297 /content/dataset/guns/test/data/armas (32)_jpg.rf.b56e4f0620c013d6001002a9105dc867.jpg: 416x416 1 pistol, Done. (0.164s)
image 235/297 /content/dataset/guns/test/data/armas (328)_jpg.rf.08f422689dfd5c398ffe63964762de91.jpg: 416x416 2 pistols, Done. (0.179s)
image 236/297 /content/dataset/guns/test/data/armas (337)_jpg.rf.b6af526c142626fe39fa3b271a2a8555.jpg: 416x416 1 pistol, Done. (0.164s)
image 237/297 /content/dataset/guns/test/data/armas (350)_jpg.rf.38bd0993b57576281c65382bdc0aedcf.jpg: 416x416 Done. (0.165s)
image 238/297 /content/dataset/guns/test/data/armas (354)_jpg.rf.6ca959e0ab686f215287aeb7dfb6338c.jpg: 416x416 1 pistol, Done. (0.164s)
image 239/297 /content/dataset/guns/test/data/armas (360)_jpg.rf.4f44c9a3463fa48ef496f793740ce6aa.jpg: 416x416 2 pistols, Done. (0.170s)
image 240/297 /content/dataset/guns/test/data/armas (361)_jpg.rf.cb4058db757bfbad492c24acbb006081.jpg: 416x416 1 pistol, Done. (0.167s)
image 241/297 /content/dataset/guns/test/data/armas (366)_jpg.rf.d30c2924a0a8c89d788e0dda4eec1528.jpg: 416x416 1 pistol, Done. (0.175s)
image 242/297 /content/dataset/guns/test/data/armas (372)_jpg.rf.3025729c1a144cb2d890a297e871095f.jpg: 416x416 1 pistol, Done. (0.164s)
image 243/297 /content/dataset/guns/test/data/armas (378)_jpg.rf.dffeb6bdfecff30600e09adf00dc3daa.jpg: 416x416 1 pistol, Done. (0.169s)
image 244/297 /content/dataset/guns/test/data/armas (381)_jpg.rf.427d6a28793153a7811717076189d5a0.jpg: 416x416 1 pistol, Done. (0.173s)
image 245/297 /content/dataset/guns/test/data/armas (385)_jpg.rf.f4e0af65afda1b78b09085ca945eb01b.jpg: 416x416 2 pistols, Done. (0.163s)
image 246/297 /content/dataset/guns/test/data/armas (393)_jpg.rf.6642f1836e305915bec3448b91f3c410.jpg: 416x416 1 pistol, Done. (0.164s)
image 247/297 /content/dataset/guns/test/data/armas (400)_jpg.rf.4b4db1460ab8697ca02449311e340f43.jpg: 416x416 1 pistol, Done. (0.179s)
image 248/297 /content/dataset/guns/test/data/armas (415)_jpg.rf.cd0d3c0f73b8599f1ee502725f4a17f4.jpg: 416x416 2 pistols, Done. (0.171s)
image 249/297 /content/dataset/guns/test/data/armas (417)_jpg.rf.d2590ce06705c41ee12c7dd056774aa4.jpg: 416x416 1 pistol, Done. (0.166s)
image 250/297 /content/dataset/guns/test/data/armas (439)_jpg.rf.ca6c2101b556af139b65ac078b6d1b92.jpg: 416x416 1 pistol, Done. (0.165s)
image 251/297 /content/dataset/guns/test/data/armas (442)_jpg.rf.0e19adaf7a52170a5b6202f174d2339e.jpg: 416x416 1 pistol, Done. (0.163s)
image 252/297 /content/dataset/guns/test/data/armas (451)_jpg.rf.0cde54a14dbc5a8f7211c97b1167b338.jpg: 416x416 1 pistol, Done. (0.172s)
image 253/297 /content/dataset/guns/test/data/armas (452)_jpg.rf.b4a83ac16f2570656defdd71094c1c2a.jpg: 416x416 1 pistol, Done. (0.166s)
image 254/297 /content/dataset/guns/test/data/armas (455)_jpg.rf.8b0d2882838c47018e97c0e7566bf635.jpg: 416x416 1 pistol, Done. (0.164s)
image 255/297 /content/dataset/guns/test/data/armas (458)_jpg.rf.348d54778af33808a6784f07d693c53d.jpg: 416x416 1 pistol, Done. (0.173s)
image 256/297 /content/dataset/guns/test/data/armas (465)_jpg.rf.c8cc7c16586304122ae8a92f6eac9ac6.jpg: 416x416 1 pistol, Done. (0.169s)
image 257/297 /content/dataset/guns/test/data/armas (471)_jpg.rf.2568fcce3adb0b2d2958855c3b21ad2c.jpg: 416x416 Done. (0.163s)
image 258/297 /content/dataset/guns/test/data/armas (510)_jpg.rf.ea172b5de77e1466a0a783936e9930b5.jpg: 416x416 2 pistols, Done. (0.172s)
image 259/297 /content/dataset/guns/test/data/armas (512)_jpg.rf.24412f4429658394911d33b6c69b7631.jpg: 416x416 Done. (0.173s)
image 260/297 /content/dataset/guns/test/data/armas (518)_jpg.rf.3b9a260b16d13e235eb0211d08b303fa.jpg: 416x416 2 pistols, Done. (0.172s)
image 261/297 /content/dataset/guns/test/data/armas (55)_jpg.rf.13e42bc80d7e19d50e28ff3d6584d874.jpg: 416x416 2 pistols, Done. (0.171s)
image 262/297 /content/dataset/guns/test/data/armas (557)_jpg.rf.b15a26a98ff2cdb89242e3a0005a8bb6.jpg: 416x416 1 pistol, Done. (0.170s)
image 263/297 /content/dataset/guns/test/data/armas (577)_jpg.rf.30cc43fb2df897b9d1b7f57b154fd5d2.jpg: 416x416 1 pistol, Done. (0.163s)
image 264/297 /content/dataset/guns/test/data/armas (605)_jpg.rf.eaa8a92e7512aa7e06312ef629c1bf0a.jpg: 416x416 2 pistols, Done. (0.179s)
image 265/297 /content/dataset/guns/test/data/armas (610)_jpg.rf.57798628867be64aed4bd3022bcbf5ab.jpg: 416x416 1 pistol, Done. (0.163s)
image 266/297 /content/dataset/guns/test/data/armas (612)_jpg.rf.e1484b992b0ae6dfc65574dedef68f0b.jpg: 416x416 1 pistol, Done. (0.160s)
image 267/297 /content/dataset/guns/test/data/armas (617)_jpg.rf.62fe39767661aa2d80610836db5068ec.jpg: 416x416 2 pistols, Done. (0.168s)
image 268/297 /content/dataset/guns/test/data/armas (63)_jpg.rf.eeb46f01ad8bf93f7ad785f9739814f0.jpg: 416x416 1 pistol, Done. (0.164s)
image 269/297 /content/dataset/guns/test/data/armas (652)_jpg.rf.76b8af6bfbe01d88a2dd2394d8fabdf3.jpg: 416x416 2 pistols, Done. (0.167s)
image 270/297 /content/dataset/guns/test/data/armas (684)_jpg.rf.65021d2a65916f50f2c56cdda85337af.jpg: 416x416 1 pistol, Done. (0.171s)
image 271/297 /content/dataset/guns/test/data/armas (689)_jpg.rf.f5352f4725235882bf544ca4641305d4.jpg: 416x416 2 pistols, Done. (0.161s)
image 272/297 /content/dataset/guns/test/data/armas (709)_jpg.rf.60c58fb8ed08923be94e56b58dd9459d.jpg: 416x416 1 pistol, Done. (0.164s)
image 273/297 /content/dataset/guns/test/data/armas (715)_jpg.rf.d5a9676a287f862f6a7cf232fb6d636b.jpg: 416x416 1 pistol, Done. (0.162s)
image 274/297 /content/dataset/guns/test/data/armas (728)_jpg.rf.5c260e2b573e5f3181ec6c1f2da5f055.jpg: 416x416 1 pistol, Done. (0.168s)
image 275/297 /content/dataset/guns/test/data/armas (730)_jpg.rf.48fab75bda99526e9c41877de517d8cd.jpg: 416x416 1 pistol, Done. (0.170s)
image 276/297 /content/dataset/guns/test/data/armas (734)_jpg.rf.836787711fb4ecdb540710b9d157066c.jpg: 416x416 1 pistol, Done. (0.176s)
image 277/297 /content/dataset/guns/test/data/armas (737)_jpg.rf.a209f597649f4b5c0d5defcd41e40182.jpg: 416x416 1 pistol, Done. (0.169s)
image 278/297 /content/dataset/guns/test/data/armas (74)_jpg.rf.912542e5d7d9585e148841eac28fb33e.jpg: 416x416 Done. (0.169s)
image 279/297 /content/dataset/guns/test/data/armas (747)_jpg.rf.17b376b62be169c1dec0918dc5df41ba.jpg: 416x416 Done. (0.165s)
image 280/297 /content/dataset/guns/test/data/armas (767)_jpg.rf.c8a3f99925c3f8ce4cd359d85f4f9cb2.jpg: 416x416 1 pistol, Done. (0.157s)
image 281/297 /content/dataset/guns/test/data/armas (77)_jpg.rf.fe1dfd57fd89141c69aacb7e733efdb8.jpg: 416x416 1 pistol, Done. (0.164s)
image 282/297 /content/dataset/guns/test/data/armas (80)_jpg.rf.17652c26c46b20342962e10797974715.jpg: 416x416 2 pistols, Done. (0.168s)
image 283/297 /content/dataset/guns/test/data/armas (804)_jpg.rf.4ac748b8d287391852e281b3734e1898.jpg: 416x416 1 pistol, Done. (0.166s)
image 284/297 /content/dataset/guns/test/data/armas (818)_jpg.rf.dc93c4113cac3378ffbb798ba9821d35.jpg: 416x416 1 pistol, Done. (0.170s)
image 285/297 /content/dataset/guns/test/data/armas (831)_jpg.rf.37109c778f51215cf34f6461faa3313b.jpg: 416x416 1 pistol, Done. (0.165s)
image 286/297 /content/dataset/guns/test/data/armas (835)_jpg.rf.28cb149d9e1976a9cfbe790ce12cec2f.jpg: 416x416 1 pistol, Done. (0.165s)
image 287/297 /content/dataset/guns/test/data/armas (839)_jpg.rf.e82c9e65653e9c14220d418819aeaf9f.jpg: 416x416 1 pistol, Done. (0.168s)
image 288/297 /content/dataset/guns/test/data/armas (859)_jpg.rf.fc68000214ebd3c8a6ee89ea4278e821.jpg: 416x416 1 pistol, Done. (0.172s)
image 289/297 /content/dataset/guns/test/data/armas (864)_jpg.rf.88fa4cb492e410ee95ff26a3d4f11139.jpg: 416x416 1 pistol, Done. (0.166s)
image 290/297 /content/dataset/guns/test/data/armas (873)_jpg.rf.cba1579c0eadbffaff4c1503e3aa1a70.jpg: 416x416 1 pistol, Done. (0.164s)
image 291/297 /content/dataset/guns/test/data/armas (885)_jpg.rf.bdee500fe6c0bea569832a82ea497eb9.jpg: 416x416 1 pistol, Done. (0.165s)
image 292/297 /content/dataset/guns/test/data/armas (909)_jpg.rf.0684d50ee40c925405828cdc0b59f8fc.jpg: 416x416 Done. (0.167s)
image 293/297 /content/dataset/guns/test/data/armas (917)_jpg.rf.f75893bd53db75fd04e29a7b02041ba7.jpg: 416x416 1 pistol, Done. (0.169s)
image 294/297 /content/dataset/guns/test/data/armas (922)_jpg.rf.4cb8db9f5c30d1a35b6e2aca547b5dff.jpg: 416x416 3 pistols, Done. (0.165s)
image 295/297 /content/dataset/guns/test/data/armas (941)_jpg.rf.5aa6318c8a4a58177f404b4c37f68c25.jpg: 416x416 1 pistol, Done. (0.165s)
image 296/297 /content/dataset/guns/test/data/armas (955)_jpg.rf.ba79f15691a4b7ae542ed20c18d3f1ec.jpg: 416x416 1 pistol, Done. (0.171s)
image 297/297 /content/dataset/guns/test/data/armas (978)_jpg.rf.0f1765e081e22742b7f91e8287f2b1be.jpg: 416x416 Done. (0.167s)
Speed: 0.6ms pre-process, 169.0ms inference, 0.5ms NMS per image at shape (1, 3, 416, 416)
Results saved to yolov5/runs/detect/exp2

image.png

Using a batch size of 1 we see an average inference time of around 169 ms per image. This is 51% slower compared to the 112 ms using the DeepSparse engine.

Further performance improvements can be gained by using a modern CPU that support Vector Neural Network Instructions (VNNI). This will allow one to run a quantized model where model weights are transformed from 32-bit floating point accuracy to 8-bit integer. This allows further model size reduction and faster inference times. Unfortunately Colab CPUs does not currently support VNNI.

Note: Inference speedup scales with model size. An experiment using YOLOv5-large pruned model showed a speedup of around 375% which is really impressive!

Run the model on a YouTube video using Ultralytics library

Finally, to test our model on external data using the GPU, we can run inference with the YOLOv5 detect.py script using the *.pt weights.

For this example we will use a YouTube video with a scene from a John Wick movie.

!python yolov5/detect.py \
  --weights /content/yolov5_runs/train/exp/weights/best.pt \
  --source "https://www.youtube.com/watch?v=nB0A4pFIOA0" \
  --conf-thres=0.6 \
  --imgsz 416

Below I link the YouTube video followed by a few screenshots from the annotated video.

image.png

image.png

image.png