CLI usage1. Download source code2. Use CLI prediction2.1. CLI usage syntax2.2, Image PredictionEffect preview3.3, Video predictionEffect preview3.4, Real-time predictionReferences
xxxxxxxxxx
git clone https://github.com/ultralytics/ultralytics.git
CLI (Command-Line Interface) is a way for users to interact with computers or software programs. Users run programs or perform tasks by typing text commands instead of clicking icons or buttons through a graphical user interface (GUI).
xxxxxxxxxx
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.
Use yolo11n.pt to predict the images provided by the ultralytics project: If the system does not find the corresponding model file in the directory where the command is run, it will automatically download it (if it cannot be downloaded, you can copy the model into it yourself)
Enter the project folder:
xxxxxxxxxx
cd /home/pi/ultralytics/ultralytics/
Use yolo11n.pt to detect the images in the target folder and output the results:
xxxxxxxxxx
yolo predict model=yolo11n source='/home/pi/ultralytics/ultralytics/assets'
Video location output by yolo recognition: /home/pi/ultralytics/ultralytics/runs/detect;
Each time it is run, the predict in this folder will automatically increase by 1
Use yolo11n.pt to predict videos under the ultralytics project (not the videos that come with ultralytics): If the system does not find the corresponding model file in the directory where the command is run, it will automatically download it (if it cannot be downloaded, you can copy the model into it yourself)
Enter the project folder:
xxxxxxxxxx
cd /home/pi/ultralytics/ultralytics
Use yolo11n.pt to detect the video in the target folder and output the result:
xxxxxxxxxx
yolo predict model=yolo11n source='/home/pi/ultralytics/ultralytics/videos'
Video location of yolo recognition output: /home/pi/ultralytics/ultralytics/runs/detect
Each time it runs, the predict under this folder automatically increases by 1
You can use the VLC application pre-installed on the Raspberry Pi to view the video
Use yolo11n.pt to predict the USB camera screen: If the system does not find the corresponding model file in the directory where the command is run, it will automatically download it (if it cannot be downloaded, you can copy the model yourself)
Enter the project folder:
xxxxxxxxxx
cd /home/pi/ultralytics/ultralytics
Use yolo11n.pt to detect the camera screen and output the results: Currently, only USB cameras can directly use CLI to predict real-time images. CSI cameras do not have relevant information that can be used directly as input sources
xxxxxxxxxx
yolo predict model=yolo11n.pt source=0 save=False show # Object detection
# Instance segmentation: yolo predict model=yolo11n-seg.pt source=0 save=False show
# Image classification: yolo predict model=yolo11n-cls.pt source=0 save=False show
# Pose estimation: yolo predict model=yolo11n-pose.pt source=0 save=False show
# Oriented object detection: yolo predict model=yolo11n-obb.pt source=0 save=False show
Click the terminal and press the "Ctrl + C" shortcut key to terminate the program!
Parameter Description
model
: Specify the YOLO model
source
: Specify the recognition source: multiple cameras can switch numbers
save=False
: Disable saving results
show
: Real-time display