Spaces:
Runtime error
Runtime error
Create fault_service.py
Browse files- services/fault_service.py +11 -0
services/fault_service.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ultralytics import YOLO
|
2 |
+
|
3 |
+
fault_model = YOLO("pole_fault_model.pt")
|
4 |
+
|
5 |
+
def detect_pole_faults(image_path):
|
6 |
+
results = fault_model(image_path)
|
7 |
+
flagged = []
|
8 |
+
for r in results:
|
9 |
+
if hasattr(r, 'fault_type') and r.conf > 0.6:
|
10 |
+
flagged.append({"fault_type": r.fault_type, "confidence": r.conf})
|
11 |
+
return flagged
|