To save the detected objects as cropped images, add the argument save_crop=True
to the inference command. To save the original image with plotted boxes on it, use the argument save=True
. The results will be saved to 'runs/detect/predict' or a similar folder (the exact path will be shown in the output).
from ultralytics import YOLO
license_plate_detector = YOLO('./model/best.pt')
license_plates = license_plate_detector('./42.jpg', save=True, save_crop=True)
You can specify where to save the output data using the parameters for project name project
and experiment name name
. To save all experiment results in the same folder use exist_ok=True
.
license_plates = license_plate_detector('./42.jpg', save=True, save_crop=True, project="runs/detect", name="inference", exist_ok=True)
# runs/detect/inference
More information about inference: https://docs.ultralytics.com/modes/predict/#inference-arguments