Skip to content



Install YOLOv8 via the ultralytics pip package for the latest stable release or by cloning the repository for the most up-to-date version.


pip install ultralytics
git clone
cd ultralytics
pip install -e .

See the ultralytics requirements.txt file for a list of dependencies. Note that pip automatically installs all required dependencies.


PyTorch requirements vary by operating system and CUDA requirements, so it's recommended to install PyTorch first following instructions at

PyTorch Installation Instructions

Use with CLI

The YOLO command line interface (CLI) allows for simple single-line commands without the need for a Python environment. CLI requires no customization or Python code. You can simply run all tasks from the terminal with the yolo command. Check out the CLI Guide to learn more about using YOLOv8 from the command line.


Ultralytics yolo commands use the following syntax:


Where   TASK (optional) is one of [detect, segment, classify]
        MODE (required) is one of [train, val, predict, export, track]
        ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
See all ARGS in the full Configuration Guide or with yolo cfg

Train a detection model for 10 epochs with an initial learning_rate of 0.01

yolo train data=coco128.yaml epochs=10 lr0=0.01

Predict a YouTube video using a pretrained segmentation model at image size 320:

yolo predict source='' imgsz=320

Val a pretrained detection model at batch-size 1 and image size 640:

yolo val data=coco128.yaml batch=1 imgsz=640

Export a YOLOv8n classification model to ONNX format at image size 224 by 128 (no TASK required)

yolo export format=onnx imgsz=224,128

Run special commands to see version, view settings, run checks and more:

yolo help
yolo checks
yolo version
yolo settings
yolo copy-cfg
yolo cfg


Arguments must be passed as arg=val pairs, split by an equals = sign and delimited by spaces between pairs. Do not use -- argument prefixes or commas , between arguments.

  • yolo predict imgsz=640 conf=0.25   ✅
  • yolo predict model imgsz 640 conf 0.25   ❌
  • yolo predict --model --imgsz 640 --conf 0.25   ❌

CLI Guide

Use with Python

YOLOv8's Python interface allows for seamless integration into your Python projects, making it easy to load, run, and process the model's output. Designed with simplicity and ease of use in mind, the Python interface enables users to quickly implement object detection, segmentation, and classification in their projects. This makes YOLOv8's Python interface an invaluable tool for anyone looking to incorporate these functionalities into their Python projects.

For example, users can load a model, train it, evaluate its performance on a validation set, and even export it to ONNX format with just a few lines of code. Check out the Python Guide to learn more about using YOLOv8 within your Python projects.


from ultralytics import YOLO

# Create a new YOLO model from scratch
model = YOLO('yolov8n.yaml')

# Load a pretrained YOLO model (recommended for training)
model = YOLO('')

# Train the model using the 'coco128.yaml' dataset for 3 epochs
results = model.train(data='coco128.yaml', epochs=3)

# Evaluate the model's performance on the validation set
results = model.val()

# Perform object detection on an image using the model
results = model('')

# Export the model to ONNX format
success = model.export(format='onnx')

Python Guide

Created 2022-12-05, Updated 2023-05-09
Authors: Glenn Jocher (10), Ayush Chaurasia (4), Laughing (1)