Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,25 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def monitor_feed():
|
4 |
global frame_gen
|
5 |
try:
|
6 |
frame = next(frame_gen)
|
7 |
except StopIteration:
|
8 |
-
# Auto-restart video when finished
|
9 |
frame_gen = get_video_frame("data/drone_day.mp4")
|
10 |
frame = next(frame_gen)
|
11 |
|
12 |
temp_path = "temp.jpg"
|
13 |
cv2.imwrite(temp_path, frame)
|
14 |
|
15 |
-
if not os.path.exists(temp_path):
|
16 |
-
raise FileNotFoundError("Temp image not created!")
|
17 |
-
|
18 |
-
# 🛠️ Correct: pass temp_path (string) to detector
|
19 |
detections = detect_objects(temp_path)
|
20 |
thermal = detect_thermal_anomalies(temp_path)
|
21 |
shadow_flag = detect_shadow_coverage(temp_path)
|
@@ -27,4 +31,19 @@ def monitor_feed():
|
|
27 |
}
|
28 |
send_to_salesforce(alert_payload)
|
29 |
|
30 |
-
return frame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# Start the video generator
|
10 |
+
frame_gen = get_video_frame("data/drone_day.mp4")
|
11 |
|
12 |
def monitor_feed():
|
13 |
global frame_gen
|
14 |
try:
|
15 |
frame = next(frame_gen)
|
16 |
except StopIteration:
|
|
|
17 |
frame_gen = get_video_frame("data/drone_day.mp4")
|
18 |
frame = next(frame_gen)
|
19 |
|
20 |
temp_path = "temp.jpg"
|
21 |
cv2.imwrite(temp_path, frame)
|
22 |
|
|
|
|
|
|
|
|
|
23 |
detections = detect_objects(temp_path)
|
24 |
thermal = detect_thermal_anomalies(temp_path)
|
25 |
shadow_flag = detect_shadow_coverage(temp_path)
|
|
|
31 |
}
|
32 |
send_to_salesforce(alert_payload)
|
33 |
|
34 |
+
return frame
|
35 |
+
|
36 |
+
iface = gr.Interface(
|
37 |
+
fn=monitor_feed,
|
38 |
+
inputs=[],
|
39 |
+
outputs="image",
|
40 |
+
live=True,
|
41 |
+
title="Solar Surveillance Feed Simulation"
|
42 |
+
)
|
43 |
+
|
44 |
+
# ✅ Hugging Face specific launch
|
45 |
+
iface.launch(
|
46 |
+
server_name="0.0.0.0",
|
47 |
+
server_port=7860,
|
48 |
+
share=False
|
49 |
+
)
|