Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
frame_gen = get_video_frame("data/drone_day.mp4")
|
10 |
+
|
11 |
+
def monitor_feed():
|
12 |
+
try:
|
13 |
+
frame = next(frame_gen)
|
14 |
+
cv2.imwrite("temp.jpg", frame)
|
15 |
+
detections = detect_objects("temp.jpg")
|
16 |
+
thermal = detect_thermal_anomalies("temp.jpg")
|
17 |
+
shadow_flag = detect_shadow_coverage("temp.jpg")
|
18 |
+
|
19 |
+
alert_payload = {
|
20 |
+
"detections": detections,
|
21 |
+
"thermal": bool(thermal),
|
22 |
+
"shadow_issue": shadow_flag,
|
23 |
+
}
|
24 |
+
send_to_salesforce(alert_payload)
|
25 |
+
return frame
|
26 |
+
except StopIteration:
|
27 |
+
return None
|
28 |
+
|
29 |
+
iface = gr.Interface(fn=monitor_feed, inputs=[], outputs="image", live=True, title="Solar Surveillance Feed Simulation")
|
30 |
+
iface.launch()
|