Spaces:
Runtime error
Runtime error
Update inference_utils.py
Browse files- inference_utils.py +9 -3
inference_utils.py
CHANGED
|
@@ -8,7 +8,9 @@ from paddleocr import PaddleOCR
|
|
| 8 |
from difflib import get_close_matches
|
| 9 |
|
| 10 |
from huggingface_hub import hf_hub_download
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
# Download to local cache
|
| 13 |
|
| 14 |
|
|
@@ -18,11 +20,15 @@ def load_models():
|
|
| 18 |
# vehicle_classifier = YOLO("https://huggingface.co/Prabhat51/number-plate-models/blob/main/veh_class.pt")
|
| 19 |
# plate_detector = YOLO("https://huggingface.co/Prabhat51/number-plate-models/blob/main/plate_detect.pt")
|
| 20 |
veh_detect_path = hf_hub_download(repo_id="Prabhat51/number-plate-models", filename="veh_detect.pt")
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
vehicle_classifier_path = hf_hub_download(repo_id="Prabhat51/number-plate-models", filename="veh_class.pt")
|
| 23 |
vehicle_classifier = YOLO(vehicle_classifier_path)
|
| 24 |
plate_detector_path = hf_hub_download(repo_id="Prabhat51/number-plate-models", filename="plate_detect.pt")
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
ocr_reader = PaddleOCR(use_angle_cls=True, lang='en')
|
| 27 |
return vehicle_detector, vehicle_classifier, plate_detector, ocr_reader
|
| 28 |
|
|
|
|
| 8 |
from difflib import get_close_matches
|
| 9 |
|
| 10 |
from huggingface_hub import hf_hub_download
|
| 11 |
+
from torch.serialization import safe_globals
|
| 12 |
+
from ultralytics.nn.tasks import DetectionModel
|
| 13 |
+
from ultralytics import YOLO
|
| 14 |
# Download to local cache
|
| 15 |
|
| 16 |
|
|
|
|
| 20 |
# vehicle_classifier = YOLO("https://huggingface.co/Prabhat51/number-plate-models/blob/main/veh_class.pt")
|
| 21 |
# plate_detector = YOLO("https://huggingface.co/Prabhat51/number-plate-models/blob/main/plate_detect.pt")
|
| 22 |
veh_detect_path = hf_hub_download(repo_id="Prabhat51/number-plate-models", filename="veh_detect.pt")
|
| 23 |
+
with safe_globals([DetectionModel]):
|
| 24 |
+
vehicle_detector = YOLO(veh_detect_path)
|
| 25 |
+
# vehicle_detector = YOLO(veh_detect_path)
|
| 26 |
vehicle_classifier_path = hf_hub_download(repo_id="Prabhat51/number-plate-models", filename="veh_class.pt")
|
| 27 |
vehicle_classifier = YOLO(vehicle_classifier_path)
|
| 28 |
plate_detector_path = hf_hub_download(repo_id="Prabhat51/number-plate-models", filename="plate_detect.pt")
|
| 29 |
+
with safe_globals([DetectionModel]):
|
| 30 |
+
vehicle_detector = YOLO(plate_detector_path)
|
| 31 |
+
# plate_detector = YOLO(plate_detector_path)
|
| 32 |
ocr_reader = PaddleOCR(use_angle_cls=True, lang='en')
|
| 33 |
return vehicle_detector, vehicle_classifier, plate_detector, ocr_reader
|
| 34 |
|