File size: 577 Bytes
2012550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4eed331
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from ultralytics import YOLO
from .base import DetectionModel

class YOLOFaceDetector(DetectionModel):
    def __init__(self, model_path="src/data/models/face_detection_model.pt"):
        self.model = YOLO(model_path)
        
    def detect(self, frame):
        results = self.model(frame, verbose=False)[0]
        detections = []
        
        for box in results.boxes:
            x1, y1, x2, y2 = box.xyxy[0].cpu().numpy()
            conf = box.conf[0].cpu().numpy()
            detections.append([int(x1), int(y1), int(x2), int(y2), conf])
        return detections