Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,23 @@
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
frame_gen = get_video_frame("data/drone_day.mp4")
|
2 |
|
3 |
def monitor_feed():
|
4 |
+
global frame_gen
|
5 |
try:
|
6 |
frame = next(frame_gen)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
except StopIteration:
|
8 |
+
# Auto-reload video when finished
|
9 |
+
frame_gen = get_video_frame("data/drone_day.mp4")
|
10 |
+
frame = next(frame_gen)
|
11 |
+
|
12 |
+
cv2.imwrite("temp.jpg", frame)
|
13 |
+
detections = detect_objects("temp.jpg")
|
14 |
+
thermal = detect_thermal_anomalies("temp.jpg")
|
15 |
+
shadow_flag = detect_shadow_coverage("temp.jpg")
|
16 |
|
17 |
+
alert_payload = {
|
18 |
+
"detections": detections,
|
19 |
+
"thermal": bool(thermal),
|
20 |
+
"shadow_issue": shadow_flag,
|
21 |
+
}
|
22 |
+
send_to_salesforce(alert_payload)
|
23 |
+
return frame
|