Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,34 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
from
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
return results
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
title="VIEP Smart Pole Fault Detection",
|
14 |
-
description="Upload a surveillance image to detect faults like intrusion, overheating, or dust/shade issues."
|
15 |
-
)
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
from services.video_service import get_video_frame
|
4 |
+
from services.detection_service import detect_objects
|
5 |
+
from services.thermal_service import detect_thermal_anomalies
|
6 |
+
from services.shadow_detection import detect_shadow_coverage
|
7 |
+
from services.salesforce_dispatcher import send_to_salesforce
|
8 |
|
9 |
+
# Video generator
|
10 |
+
frame_gen = get_video_frame("data/sample_pole_video.mp4")
|
|
|
11 |
|
12 |
+
def monitor_feed():
|
13 |
+
try:
|
14 |
+
frame = next(frame_gen)
|
15 |
+
cv2.imwrite("temp.jpg", frame)
|
|
|
|
|
|
|
16 |
|
17 |
+
detections = detect_objects("temp.jpg")
|
18 |
+
thermal = detect_thermal_anomalies("temp.jpg")
|
19 |
+
shadow_flag = detect_shadow_coverage("temp.jpg")
|
20 |
+
|
21 |
+
alert_payload = {
|
22 |
+
"detections": detections,
|
23 |
+
"thermal": bool(thermal),
|
24 |
+
"shadow_issue": shadow_flag,
|
25 |
+
}
|
26 |
+
|
27 |
+
send_to_salesforce(alert_payload)
|
28 |
+
|
29 |
+
return frame
|
30 |
+
except StopIteration:
|
31 |
+
return None
|
32 |
+
|
33 |
+
iface = gr.Interface(fn=monitor_feed, inputs=[], outputs="image", live=True, title="VIEP Smart Pole Video Fault Detector")
|
34 |
+
iface.launch()
|