This release incorporates many new features and bug fixes (271 PRs from 48 contributors) since our last release in October 2021. It adds TensorRT, Edge TPU and OpenVINO support, and provides retrained models at --batch-size 128
with new default one-cycle linear LR scheduler. YOLOv5 now officially supports 11 different formats, not just for export but for inference (both detect.py and PyTorch Hub), and validation to profile mAP and speed results after export.
Format | export.py --include
| Model |
---|---|---|
PyTorch | - | yolov5s.pt
|
TorchScript | torchscript
| yolov5s.torchscript
|
ONNX | onnx
| yolov5s.onnx
|
OpenVINO | openvino
| yolov5s_openvino_model/
|
TensorRT | engine
| yolov5s.engine
|
CoreML | coreml
| yolov5s.mlmodel
|
TensorFlow SavedModel | saved_model
| yolov5s_saved_model/
|
TensorFlow GraphDef | pb
| yolov5s.pb
|
TensorFlow Lite | tflite
| yolov5s.tflite
|
TensorFlow Edge TPU | edgetpu
| yolov5s_edgetpu.tflite
|
TensorFlow.js | tfjs
| yolov5s_web_model/
|
Usage examples (ONNX shown):
Export: python export.py --weights yolov5s.pt --include onnx
Detect: python detect.py --weights yolov5s.onnx
PyTorch Hub: model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5s.onnx')
Validate: python val.py --weights yolov5s.onnx
Visualize: https://netron.app
Important Updates
- TensorRT support: TensorFlow, Keras, TFLite, TF.js model export now fully integrated using
python export.py --include saved_model pb tflite tfjs
(#5699 by @imyhxy) - Tensorflow Edge TPU support ⭐ NEW: New smaller YOLOv5n (1.9M params) model below YOLOv5s (7.5M params), exports to 2.1 MB INT8 size, ideal for ultralight mobile solutions. (#3630 by @zldrobit)
- OpenVINO support: YOLOv5 ONNX models are now compatible with both OpenCV DNN and ONNX Runtime (#6057 by @glenn-jocher).
- Export Benchmarks: Benchmark (mAP and speed) all YOLOv5 export formats with
python utils/benchmarks.py --weights yolov5s.pt
. Currently operates on CPU, future updates will implement GPU support. (#6613 by @glenn-jocher). - Architecture: no changes
- Hyperparameters: minor change
- hyp-scratch-large.yaml
lrf
reduced from 0.2 to 0.1 (#6525 by @glenn-jocher).
- hyp-scratch-large.yaml
- Training: Default Learning Rate (LR) scheduler updated
- One-cycle with cosine replace with one-cycle linear for improved results (#6729 by @glenn-jocher).
New Results
All model trainings logged to https://wandb.ai/glenn-jocher/YOLOv5_v61_official
Figure Notes (click to expand)
python val.py --task study --data coco.yaml --iou 0.7 --weights yolov5n6.pt yolov5s6.pt yolov5m6.pt yolov5l6.pt yolov5x6.pt
Example YOLOv5l before and after metrics:
YOLOv5l Large | size (pixels) | mAPval 0.5:0.95 | mAPval 0.5 | Speed CPU b1 (ms) | Speed V100 b1 (ms) | Speed V100 b32 (ms) | params (M) | FLOPs @640 (B) |
---|---|---|---|---|---|---|---|---|
v5.0 | 640 | 48.2 | 66.9 | 457.9 | 11.6 | 2.8 | 47.0 | 115.4 |
v6.0 (previous) | 640 | 48.8 | 67.2 | 424.5 | 10.9 | 2.7 | 46.5 | 109.1 |
v6.1 (this release) | 640 | 49.0 | 67.3 | 424.5 | 10.9 | 2.7 | 46.5 | 109.1 |
Pretrained Checkpoints
Model | size (pixels) | mAPval 0.5:0.95 | mAPval 0.5 | Speed CPU b1 (ms) | Speed V100 b1 (ms) | Speed V100 b32 (ms) | params (M) | FLOPs @640 (B) |
---|---|---|---|---|---|---|---|---|
YOLOv5n | 640 | 28.0 | 45.7 | 45 | 6.3 | 0.6 | 1.9 | 4.5 |
YOLOv5s | 640 | 37.4 | 56.8 | 98 | 6.4 | 0.9 | 7.2 | 16.5 |
YOLOv5m | 640 | 45.4 | 64.1 | 224 | 8.2 | 1.7 | 21.2 | 49.0 |
YOLOv5l | 640 | 49.0 | 67.3 | 430 | 10.1 | 2.7 | 46.5 | 109.1 |
YOLOv5x | 640 | 50.7 | 68.9 | 766 | 12.1 | 4.8 | 86.7 | 205.7 |
YOLOv5n6 | 1280 | 36.0 | 54.4 | 153 | 8.1 | 2.1 | 3.2 | 4.6 |
YOLOv5s6 | 1280 | 44.8 | 63.7 | 385 | 8.2 | 3.6 | 12.6 | 16.8 |
YOLOv5m6 | 1280 | 51.3 | 69.3 | 887 | 11.1 | 6.8 | 35.7 | 50.0 |
YOLOv5l6 | 1280 | 53.7 | 71.3 | 1784 | 15.8 | 10.5 | 76.8 | 111.4 |
YOLOv5x6 + TTA | 1280 1536 | 55.0 55.8 | 72.7 72.7 | 3136 - | 26.2 - | 19.4 - | 140.7 - | 209.8 - |
Table Notes (click to expand)
- All checkpoints are trained to 300 epochs with default settings. Nano and Small models use hyp.scratch-low.yaml hyps, all others use hyp.scratch-high.yaml.
- mAPval values are for single-model single-scale on COCO val2017 dataset.
Reproduce bypython val.py --data coco.yaml --img 640 --conf 0.001 --iou 0.65
- Speed averaged over COCO val images using a AWS p3.2xlarge instance. NMS times (~1 ms/img) not included.
Reproduce bypython val.py --data coco.yaml --img 640 --task speed --batch 1
- TTA Test Time Augmentation includes reflection and scale augmentations.
Reproduce bypython val.py --data coco.yaml --img 1536 --iou 0.7 --augment
Changelog
Changes between previous release and this release: v6.0...v6.1
Changes since this release: v6.1...HEAD
New Features and Bug Fixes (271)
tf
conversion in new v6 models by @YoniChechik in #5153
'onnxruntime-gpu' if torch.has_cuda
by @glenn-jocher in #5087
LoadImagesAndLabels()
dataloader by @glenn-jocher in #5172
''
and ""
by @glenn-jocher in #5192
on_fit_epoch_end
callback by @glenn-jocher in #5232
EarlyStopping()
message by @glenn-jocher in #5303
autobatch
feature for best batch-size
estimation by @glenn-jocher in #5092
AutoShape.forward()
model.classes example by @glenn-jocher in #5324
nl
fix by @glenn-jocher in #5332
MixConv2d()
remove shortcut + apply depthwise by @glenn-jocher in #5410
indexing='ij'
for PyTorch 1.10 by @glenn-jocher in #5309
get_loggers()
by @glenn-jocher in #4854
check_git_status()
to run under ROOT
working directory by @MrinalJain17 in #5441
LoadImages()
dataloader return values by @glenn-jocher in #5455
check_requirements(('tensorflow>=2.4.1',))
by @glenn-jocher in #5476
LOGGER
by @glenn-jocher in #5483
increment_path()
with multiple-suffix filenames by @glenn-jocher in #5518
is_coco
logic betwen train.py and val.py by @glenn-jocher in #5521
increment_path()
explicit file vs dir handling by @glenn-jocher in #5523
check_file()
avoid repeat URL downloads by @glenn-jocher in #5526
models/hub/*.yaml
files for v6.0n release by @glenn-jocher in #5540
intersect_dicts()
in hubconf.py fix by @glenn-jocher in #5542
save_one_box()
by @glenn-jocher in #5545
--conf-thres
>> 0.001 warning by @glenn-jocher in #5567
LOGGER
consolidation by @glenn-jocher in #5569
DetectMultiBackend()
class by @glenn-jocher in #5549
notebook_init()
to utils/init.py by @glenn-jocher in #5488
check_requirements()
resource warning allocation open file by @ayman-saleh in #5602
tqdm
to fixed width by @glenn-jocher in #5367
speed
and study
tasks by @glenn-jocher in #5608
np.unique()
sort fix for segments by @glenn-jocher in #5609
WORLD_SIZE
-safe dataloader workers by @glenn-jocher in #5631
shuffle=True
for training by @werner-duvaud in #5623
LOGGER
by @glenn-jocher in #5635
transpose()
with 1 permute
in TransformerBlock()` by @dingyiwei in #5645
NUM_THREADS
leave at least 1 CPU free by @glenn-jocher in #5706
.autoshape()
method by @glenn-jocher in #5694
--visualize
by @Zengyf-CVer in #5701
torch==1.7.0
Path support by @miknyko in #5781
DetectMultiBackend()
by @phodgers in #5792
model.warmup()
method by @glenn-jocher in #5810
dataset_stats()
to cv2.INTER_AREA
by @glenn-jocher in #5821
wandb.errors.UsageError
by @glenn-jocher in #5839
imgs
in LoadStreams
by @passerbythesun in #5850
LoadImages
ret_val=False
handling by @gmt710 in #5852
*.torchscript
by @glenn-jocher in #5856
--workers 8
argument to val.py by @iumyx2612 in #5857
plot_lr_scheduler()
by @daikankan in #5864
nl
after cutout()
by @glenn-jocher in #5873
AutoShape()
models as DetectMultiBackend()
instances by @glenn-jocher in #5845
Detections().tolist()
explicit argument fix by @lizeng614 in #5907
notebook_init()
by @glenn-jocher in #5919
plot_lr_scheduler()
" by @glenn-jocher in #5920
autocast(False)
by @glenn-jocher in #5926
select_device()
robust to batch_size=-1
by @youyuxiansen in #5940
strip_optimizer()
by @iumyx2612 in #5949
NUM_THREADS
by @glenn-jocher in #5954
tolist()
method by @yonomitt in #5945
imgsz
bug by @d57montes in #5948
pretrained=False
fix by @glenn-jocher in #5966
__init__()
by @glenn-jocher in #5979
ar_thr
from 20 to 100 for better detection on slender (high aspect ratio) objects by @MrinalJain17 in #5556
--weights URL
by @glenn-jocher in #5991
jar xf file.zip
for zips by @glenn-jocher in #5993
self.jit
fix by @glenn-jocher in #6007
--freeze
argument by @youyuxiansen in #6019
LOGGER
fix by @glenn-jocher in #6041
set_logging()
indexing by @glenn-jocher in #6042
--freeze
fix by @glenn-jocher in #6044
if: else
statements by @cmoseses in #6087
max_wh=7680
for 8k images by @glenn-jocher in #6178
*_openvino_model/
dir by @glenn-jocher in #6180
anchor_grid
compatibility fix by @imyhxy in #6185
tensorrt>=7.0.0
checks by @glenn-jocher in #6193
nan
-robust stream FPS by @glenn-jocher in #6198
--int8
'flatbuffers==1.12' fix by @glenn-jocher in #6216
--int8
'flatbuffers==1.12' fix 2 by @glenn-jocher in #6217
edgetpu_compiler
checks by @glenn-jocher in #6218
edgetpu-compiler
autoinstall by @glenn-jocher in #6223
models/hub
variants by @glenn-jocher in #6230
cmd
string on tfjs
export by @dart-bird in #6243
--half
FP16 inference by @glenn-jocher in #6268
is_kaggle()
function by @glenn-jocher in #6285
device
count check by @glenn-jocher in #6290
select_device()
cleanup by @glenn-jocher in #6302
train.py
parameter groups desc error by @Otfot in #6318
dataset_stats()
autodownload capability by @glenn-jocher in #6303
assert im.device.type != 'cpu'
on export by @glenn-jocher in #6340
export.py
return exported files/dirs by @glenn-jocher in #6343
export.py
automatic forward_export
by @glenn-jocher in #6352
VERBOSE
environment variable by @johnk2hawaii in #6353
de_parallel()
rather than is_parallel()
by @imyhxy in #6354
DEVICE_COUNT
instead of WORLD_SIZE
to calculate nw
by @sitecao in #6324
--evolve
by @AyushExel in #6374
albumentations
to Dockerfile by @glenn-jocher in #6392
stop_training=False
flag to callbacks by @haimat in #6365
detect.py
GIF video inference by @glenn-jocher in #6410
greetings.yaml
email address by @glenn-jocher in #6412
tflite_runtime
for TFLite inference if installed by @motokimura in #6406
VERBOSE
env variable to YOLOv5_VERBOSE
by @glenn-jocher in #6428
*.asf
video support by @toschi23 in #6436
dataset_stats()
autodownload capability" by @glenn-jocher in #6442
select_device()
for Multi-GPU by @glenn-jocher in #6434
select_device()
for Multi-GPU by @glenn-jocher in #6461
export.py
usage examples by @glenn-jocher in #6495
list()
-> sorted()
by @glenn-jocher in #6496
torch.jit.TracerWarning
on export by @glenn-jocher in #6498
export.run()
TracerWarning
by @glenn-jocher in #6499
batch_size
on resuming by @AyushExel in #6512
lrf: 0.1
by @glenn-jocher in #6525
sudo
fix by @glenn-jocher in #6531
tf.lite.experimental.load_delegate
fix by @glenn-jocher in #6536
if any(f):
by @glenn-jocher in #6569
plot_labels()
colored histogram bug by @glenn-jocher in #6574
--evolve
project names by @MattVAD in #6567
DATASETS_DIR
global in general.py by @glenn-jocher in #6578
opt
from train.run()
by @chf4850 in #6581
pafy
package by @glenn-jocher in #6603
hyp_evolve.yaml
indexing bug by @glenn-jocher in #6604
ROOT / data
when running W&B log_dataset()
by @or-toledano in #6606
youtube_dl==2020.12.2
by @glenn-jocher in #6612
vmin=0.0
by @glenn-jocher in #6638
KeyError
by @imyhxy in #6637
--workers
by @glenn-jocher in #6658
--workers
single-GPU/CPU fix by @glenn-jocher in #6659
--cache val
option by @glenn-jocher in #6663
scipy.cluster.vq.kmeans
too few points by @glenn-jocher in #6668
torch==1.10.2+cu113
by @glenn-jocher in #6669
--evolve --bucket gs://...
by @glenn-jocher in #6698
export_formats()
in export.py by @glenn-jocher in #6705
torch
AMP-CPU warnings by @glenn-jocher in #6706
nw
to max(nd, 1)
by @glenn-jocher in #6714
New Contributors (48)
Full Changelog: v6.0...v6.1