Spaces:
Sleeping
Sleeping
Update detector.py
Browse files- detector.py +2 -2
detector.py
CHANGED
|
@@ -2,12 +2,12 @@ from ultralytics import YOLO
|
|
| 2 |
import cv2
|
| 3 |
import torch
|
| 4 |
import torch.serialization
|
| 5 |
-
import ultralytics # Required to access ultralytics
|
| 6 |
|
| 7 |
class LBWDetector:
|
| 8 |
def __init__(self, model_path='best.pt'):
|
| 9 |
"""Initialize YOLO model with safe globals for PyTorch 2.6+."""
|
| 10 |
-
with torch.serialization.safe_globals([torch.nn.modules.container.Sequential, ultralytics.nn.tasks.DetectionModel, ultralytics.nn.modules.conv.Conv]):
|
| 11 |
self.model = YOLO(model_path)
|
| 12 |
|
| 13 |
def detect_objects(self, frame):
|
|
|
|
| 2 |
import cv2
|
| 3 |
import torch
|
| 4 |
import torch.serialization
|
| 5 |
+
import ultralytics # Required to access ultralytics-specific classes
|
| 6 |
|
| 7 |
class LBWDetector:
|
| 8 |
def __init__(self, model_path='best.pt'):
|
| 9 |
"""Initialize YOLO model with safe globals for PyTorch 2.6+."""
|
| 10 |
+
with torch.serialization.safe_globals([torch.nn.modules.container.Sequential, ultralytics.nn.tasks.DetectionModel, ultralytics.nn.modules.conv.Conv, torch.nn.modules.conv.Conv2d]):
|
| 11 |
self.model = YOLO(model_path)
|
| 12 |
|
| 13 |
def detect_objects(self, frame):
|