2022-12-05 00:34:57 +00:00
## Installation
2023-01-09 14:24:01 +00:00
Install YOLOv8 via the `ultralytics` pip package for the latest stable release or by cloning the [https://github.com/ultralytics/ultralytics ](https://github.com/ultralytics/ultralytics ) repository for the most up-to-date version.
!!! note "pip install (recommended)"
2022-12-05 00:34:57 +00:00
```
pip install ultralytics
```
2023-01-09 14:24:01 +00:00
!!! note "git clone"
2022-12-05 00:34:57 +00:00
```
git clone https://github.com/ultralytics/ultralytics
cd ultralytics
pip install -e '.[dev]'
```
See contributing section to know more about contributing to the project
## CLI
2023-01-09 14:24:01 +00:00
The command line YOLO interface lets you simply train, validate or infer models on various tasks and versions.
CLI requires no customization or code. You can simply run all tasks from the terminal with the `yolo` command.
!!! note
2022-12-05 00:34:57 +00:00
=== "Syntax"
```bash
2023-01-09 14:24:01 +00:00
yolo task=detect mode=train model=yolov8n.yaml args...
classify predict yolov8n-cls.yaml args...
segment val yolov8n-seg.yaml args...
export yolov8n.pt format=onnx args...
2022-12-05 00:34:57 +00:00
```
2022-12-20 04:23:55 +00:00
=== "Example training"
2022-12-05 00:34:57 +00:00
```bash
2023-01-09 14:24:01 +00:00
yolo task=detect mode=train model=yolov8n.pt data=coco128.yaml device=0
2022-12-05 00:34:57 +00:00
```
2023-01-09 14:24:01 +00:00
=== "Example Multi-GPU training"
2022-12-20 04:23:55 +00:00
```bash
2023-01-09 14:24:01 +00:00
yolo task=detect mode=train model=yolov8n.pt data=coco128.yaml device=\'0,1,2,3\'
2022-12-20 04:23:55 +00:00
```
2023-01-02 15:12:30 +00:00
[CLI Guide ](cli.md ){ .md-button .md-button--primary}
2022-12-05 00:34:57 +00:00
## Python API
2023-01-09 14:24:01 +00:00
The Python API allows users to easily use YOLOv8 in their Python projects. It provides functions for loading and running the model, as well as for processing the model's output. The interface is designed to be easy to use, so that users can quickly implement object detection in their projects.
Overall, the Python interface is a useful tool for anyone looking to incorporate object detection, segmentation or classification into their Python projects using YOLOv8.
!!! note
2022-12-05 00:34:57 +00:00
```python
from ultralytics import YOLO
2022-12-12 03:51:00 +00:00
2023-01-09 14:24:01 +00:00
model = YOLO('yolov8n.yaml') # build a new model from scratch
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for best training results)
results = model.train(data='coco128.yaml') # train the model
results = model.val() # evaluate model performance on the validation set
results = model.predict(source='bus.jpg') # predict on an image
success = model.export(format='onnx') # export the model to ONNX format
2022-12-05 00:34:57 +00:00
```
2023-01-02 15:12:30 +00:00
[API Guide ](sdk.md ){ .md-button .md-button--primary}