What is YOLOv5?
YOLOv5 is Ultralytics' PyTorch implementation of the YOLOv5 family of real-time vision models, published as a self-contained repository you clone and run. It covers three tasks: object detection, instance segmentation (added in release v7.0) and image classification (added in release v6.2). It sits in the Vision & Understanding category of the Multimodal Generation tools and is open-source, written in Python and licensed AGPL-3.0.
Overview
YOLOv5 is Ultralytics' PyTorch implementation of the YOLOv5 family of real-time vision models, published as a self-contained repository you clone and run. It covers three tasks: object detection, instance segmentation (added in release v7.0) and image classification (added in release v6.2). Pretrained checkpoints come in five sizes — nano, small, medium, large and extra-large (yolov5n through yolov5x) — plus larger-input P6 variants, and are downloaded automatically from the repo's GitHub releases the first time you use them.

It is a different thing from the `ultralytics` pip package that the same company maintains. YOLOv5 is driven by standalone scripts inside the cloned repo — `train.py`, `val.py`, `detect.py` and `export.py`, with train, val and predict counterparts under `segment/` and `classify/` — and by PyTorch Hub (`torch.hub.load("ultralytics/yolov5", ...)`). The `ultralytics` package is the maintainers' unified Python and `yolo` CLI home for newer Ultralytics YOLO architectures and adds tasks such as pose estimation and oriented bounding boxes. The YOLOv5 README itself points people who want the later YOLO generations or that unified interface to the package, and describes YOLOv5 as a mature, production-proven model for detection, segmentation and classification.
In practice people reach for this repo when an existing pipeline, paper or deployment is already built on YOLOv5 checkpoints and scripts, or when they want the plain, readable training scripts to modify. The repo also documents workflows around the models: training on custom data, multi-GPU training, test-time augmentation, model ensembling, pruning, hyperparameter evolution, transfer learning with frozen layers, and exporting to deployment formats such as ONNX, TensorRT, CoreML and TFLite. It is dual-licensed: AGPL-3.0 for open-source use, with an Ultralytics Enterprise License for commercial products that cannot meet the AGPL's terms.
What it does
- Detection, instance-segmentation and classification models in five sizes (n/s/m/l/x), with P6 variants trained at 1280-pixel input

- Standalone `train.py`, `val.py`, `detect.py` and `export.py` scripts, with `train.py` / `val.py` / `predict.py` counterparts under `segment/` and `classify/`
- One-line PyTorch Hub loading, with results you can print, show, save, crop or turn into a pandas table
- `detect.py` accepts webcams, images, videos, directories, glob patterns, screen capture, YouTube URLs and RTSP/RTMP/HTTP streams
- Export to deployment formats including ONNX, TensorRT, CoreML and TFLite through `export.py`
- Multi-GPU DDP training, AutoBatch (`--batch-size -1`), hyperparameter evolution and test-time augmentation built into the scripts
Getting started
YOLOv5 runs from a clone of the repository in a Python 3.8+ environment with PyTorch 1.8 or newer. Models and example datasets download automatically on first use.
Clone the repo and install requirements
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txtRun inference through PyTorch Hub
`torch.hub.load` fetches the model code and the checkpoint. The input can be a URL, a local file, a PIL image, an OpenCV frame, a numpy array or a list of them.
import torch
# options: yolov5n, yolov5s, yolov5m, yolov5l, yolov5x
model = torch.hub.load("ultralytics/yolov5", "yolov5s")
results = model("https://ultralytics.com/images/zidane.jpg")
results.print() # print results to console
results.save() # save to runs/detect/expOr run detect.py on files, cameras and streams
Annotated outputs are written to `runs/detect`.
python detect.py --weights yolov5s.pt --source 0 # webcam
python detect.py --weights yolov5s.pt --source img.jpg # image
python detect.py --weights yolov5s.pt --source vid.mp4 # video
python detect.py --weights yolov5s.pt --source path/to/images/
python detect.py --weights yolov5s.pt --source 'rtsp://example.com/media.mp4'Train a model
This is the README's command for training YOLOv5s from scratch on COCO. For your own dataset, follow the Train Custom Data tutorial in the YOLOv5 docs and point `--data` at your dataset YAML. `--batch-size -1` lets AutoBatch pick the batch size for your GPU.
python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5s.yaml --batch-size 64
Segment, classify and export
The segmentation and classification models use the same script pattern from their own folders; `export.py` converts any of them for deployment.
python segment/predict.py --weights yolov5m-seg.pt --source data/images/bus.jpg
python classify/predict.py --weights yolov5s-cls.pt --source data/images/bus.jpg
python export.py --weights yolov5s-seg.pt --include onnx engine --img 640 --device 0Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it

- Reach for it when an existing system, paper or edge deployment is built on YOLOv5 checkpoints and you need to retrain, reproduce or re-export them
- Reach for it when you want a real-time detector whose training and inference code are short, plain scripts you can read and edit
- Reach for it to fine-tune a small detector or segmenter on a custom dataset and ship it as ONNX or TensorRT
- Reach for the `ultralytics` package instead when you want newer YOLO architectures, pose or OBB tasks, or a single `yolo` CLI
Version history
Every verified update to YOLOv5 that AI/TLDR tracked, newest first — each links to our coverage and the official changeset.
- 2022-11-22v7.0
Added instance-segmentation models (YOLOv5n-seg to YOLOv5x-seg) with segment/train, val and predict scripts.
- 2022-08-17v6.2
Added image-classification models (YOLOv5-cls) with training, validation and export support.
How YOLOv5 compares
YOLOv5 alongside other open-source vision & understanding tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| PaddleOCR | ★ 92.1k | A toolkit for detecting and recognizing text in images across many languages, plus document parsing. |
| OpenCV | ★ 91.4k | The long-standing open-source computer-vision library for C++, Python and Java; version 5 rewrote the DNN engine and added ONNX-based LLM and VLM inference in-library. |
| Ultralytics YOLO | ★ 63k | A framework for training and running YOLO models for real-time object detection, segmentation, and tracking. |
| YOLOv5 | ★ 58.2k | The script-driven PyTorch repo behind the YOLOv5 detection, segmentation and classification models |
| Supervision | ★ 51.5k | A Python toolkit for processing, annotating, and visualizing detections and segmentations from many vision models. |
| MediaPipe | ★ 37.5k | Google's on-device ML framework: ready-to-run vision, text and audio tasks with one cross-platform API for Android, iOS, web, desktop and edge. |
| MMDetection | ★ 33k | An OpenMMLab toolbox with many object detection and instance segmentation algorithms for research and production. |
| vit-pytorch | ★ 25.6k | A single pip package with readable PyTorch implementations of the Vision Transformer and dozens of its research variants, for training image models from scratch. |
