Spaces:
Sleeping
Sleeping
Update detect_bubbles.py
Browse files- detect_bubbles.py +3 -1
detect_bubbles.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
| 1 |
from ultralytics import YOLO
|
| 2 |
import torch
|
| 3 |
|
|
|
|
|
|
|
| 4 |
def safe_load_model(model_path):
|
| 5 |
"""
|
| 6 |
Manually loads the YOLO model weights with 'weights_only' set to False
|
| 7 |
to avoid the security check issue with PyTorch.
|
| 8 |
"""
|
| 9 |
-
model = YOLO(model_path)
|
| 10 |
return model
|
| 11 |
|
| 12 |
def detect_bubbles(model_path, image_path):
|
|
|
|
| 1 |
from ultralytics import YOLO
|
| 2 |
import torch
|
| 3 |
|
| 4 |
+
torch.serialization.add_safe_globals([YOLO, 'DetectionModel'])
|
| 5 |
+
|
| 6 |
def safe_load_model(model_path):
|
| 7 |
"""
|
| 8 |
Manually loads the YOLO model weights with 'weights_only' set to False
|
| 9 |
to avoid the security check issue with PyTorch.
|
| 10 |
"""
|
| 11 |
+
model = YOLO(model_path, weights_only=False)
|
| 12 |
return model
|
| 13 |
|
| 14 |
def detect_bubbles(model_path, image_path):
|