ultralytics/yolov5: v6.2 - YOLOv5 Classification Models, Apple M1, Reproducibility, ClearML and Deci.ai integrations
Creators
- Glenn Jocher1
- Ayush Chaurasia
- Alex Stoken2
- Jirka Borovec3
- NanoCode012
- Yonghye Kwon4
- TaoXie5
- Kalen Michael
- Jiacong Fang
- imyhxy
- Lorna6
- Colin Wong7
- 曾逸夫(Zeng Yifu)
- Abhiram V8
- Diego Montes
- Zhiqiang Wang
- Cristi Fati
- Jebastin Nadar
- Laughing
- UnglvKitDe
- tkianai9
- yxNONG
- Piotr Skalski10
- Adam Hogan11
- Max Strobel12
- Mrinal Jain13
- Lorenzo Mammana14
- xylieong
- 1. @ultralytics
- 2. Jacobs JETS @ NASA Johnson Space Center
- 3. Grid.ai | PytorchLightning
- 4. MarkAny
- 5. 罗布乐思
- 6. Dakewe Biotech Co., Ltd.
- 7. @frc5431 @Rebirth-of-the-Night
- 8. @zealabs
- 9. 别怕失败,大不了从头来过
- 10. @unleashlive, @ultralytics
- 11. North Carolina State University
- 12. Technische Universität München
- 13. Ephesoft
- 14. Orobix
Description
This release incorporates 401 PRs from 41 contributors since our last release in February 2022. It adds Classification training, validation, prediction and export (to all 11 formats), and also provides ImageNet-pretrained YOLOv5m-cls, ResNet (18, 34, 50, 101) and EfficientNet (b0-b3) models.
My main goal with this release is to introduce super simple YOLOv5 classification workflows just like our existing object detection models. The new v6.2 YOLOv5-cls models below are just a start, we will continue to improve these going forward together with our existing detection models. We'd love your contributions on this effort!
Our next release, v6.3 is scheduled for September and will bring official instance segmentation support to YOLOv5, with a major v7.0 release later this year updating architectures across all 3 tasks - classification, detection and segmentation.
New Classification Model Usage Examples TrainYOLOv5 classification training supports auto-download of MNIST, Fashion-MNIST, CIFAR10, CIFAR100, Imagenette, Imagewoof, and ImageNet datasets with the --data
argument. To start training on MNIST for example use --data mnist
.
# Single-GPU
python classify/train.py --model yolov5s-cls.pt --data cifar100 --epochs 5 --img 224 --batch 128
# Multi-GPU DDP
python -m torch.distributed.run --nproc_per_node 4 --master_port 1 classify/train.py --model yolov5s-cls.pt --data imagenet --epochs 5 --img 224 --device 0,1,2,3
Val
Validate accuracy on a pretrained model. To validate YOLOv5m-cls accuracy on ImageNet.
bash data/scripts/get_imagenet.sh --val # download ImageNet val split (6.3G, 50000 images)
python classify/val.py --weights yolov5m-cls.pt --data ../datasets/imagenet --img 224 # validate
Predict
Run a classification prediction on an image.
python classify/predict.py --weights yolov5s-cls.pt --data data/images/bus.jpg
model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5s-cls.pt') # load from PyTorch Hub
Export
Export a group of trained YOLOv5-cls, ResNet and EfficientNet models to ONNX and TensorRT.
python export.py --weights yolov5s-cls.pt resnet50.pt efficientnet_b0.pt --include onnx engine --img 224
Important Updates
- Classification Models: TensorFlow, Keras, TFLite, TF.js model export now fully integrated using
python export.py --include saved_model pb tflite tfjs
(https://github.com/ultralytics/yolov5/pull/8956 by @glenn-jocher) - ClearML logging ⭐ NEW: Integration with the open-source experiment tracker ClearML. Installing with
pip install clearml
will enable the integration and allow users to track every training run in ClearML. This in turn allows users to track and compare runs and even schedule runs remotely. (https://github.com/ultralytics/yolov5/pull/8620 by @thepycoder) - Deci.ai optimization ⭐ NEW: Automatically compile and quantize YOLOv5 for better inference performance in one click at Deci (https://github.com/ultralytics/yolov5/pull/8956 by @glenn-jocher).
- GPU Export Benchmarks: Benchmark (mAP and speed) all YOLOv5 export formats with
python utils/benchmarks.py --weights yolov5s.pt --device 0
for GPU benchmarks or--device cpu
for CPU benchmarks (https://github.com/ultralytics/yolov5/pull/6963 by @glenn-jocher). - Training Reproducibility: Single-GPU YOLOv5 training with
torch>=1.12.0
is now fully reproducible, and a new--seed
argument can be used (default seed=0) (https://github.com/ultralytics/yolov5/pull/8213 by @AyushExel). - Apple Metal Performance Shader (MPS) Support: MPS support for Apple M1/M2 devices with
--device mps
(full functionality is pending torch updates in https://github.com/pytorch/pytorch/issues/77764) (https://github.com/ultralytics/yolov5/pull/7878 by @glenn-jocher)
We trained YOLOv5-cls classification models on ImageNet for 90 epochs using a 4xA100 instance, and we trained ResNet and EfficientNet models alongside with the same default training settings to compare. We exported all models to ONNX FP32 for CPU speed tests and to TensorRT FP16 for GPU speed tests. We ran all speed tests on Google Colab Pro for easy reproducibility.
Model | size<br><sup>(pixels) | accuracy<br><sup>top1 | accuracy<br><sup>top5 | Train time<br><sup>90 epochs<br>4x A100 (hours) | Speed<br><sup>ONNX-CPU<br>(ms) | Speed<br><sup>TensorRT-V100<br>(ms) | params<br><sup>(M) | FLOPs<br><sup>@224 (B) |
---|---|---|---|---|---|---|---|---|
YOLOv5n-cls | 224 | 64.6 | 85.4 | 7:59 | 3.3 | 0.5 | 2.5 | 0.5 |
YOLOv5s-cls | 224 | 71.5 | 90.2 | 8:09 | 6.6 | 0.6 | 5.4 | 1.4 |
YOLOv5m-cls | 224 | 75.9 | 92.9 | 10:06 | 15.5 | 0.9 | 12.9 | 3.9 |
YOLOv5l-cls | 224 | 78.0 | 94.0 | 11:56 | 26.9 | 1.4 | 26.5 | 8.5 |
YOLOv5x-cls | 224 | 79.0 | 94.4 | 15:04 | 54.3 | 1.8 | 48.1 | 15.9 |
ResNet18 | 224 | 70.3 | 89.5 | 6:47 | 11.2 | 0.5 | 11.7 | 3.7 |
ResNet34 | 224 | 73.9 | 91.8 | 8:33 | 20.6 | 0.9 | 21.8 | 7.4 |
ResNet50 | 224 | 76.8 | 93.4 | 11:10 | 23.4 | 1.0 | 25.6 | 8.5 |
ResNet101 | 224 | 78.5 | 94.3 | 17:10 | 42.1 | 1.9 | 44.5 | 15.9 |
EfficientNet_b0 | 224 | 75.1 | 92.4 | 13:03 | 12.5 | 1.3 | 5.3 | 1.0 |
EfficientNet_b1 | 224 | 76.4 | 93.2 | 17:04 | 14.9 | 1.6 | 7.8 | 1.5 |
EfficientNet_b2 | 224 | 76.6 | 93.4 | 17:10 | 15.9 | 1.6 | 9.1 | 1.7 |
EfficientNet_b3 | 224 | 77.7 | 94.0 | 19:19 | 18.9 | 1.9 | 12.2 | 2.4 |
- All checkpoints are trained to 90 epochs with SGD optimizer with lr0=0.001 at image size 224 and all default settings. Runs logged to https://wandb.ai/glenn-jocher/YOLOv5-Classifier-v6-2.
- Accuracy values are for single-model single-scale on ImageNet-1k dataset.<br>Reproduce by
python classify/val.py --data ../datasets/imagenet --img 224
- Speed averaged over 100 inference images using a Colab Pro V100 High-RAM instance.<br>Reproduce by
python classify/val.py --data ../datasets/imagenet --img 224 --batch 1
- Export to ONNX at FP32 and TensorRT at FP16 done with
export.py
. <br>Reproduce bypython export.py --weights yolov5s-cls.pt --include engine onnx --imgsz 224
- Changes between previous release and this release: https://github.com/ultralytics/yolov5/compare/v6.1...v6.2
- Changes since this release: https://github.com/ultralytics/yolov5/compare/v6.2...HEAD
Files
ultralytics/yolov5-v6.2.zip
Files
(944.0 kB)
Name | Size | Download all |
---|---|---|
md5:50ea149f021ea17f190f7ea3229b825b
|
944.0 kB | Preview Download |
Additional details
Related works
- Is supplement to
- https://github.com/ultralytics/yolov5/tree/v6.2 (URL)