18 lines
462 B
Python
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 |