Spaces:
Runtime error
Runtime error
Update services/road_safety/pothole_crack_detection.py
Browse files
services/road_safety/pothole_crack_detection.py
CHANGED
@@ -4,7 +4,7 @@ from ultralytics import YOLO
|
|
4 |
from typing import List, Tuple, Dict, Any
|
5 |
|
6 |
# Load YOLOv8 model for pothole and crack detection
|
7 |
-
model = YOLO("models/yolov8n.pt")
|
8 |
|
9 |
def detect_potholes_and_cracks(frame: np.ndarray) -> Tuple[List[Dict[str, Any]], np.ndarray]:
|
10 |
"""
|
@@ -15,7 +15,7 @@ def detect_potholes_and_cracks(frame: np.ndarray) -> Tuple[List[Dict[str, Any]],
|
|
15 |
Tuple of (list of detections, annotated frame).
|
16 |
"""
|
17 |
# Perform inference
|
18 |
-
results = model(frame, classes=[0, 1], conf=0.5) #
|
19 |
|
20 |
detections = []
|
21 |
for i, r in enumerate(results[0].boxes):
|
|
|
4 |
from typing import List, Tuple, Dict, Any
|
5 |
|
6 |
# Load YOLOv8 model for pothole and crack detection
|
7 |
+
model = YOLO("models/yolov8n.pt")
|
8 |
|
9 |
def detect_potholes_and_cracks(frame: np.ndarray) -> Tuple[List[Dict[str, Any]], np.ndarray]:
|
10 |
"""
|
|
|
15 |
Tuple of (list of detections, annotated frame).
|
16 |
"""
|
17 |
# Perform inference
|
18 |
+
results = model(frame, classes=[0, 1], conf=0.5) # Class 0: pothole, Class 1: crack
|
19 |
|
20 |
detections = []
|
21 |
for i, r in enumerate(results[0].boxes):
|