Command Line Interface Usage
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.
Watch: Mastering Ultralytics YOLO: CLI
Example
Ultralytics yolo
commands use the following syntax:
yolo TASK MODE ARGS
Where TASK (optional) is one of [detect, segment, classify, pose, obb]
MODE (required) is one of [train, val, predict, export, track, benchmark]
ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
yolo cfg
Train a detection model for 10 epochs with an initial learning_rate of 0.01
Predict a YouTube video using a pretrained segmentation model at image size 320:
Val a pretrained detection model at batch-size 1 and image size 640:
Export a YOLO11n classification model to ONNX format at image size 224 by 128 (no TASK required)
Where:
TASK
(optional) is one of[detect, segment, classify, pose, obb]
. If it is not passed explicitly YOLO11 will try to guess theTASK
from the model type.MODE
(required) is one of[train, val, predict, export, track, benchmark]
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
Warning
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 model=yolo11n.pt imgsz=640 conf=0.25
✅yolo predict model yolo11n.pt imgsz 640 conf 0.25
❌yolo predict --model yolo11n.pt --imgsz 640 --conf 0.25
❌
Train
Train YOLO11n on the COCO8 dataset for 100 epochs at image size 640. For a full list of available arguments see the Configuration page.
Example
Val
Validate trained YOLO11n model accuracy on the COCO8 dataset. No arguments are needed as the model
retains its training data
and arguments as model attributes.
Example
Predict
Use a trained YOLO11n model to run predictions on images.
Example
Export
Export a YOLO11n model to a different format like ONNX, CoreML, etc.
Example
Available YOLO11 export formats are in the table below. You can export to any format using the format
argument, i.e. format='onnx'
or format='engine'
.
Format | format Argument | Model | Metadata | Arguments |
---|---|---|---|---|
PyTorch | - | yolo11n.pt | ✅ | - |
TorchScript | torchscript | yolo11n.torchscript | ✅ | imgsz , optimize , batch |
ONNX | onnx | yolo11n.onnx | ✅ | imgsz , half , dynamic , simplify , opset , batch |
OpenVINO | openvino | yolo11n_openvino_model/ | ✅ | imgsz , half , int8 , batch |
TensorRT | engine | yolo11n.engine | ✅ | imgsz , half , dynamic , simplify , workspace , int8 , batch |
CoreML | coreml | yolo11n.mlpackage | ✅ | imgsz , half , int8 , nms , batch |
TF SavedModel | saved_model | yolo11n_saved_model/ | ✅ | imgsz , keras , int8 , batch |
TF GraphDef | pb | yolo11n.pb | ❌ | imgsz , batch |
TF Lite | tflite | yolo11n.tflite | ✅ | imgsz , half , int8 , batch |
TF Edge TPU | edgetpu | yolo11n_edgetpu.tflite | ✅ | imgsz |
TF.js | tfjs | yolo11n_web_model/ | ✅ | imgsz , half , int8 , batch |
PaddlePaddle | paddle | yolo11n_paddle_model/ | ✅ | imgsz , batch |
MNN | mnn | yolo11n.mnn | ✅ | imgsz , batch , int8 , half |
NCNN | ncnn | yolo11n_ncnn_model/ | ✅ | imgsz , half , batch |
IMX500 | imx | yolo11n_imx_model/ | ✅ | imgsz , int8 |
See full export
details in the Export page.
Overriding default arguments
Default arguments can be overridden by simply passing them as arguments in the CLI in arg=value
pairs.
Tip
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:
FAQ
How do I use the Ultralytics YOLO11 command line interface (CLI) for model training?
To train a YOLO11 model using the CLI, you can execute a simple one-line command in the terminal. For example, to train a detection model for 10 epochs with a learning rate of 0.01, you would run:
This command uses the train
mode with specific arguments. Refer to the full list of available arguments in the Configuration Guide.
What tasks can I perform with the Ultralytics YOLO11 CLI?
The Ultralytics YOLO11 CLI supports a variety of tasks including detection, segmentation, classification, validation, prediction, export, and tracking. For instance:
- Train a Model: Run
yolo train data=<data.yaml> model=<model.pt> epochs=<num>
. - Run Predictions: Use
yolo predict model=<model.pt> source=<data_source> imgsz=<image_size>
. - Export a Model: Execute
yolo export model=<model.pt> format=<export_format>
.
Each task can be customized with various arguments. For detailed syntax and examples, see the respective sections like Train, Predict, and Export.
How can I validate the accuracy of a trained YOLO11 model using the CLI?
To validate a YOLO11 model's accuracy, use the val
mode. For example, to validate a pretrained detection model with a batch size of 1 and image size of 640, run:
This command evaluates the model on the specified dataset and provides performance metrics. For more details, refer to the Val section.
What formats can I export my YOLO11 models to using the CLI?
YOLO11 models can be exported to various formats such as ONNX, CoreML, TensorRT, and more. For instance, to export a model to ONNX format, run:
For complete details, visit the Export page.
How do I customize YOLO11 CLI commands to override default arguments?
To override default arguments in YOLO11 CLI commands, pass them as arg=value
pairs. For example, to train a model with custom arguments, use:
For a full list of available arguments and their descriptions, refer to the Configuration Guide. Ensure arguments are formatted correctly, as shown in the Overriding default arguments section.