Home

Awesome

<div align="center"> <p> <a href="https://ultralytics.com/events/yolovision" target="_blank"> <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/banner-yolov8.png"></a> </p>

中文 | 한국어 | 日本語 | Русский | Deutsch | Français | Español | Português | Türkçe | Tiếng Việt | हिन्दी | العربية

<div> <a href="https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml"><img src="https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml/badge.svg" alt="YOLOv5 CI"></a> <a href="https://zenodo.org/badge/latestdoi/264818686"><img src="https://zenodo.org/badge/264818686.svg" alt="YOLOv5 Citation"></a> <a href="https://hub.docker.com/r/ultralytics/yolov5"><img src="https://img.shields.io/docker/pulls/ultralytics/yolov5?logo=docker" alt="Docker Pulls"></a> <a href="https://ultralytics.com/discord"><img alt="Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a> <a href="https://community.ultralytics.com"><img alt="Ultralytics Forums" src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue"></a> <br> <a href="https://bit.ly/yolov5-paperspace-notebook"><img src="https://assets.paperspace.io/img/gradient-badge.svg" alt="Run on Gradient"></a> <a href="https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> <a href="https://www.kaggle.com/ultralytics/yolov5"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open In Kaggle"></a> </div> <br>

YOLOv5 🚀 is the world's most loved vision AI, representing <a href="https://ultralytics.com">Ultralytics</a> open-source research into future vision AI methods, incorporating lessons learned and best practices evolved over thousands of hours of research and development.

We hope that the resources here will help you get the most out of YOLOv5. Please browse the YOLOv5 <a href="https://docs.ultralytics.com/yolov5">Docs</a> for details, raise an issue on <a href="https://github.com/ultralytics/yolov5/issues/new/choose">GitHub</a> for support, and join our <a href="https://ultralytics.com/discord">Discord</a> community for questions and discussions!

To request an Enterprise License please complete the form at Ultralytics Licensing.

<div align="center"> <a href="https://github.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="2%" alt="Ultralytics GitHub"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%"> <a href="https://www.linkedin.com/company/ultralytics/"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="2%" alt="Ultralytics LinkedIn"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%"> <a href="https://twitter.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="2%" alt="Ultralytics Twitter"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%"> <a href="https://youtube.com/ultralytics?sub_confirmation=1"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="2%" alt="Ultralytics YouTube"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%"> <a href="https://www.tiktok.com/@ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="2%" alt="Ultralytics TikTok"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%"> <a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="2%" alt="Ultralytics BiliBili"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="2%"> <a href="https://ultralytics.com/discord"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="2%" alt="Ultralytics Discord"></a> </div> </div> <br>

<div align="center">YOLOv8 🚀 NEW</div>

We are thrilled to announce the launch of Ultralytics YOLOv8 🚀, our NEW cutting-edge, state-of-the-art (SOTA) model released at https://github.com/ultralytics/ultralytics. YOLOv8 is designed to be fast, accurate, and easy to use, making it an excellent choice for a wide range of object detection, image segmentation and image classification tasks.

See the YOLOv8 Docs for details and get started with:

PyPI version Downloads

pip install ultralytics
<div align="center"> <a href="https://ultralytics.com/yolov8" target="_blank"> <img width="100%" src="https://raw.githubusercontent.com/ultralytics/assets/main/yolov8/yolo-comparison-plots.png"></a> </div>

<div align="center">Documentation</div>

See the YOLOv5 Docs for full documentation on training, testing and deployment. See below for quickstart examples.

<details open> <summary>Install</summary>

Clone repo and install requirements.txt in a Python>=3.8.0 environment, including PyTorch>=1.8.

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install
</details> <details> <summary>Inference</summary>

YOLOv5 PyTorch Hub inference. Models download automatically from the latest YOLOv5 release.

import torch

# Model
model = torch.hub.load("ultralytics/yolov5", "yolov5s")  # or yolov5n - yolov5x6, custom

# Images
img = "https://ultralytics.com/images/zidane.jpg"  # or file, Path, PIL, OpenCV, numpy, list

# Inference
results = model(img)

# Results
results.print()  # or .show(), .save(), .crop(), .pandas(), etc.
</details> <details> <summary>Inference with detect.py</summary>

detect.py runs inference on a variety of sources, downloading models automatically from the latest YOLOv5 release and saving results to runs/detect.

python detect.py --weights yolov5s.pt --source 0                               # webcam
                                               img.jpg                         # image
                                               vid.mp4                         # video
                                               screen                          # screenshot
                                               path/                           # directory
                                               list.txt                        # list of images
                                               list.streams                    # list of streams
                                               'path/*.jpg'                    # glob
                                               'https://youtu.be/LNwODJXcvt4'  # YouTube
                                               'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream
</details> <details> <summary>Training</summary>

The commands below reproduce YOLOv5 COCO results. Models and datasets download automatically from the latest YOLOv5 release. Training times for YOLOv5n/s/m/l/x are 1/2/4/6/8 days on a V100 GPU (Multi-GPU times faster). Use the largest --batch-size possible, or pass --batch-size -1 for YOLOv5 AutoBatch. Batch sizes shown for V100-16GB.

python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5n.yaml  --batch-size 128
                                                                 yolov5s                    64
                                                                 yolov5m                    40
                                                                 yolov5l                    24
                                                                 yolov5x                    16
<img width="800" src="https://user-images.githubusercontent.com/26833433/90222759-949d8800-ddc1-11ea-9fa1-1c97eed2b963.png"> </details> <details open> <summary>Tutorials</summary> </details>

<div align="center">Integrations</div>

<br> <a align="center" href="https://ultralytics.com/hub" target="_blank"> <img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/integrations-loop.png"></a> <br> <br> <div align="center"> <a href="https://roboflow.com/?ref=ultralytics"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-roboflow.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="" /> <a href="https://cutt.ly/yolov5-readme-clearml"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-clearml.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="" /> <a href="https://bit.ly/yolov5-readme-comet2"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-comet.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="15%" height="0" alt="" /> <a href="https://bit.ly/yolov5-neuralmagic"> <img src="https://github.com/ultralytics/assets/raw/main/partners/logo-neuralmagic.png" width="10%" /></a> </div>
RoboflowClearML ⭐ NEWComet ⭐ NEWNeural Magic ⭐ NEW
Label and export your custom datasets directly to YOLOv5 for training with RoboflowAutomatically track, visualize and even remotely train YOLOv5 using ClearML (open-source!)Free forever, Comet lets you save YOLOv5 models, resume training, and interactively visualise and debug predictionsRun YOLOv5 inference up to 6x faster with Neural Magic DeepSparse

<div align="center">Ultralytics HUB</div>

Experience seamless AI with Ultralytics HUB ⭐, the all-in-one solution for data visualization, YOLOv5 and YOLOv8 🚀 model training and deployment, without any coding. Transform images into actionable insights and bring your AI visions to life with ease using our cutting-edge platform and user-friendly Ultralytics App. Start your journey for Free now!

<a align="center" href="https://ultralytics.com/hub" target="_blank"> <img width="100%" src="https://github.com/ultralytics/assets/raw/main/im/ultralytics-hub.png"></a>

<div align="center">Why YOLOv5</div>

YOLOv5 has been designed to be super easy to get started and simple to learn. We prioritize real-world results.

<p align="left"><img width="800" src="https://user-images.githubusercontent.com/26833433/155040763-93c22a27-347c-4e3c-847a-8094621d3f4e.png"></p> <details> <summary>YOLOv5-P5 640 Figure</summary> <p align="left"><img width="800" src="https://user-images.githubusercontent.com/26833433/155040757-ce0934a3-06a6-43dc-a979-2edbbd69ea0e.png"></p> </details> <details> <summary>Figure Notes</summary> </details>

Pretrained Checkpoints

Modelsize<br><sup>(pixels)mAP<sup>val<br>50-95mAP<sup>val<br>50Speed<br><sup>CPU b1<br>(ms)Speed<br><sup>V100 b1<br>(ms)Speed<br><sup>V100 b32<br>(ms)params<br><sup>(M)FLOPs<br><sup>@640 (B)
YOLOv5n64028.045.7456.30.61.94.5
YOLOv5s64037.456.8986.40.97.216.5
YOLOv5m64045.464.12248.21.721.249.0
YOLOv5l64049.067.343010.12.746.5109.1
YOLOv5x64050.768.976612.14.886.7205.7
YOLOv5n6128036.054.41538.12.13.24.6
YOLOv5s6128044.863.73858.23.612.616.8
YOLOv5m6128051.369.388711.16.835.750.0
YOLOv5l6128053.771.3178415.810.576.8111.4
YOLOv5x6<br>+ TTA1280<br>153655.0<br>55.872.7<br>72.73136<br>-26.2<br>-19.4<br>-140.7<br>-209.8<br>-
<details> <summary>Table Notes</summary> </details>

<div align="center">Segmentation</div>

Our new YOLOv5 release v7.0 instance segmentation models are the fastest and most accurate in the world, beating all current SOTA benchmarks. We've made them super simple to train, validate and deploy. See full details in our Release Notes and visit our YOLOv5 Segmentation Colab Notebook for quickstart tutorials.

<details> <summary>Segmentation Checkpoints</summary> <div align="center"> <a align="center" href="https://ultralytics.com/yolov5" target="_blank"> <img width="800" src="https://user-images.githubusercontent.com/61612323/204180385-84f3aca9-a5e9-43d8-a617-dda7ca12e54a.png"></a> </div>

We trained YOLOv5 segmentations models on COCO for 300 epochs at image size 640 using A100 GPUs. 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 notebooks for easy reproducibility.

Modelsize<br><sup>(pixels)mAP<sup>box<br>50-95mAP<sup>mask<br>50-95Train time<br><sup>300 epochs<br>A100 (hours)Speed<br><sup>ONNX CPU<br>(ms)Speed<br><sup>TRT A100<br>(ms)params<br><sup>(M)FLOPs<br><sup>@640 (B)
YOLOv5n-seg64027.623.480:1762.71.22.07.1
YOLOv5s-seg64037.631.788:16173.31.47.626.4
YOLOv5m-seg64045.037.1108:36427.02.222.070.8
YOLOv5l-seg64049.039.966:43 (2x)857.42.947.9147.7
YOLOv5x-seg64050.741.462:56 (3x)1579.24.588.8265.7
</details> <details> <summary>Segmentation Usage Examples &nbsp;<a href="https://colab.research.google.com/github/ultralytics/yolov5/blob/master/segment/tutorial.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a></summary>

Train

YOLOv5 segmentation training supports auto-download COCO128-seg segmentation dataset with --data coco128-seg.yaml argument and manual download of COCO-segments dataset with bash data/scripts/get_coco.sh --train --val --segments and then python train.py --data coco.yaml.

# Single-GPU
python segment/train.py --data coco128-seg.yaml --weights yolov5s-seg.pt --img 640

# Multi-GPU DDP
python -m torch.distributed.run --nproc_per_node 4 --master_port 1 segment/train.py --data coco128-seg.yaml --weights yolov5s-seg.pt --img 640 --device 0,1,2,3

Val

Validate YOLOv5s-seg mask mAP on COCO dataset:

bash data/scripts/get_coco.sh --val --segments  # download COCO val segments split (780MB, 5000 images)
python segment/val.py --weights yolov5s-seg.pt --data coco.yaml --img 640  # validate

Predict

Use pretrained YOLOv5m-seg.pt to predict bus.jpg:

python segment/predict.py --weights yolov5m-seg.pt --source data/images/bus.jpg
model = torch.hub.load(
    "ultralytics/yolov5", "custom", "yolov5m-seg.pt"
)  # load from PyTorch Hub (WARNING: inference not yet supported)
zidanebus

Export

Export YOLOv5s-seg model to ONNX and TensorRT:

python export.py --weights yolov5s-seg.pt --include onnx engine --img 640 --device 0
</details>

<div align="center">Classification</div>

YOLOv5 release v6.2 brings support for classification model training, validation and deployment! See full details in our Release Notes and visit our YOLOv5 Classification Colab Notebook for quickstart tutorials.

<details> <summary>Classification Checkpoints</summary> <br>

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.

Modelsize<br><sup>(pixels)acc<br><sup>top1acc<br><sup>top5Training<br><sup>90 epochs<br>4xA100 (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-cls22464.685.47:593.30.52.50.5
YOLOv5s-cls22471.590.28:096.60.65.41.4
YOLOv5m-cls22475.992.910:0615.50.912.93.9
YOLOv5l-cls22478.094.011:5626.91.426.58.5
YOLOv5x-cls22479.094.415:0454.31.848.115.9
ResNet1822470.389.56:4711.20.511.73.7
ResNet3422473.991.88:3320.60.921.87.4
ResNet5022476.893.411:1023.41.025.68.5
ResNet10122478.594.317:1042.11.944.515.9
EfficientNet_b022475.192.413:0312.51.35.31.0
EfficientNet_b122476.493.217:0414.91.67.81.5
EfficientNet_b222476.693.417:1015.91.69.11.7
EfficientNet_b322477.794.019:1918.91.912.22.4
<details> <summary>Table Notes (click to expand)</summary> </details> </details> <details> <summary>Classification Usage Examples &nbsp;<a href="https://colab.research.google.com/github/ultralytics/yolov5/blob/master/classify/tutorial.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a></summary>

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 YOLOv5m-cls accuracy on ImageNet-1k dataset:

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

Use pretrained YOLOv5s-cls.pt to predict bus.jpg:

python classify/predict.py --weights yolov5s-cls.pt --source data/images/bus.jpg
model = torch.hub.load("ultralytics/yolov5", "custom", "yolov5s-cls.pt")  # load from PyTorch Hub

Export

Export a group of trained YOLOv5s-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
</details>

<div align="center">Environments</div>

Get started in seconds with our verified environments. Click each icon below for details.

<div align="center"> <a href="https://bit.ly/yolov5-paperspace-notebook"> <img src="https://github.com/ultralytics/assets/releases/download/v0.0.0/logo-gradient.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="5%" alt="" /> <a href="https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb"> <img src="https://github.com/ultralytics/assets/releases/download/v0.0.0/logo-colab-small.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="5%" alt="" /> <a href="https://www.kaggle.com/ultralytics/yolov5"> <img src="https://github.com/ultralytics/assets/releases/download/v0.0.0/logo-kaggle-small.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="5%" alt="" /> <a href="https://hub.docker.com/r/ultralytics/yolov5"> <img src="https://github.com/ultralytics/assets/releases/download/v0.0.0/logo-docker-small.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="5%" alt="" /> <a href="https://docs.ultralytics.com/yolov5/environments/aws_quickstart_tutorial/"> <img src="https://github.com/ultralytics/assets/releases/download/v0.0.0/logo-aws-small.png" width="10%" /></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="5%" alt="" /> <a href="https://docs.ultralytics.com/yolov5/environments/google_cloud_quickstart_tutorial/"> <img src="https://github.com/ultralytics/assets/releases/download/v0.0.0/logo-gcp-small.png" width="10%" /></a> </div>

<div align="center">Contribute</div>

We love your input! We want to make contributing to YOLOv5 as easy and transparent as possible. Please see our Contributing Guide to get started, and fill out the YOLOv5 Survey to send us feedback on your experiences. Thank you to all our contributors!

<!-- SVG image from https://opencollective.com/ultralytics/contributors.svg?width=990 --> <a href="https://github.com/ultralytics/yolov5/graphs/contributors"> <img src="https://github.com/ultralytics/assets/raw/main/im/image-contributors.png" /></a>

<div align="center">License</div>

Ultralytics offers two licensing options to accommodate diverse use cases:

<div align="center">Contact</div>

For YOLOv5 bug reports and feature requests please visit GitHub Issues, and join our Discord community for questions and discussions!

<br> <div align="center"> <a href="https://github.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="3%" alt="Ultralytics GitHub"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%"> <a href="https://www.linkedin.com/company/ultralytics/"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="3%" alt="Ultralytics LinkedIn"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%"> <a href="https://twitter.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="3%" alt="Ultralytics Twitter"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%"> <a href="https://youtube.com/ultralytics?sub_confirmation=1"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="3%" alt="Ultralytics YouTube"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%"> <a href="https://www.tiktok.com/@ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="3%" alt="Ultralytics TikTok"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%"> <a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="3%" alt="Ultralytics BiliBili"></a> <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%"> <a href="https://ultralytics.com/discord"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a> </div>