Load the trained target detection YOLOv8, v5, v3, v6 models, put a box on the object in a picture in the data set, mark the category, and save the picture locally

Reference tutorial: Python - Ultralytics YOLOv8 Docs

Create a new predict.py at the same level as the ultralytics code

 Write the following content inside. just run

from ultralytics import YOLO
from PIL import Image
import cv2

# 加载计划使用的模型
model = YOLO("yolov8n.pt")  # load a pretrained model (recommended for training)

# 加载被标注的照片
im1 = Image.open("bus.jpg")

# 完成标注并保存到本地
results = model.predict(source=[im1], save=True)  # save plotted images
# results = model.predict(source=[im1], save=True)  # save plotted images

print(results)

 

Guess you like

Origin blog.csdn.net/Albert233333/article/details/131951431