kangda_robotic_dog/机器狗后台服务/app/util/yolov8Obj.py
2025-08-20 09:24:06 +08:00

18 lines
462 B
Python

from ultralytics import YOLO
from app.config.config import yolov8_settings
class Yolov8Obj:
def __init__(self):
self.model = YOLO(yolov8_settings.YOLOV8_MODEL_DIR)
def detect(self, image_path):
result = self.model.predict(image_path)
boxes = result[0].boxes
cls = boxes.cls.tolist()
conf = boxes.conf.tolist()
coords = boxes.xyxy.tolist()
return cls, conf, coords