yolov5

(★ 57,917)

Ultralytics YOLOv5 in PyTorch for object detection, instance segmentation, classification, training, and export.

File Explorer

  • .dockerignore
  • .gitattributes
  • .gitignore
  • AGENTS.md
  • benchmarks.py
  • CITATION.cff
  • CLAUDE.md
  • CONTRIBUTING.md
  • detect.py
  • export.py
  • hubconf.py
  • LICENSE
  • pyproject.toml
  • README.md
  • README.zh-CN.md
  • requirements.txt
  • train.py
  • tutorial.ipynb
  • val.py

# Installation Guide

python
Prerequisites

Setup Steps

git clone https://github.com/ultralytics/yolov5

Clone the YOLOv5 repository.

cd yolov5

Navigate to the project directory.

pip install -r requirements.txt

Install required python packages.

python detect.py --weights yolov5s.pt --source 0

Run object detection inference with the model.

Key Commands

pip install -r requirements.txt

Install all python dependency packages specified in requirements.txt.

python detect.py --weights yolov5s.pt --source 0

Run object detection inference on sources like webcam, images, or videos.

python train.py --img 640 --batch 16 --epochs 5 --data coco128.yaml --weights yolov5s.pt

Train a YOLOv5 model using a custom dataset.

python val.py --weights yolov5s.pt --data coco128.yaml

Validate the performance of the trained model.

python export.py --weights yolov5s.pt --include onnx

Export the trained model to other formats such as ONNX or TensorRT.

It is recommended to run in an NVIDIA GPU environment with CUDA support.

# Use via CDN

jsDelivr

jsDelivr serves any public GitHub repository as a CDN with zero setup. Pick a version and a file to get a ready-to-paste link and snippet.

Command Glossary

Commands referenced in this DOCs, explained below.

🔍

git clone

View Details ▼

Clone an existing repository.

git clone {{remote_repository_location}} {{path/to/directory}}

Clone an existing repository into a new directory (the default directory is the repository name):

git clone --recursive {{remote_repository_location}}

Clone an existing repository and its submodules:

git clone {{[-n|--no-checkout]}} {{remote_repository_location}}

Clone only the `.git` directory of an existing repository:

🔍

pip install

View Details ▼

Install Python packages.

pip install {{package1 package2 ...}}

Install one or more packages:

pip install {{package1 package2 ...}} {{[-U|--upgrade]}}

Upgrade all specified packages to the latest version, installing any that are not already present:

pip install {{package}}=={{version}}

Install a specific version of a package:

🔍

python

View Details ▼

Python language interpreter.

python

Start a REPL (interactive shell):

python {{path/to/file.py}}

Execute a specific Python file:

python -i {{path/to/file.py}}

Execute a specific Python file and start a REPL:

// repository documentation