ultralytics/yolov5: v6.2 - YOLOv5 Classification Models, Apple M1, Reproducibility, ClearML and Deci.ai integrations
Abstract
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 Train YOLOv5 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) New Classification Checkpoints 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
(pixels) accuracy
top1 accuracy
top5 Train time
90 epochs
4x A100 (hours) Speed
ONNX-CPU
(ms) Speed
TensorRT-V100
(ms) params
(M) FLOPs
@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.
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.
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.
Reproduce by python export.py --weights yolov5s-cls.pt --include engine onnx --imgsz 224 Changelog 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 🛠️ New Features and Bug Fixes (401)
* Pre-commit table fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6744 * Update tutorial.ipynb (2 CPUs, 12.7 GB RAM, 42.2/166.8 GB disk) by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6767 * Update min warmup iterations from 1k to 100 by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6768 * Default `OMP_NUM_THREADS=8` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6770 * Update tutorial.ipynb by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6771 * Update hyp.VOC.yaml by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6772 * Fix export for 1-channel images by @lcombaldieu in https://github.com/ultralytics/yolov5/pull/6780 * Update EMA decay `tau` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6769 * YOLOv5s6 params FLOPs fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6782 * Update PULL_REQUEST_TEMPLATE.md by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6783 * Update autoanchor.py by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6794 * Update sweep.yaml by @lcombaldieu in https://github.com/ultralytics/yolov5/pull/6825 * AutoAnchor improved initialization robustness by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6854 * Add `*.ts` to `VID_FORMATS` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6859 * Update `--cache disk` deprecate `*_npy/` dirs by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6876 * Update yolov5s.yaml by @vnekat in https://github.com/ultralytics/yolov5/pull/6865 * Default FP16 TensorRT export by @DavidBaldsiefen in https://github.com/ultralytics/yolov5/pull/6798 * Bump actions/setup-python from 2 to 3 by @dependabot in https://github.com/ultralytics/yolov5/pull/6880 * Bump actions/checkout from 2 to 3 by @dependabot in https://github.com/ultralytics/yolov5/pull/6881 * Fix TRT `max_workspace_size` deprecation notice by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6856 * Update bytes to GB with bit shift by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6886 * Move `git_describe()` to general.py by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6918 * PyTorch 1.11.0 compatibility updates by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6932 * Optimize PyTorch 1.11.0 compatibility update by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6933 * Allow 3-point segments by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6938 * Fix PyTorch Hub export inference shapes by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6949 * DetectMultiBackend() `--half` handling by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6945 * Update Dockerfile `torch==1.11.0+cu113` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6954 * New val.py `cuda` variable by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6957 * DetectMultiBackend() return `device` update by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6958 * Tensor initialization on device improvements by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6959 * EdgeTPU optimizations by @paradigmn in https://github.com/ultralytics/yolov5/pull/6808 * Model `ema` key backward compatibility fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6972 * YOLOv5 Export Benchmarks for GPU by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6963 * Update TQDM bar format by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/6988 * Conditional `Timeout()` by OS (disable on Windows) by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7013 * fix: add default PIL font as fallback by @maxstrobel in https://github.com/ultralytics/yolov5/pull/7010 * Consistent saved_model output format by @MrinalJain17 in https://github.com/ultralytics/yolov5/pull/7032 * `ComputeLoss()` indexing/speed improvements by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7048 * Update Dockerfile to `git clone` instead of `COPY` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7053 * Create SECURITY.md by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7054 * Fix incomplete URL substring sanitation by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7056 * Use PIL to eliminate chroma subsampling in crops by @LaserBorg in https://github.com/ultralytics/yolov5/pull/7008 * Fix `check_anchor_order()` in pixel-space not grid-space by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7060 * Update detect.py non-inplace with `y.tensor_split()` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7062 * Update common.py lists for tuples by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7063 * Update W&B message to `LOGGER.info()` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7064 * Update __init__.py by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7065 * Add non-zero `da` `check_anchor_order()` condition by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7066 * Fix2 `check_anchor_order()` in pixel-space not grid-space by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7067 * Revert "Update detect.py non-inplace with `y.tensor_split()`" by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7074 * Update loss.py with `if self.gr < 1:` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7087 * Update loss for FP16 `tobj` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7088 * Display model name in model summary by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7101 * `torch.split()` 1.7.0 compatibility fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7102 * Update benchmarks significant digits by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7103 * Model summary `pathlib` fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7104 * Remove named arguments where possible by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7105 * Multi-threaded VisDrone and VOC downloads by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7108 * `np.fromfile()` Chinese image paths fix by @yeshanliu in https://github.com/ultralytics/yolov5/pull/6979 * Add PyTorch Hub `results.save(labels=False)` option by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7129 * Fix `cv2.imwrite` on non-ASCII paths by @CCRcmcpe in https://github.com/ultralytics/yolov5/pull/7139 * Fix `detect.py --view-img` for non-ASCII paths by @Zengyf-CVer in https://github.com/ultralytics/yolov5/pull/7093 * Add Architecture Summary to README Tutorials by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7146 * Adjust NMS time limit warning to batch size by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7156 * Sidestep `os.path.relpath()` Windows bug by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7158 * NMS unused variable fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7161 * `yolo.py --profile` updates by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7170 * Revert `C3()` change by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7172 * Bump actions/cache from 2.1.7 to 3 by @dependabot in https://github.com/ultralytics/yolov5/pull/7175 * yolo.py profiling updates by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7178 * Update tutorial.ipynb by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7212 * `ENV OMP_NUM_THREADS=8` by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7215 * Add train.py `--name cfg` option by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7202 * precommit: yapf by @Borda in https://github.com/ultralytics/yolov5/pull/5494 * CLI `fire` prep updates by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7229 * Update .pre-commit-config.yaml by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7230 * SavedModel TF Serve Fix by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7228 * Create CODE_OF_CONDUCT.md by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7233 * Fix `www.youtube.com` hostname by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7242 * Update minimum Python>=3.7.0 by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7247 * Update setup.cfg to `description_file` field by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7248 * Update tutorial.ipynb by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7254 * Update tutorial.ipynb by @glenn-jocher in https://github.com/ultralytics/yolov5/pull/7255 * Fix Flask REST API by @Zengyf-CVer in https://github.com/ultralytics/yolov5/pull/7210 * Exp
- Publication:
-
Zenodo
- Pub Date:
- DOI:
- Bibcode:
- 2022zndo...7002879J