CLI
The YOLO Command Line Interface (CLI) is the easiest way to get started training, validating, predicting and exporting YOLOv8 models.
The yolo
command is used for all actions:
Where:
TASK
(optional) is one of[detect, segment, classify]
. If it is not passed explicitly YOLOv8 will try to guess theTASK
from the model type.MODE
(required) is one of[train, val, predict, export]
ARGS
(optional) are any number of customarg=value
pairs likeimgsz=320
that override defaults. For a full list of availableARGS
see the Configuration page anddefaults.yaml
GitHub source.
Note: Arguments MUST be passed as arg=val
with an equals sign and a space between arg=val
pairs
yolo predict model=yolov8n.pt imgsz=640 conf=0.25
✅yolo predict model yolov8n.pt imgsz 640 conf 0.25
❌yolo predict --model yolov8n.pt --imgsz 640 --conf 0.25
❌
Train
Train YOLOv8n on the COCO128 dataset for 100 epochs at image size 640. For a full list of available arguments see the Configuration page.
Val
Validate trained YOLOv8n model accuracy on the COCO128 dataset. No argument need to passed as the model
retains it's
training data
and arguments as model attributes.
Predict
Use a trained YOLOv8n model to run predictions on images.
Export
Export a YOLOv8n model to a different format like ONNX, CoreML, etc.
yolo export model=yolov8n.pt format=onnx # export official model
yolo export model=path/to/best.pt format=onnx # export custom trained model
Available YOLOv8 export formats include:
Format | format= |
Model |
---|---|---|
PyTorch | - | yolov8n.pt |
TorchScript | torchscript |
yolov8n.torchscript |
ONNX | onnx |
yolov8n.onnx |
OpenVINO | openvino |
yolov8n_openvino_model/ |
TensorRT | engine |
yolov8n.engine |
CoreML | coreml |
yolov8n.mlmodel |
TensorFlow SavedModel | saved_model |
yolov8n_saved_model/ |
TensorFlow GraphDef | pb |
yolov8n.pb |
TensorFlow Lite | tflite |
yolov8n.tflite |
TensorFlow Edge TPU | edgetpu |
yolov8n_edgetpu.tflite |
TensorFlow.js | tfjs |
yolov8n_web_model/ |
PaddlePaddle | paddle |
yolov8n_paddle_model/ |
Overriding default arguments
Default arguments can be overriden by simply passing them as arguments in the CLI in arg=value
pairs.
Train a detection model for 10 epochs
with learning_rate
of 0.01
Predict a YouTube video using a pretrained segmentation model at image size 320:
Overriding default config file
You can override the default.yaml
config file entirely by passing a new file with the cfg
arguments,
i.e. cfg=custom.yaml
.
To do this first create a copy of default.yaml
in your current working dir with the yolo copy-cfg
command.
This will create default_copy.yaml
, which you can then pass as cfg=default_copy.yaml
along with any additional args,
like imgsz=320
in this example: