Spaces:
Sleeping
Sleeping
Create detector.py
Browse files- detector.py +11 -0
detector.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ultralytics import YOLO
|
2 |
+
import cv2
|
3 |
+
|
4 |
+
class LBWDetector:
|
5 |
+
def __init__(self, model_path='best.pt'):
|
6 |
+
self.model = YOLO(model_path)
|
7 |
+
|
8 |
+
def detect_objects(self, frame):
|
9 |
+
results = self.model.predict(source=frame, conf=0.3, save=False, verbose=False)
|
10 |
+
detections = results[0].boxes.data.cpu().numpy() # x1, y1, x2, y2, conf, class
|
11 |
+
return detections, results[0].names
|