你可能用了这套代码:
from ultralytics import YOLO# Load a pretrained YOLOv8n model
model = YOLO('./best.pt')# Define path to video file
source = r".\WeChat_20240515193007.mp4"# Run inference on the source
results = model(source, stream=True) # generator of Results objects
这套代码它把结果放到了results中 但没有保存。
正确代码:
from ultralytics import YOLO# Load a pretrained YOLOv8n model
model = YOLO(r"./best.pt")# Run inference on 'bus.jpg' with arguments
model.predict(r"./p1_rgb.mp4", save=True, imgsz=320, conf=0.5)