Spaces:
Runtime error
Runtime error
File size: 1,128 Bytes
581110e b84252e a144441 09239d2 b84252e 09239d2 b84252e 8055941 b84252e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
import cv2
import os, sys
# ✅ Fix: Add services/ to path manually
sys.path.append(os.path.join(os.path.dirname(__file__), "services"))
from video_service import get_video_frame
from detection_service import detect_objects
from thermal_service import detect_thermal_anomalies
from shadow_detection import detect_shadow_coverage
from salesforce_dispatcher import send_to_salesforce
frame_gen = get_video_frame("data/sample_pole_video.mp4")
def monitor_feed():
try:
frame = next(frame_gen)
cv2.imwrite("temp.jpg", frame)
detections = detect_objects("temp.jpg")
thermal = detect_thermal_anomalies("temp.jpg")
shadow_flag = detect_shadow_coverage("temp.jpg")
alert_payload = {
"detections": detections,
"thermal": bool(thermal),
"shadow_issue": shadow_flag,
}
send_to_salesforce(alert_payload)
return frame
except StopIteration:
return None
iface = gr.Interface(fn=monitor_feed, inputs=[], outputs="image", live=True, title="VIEP Smart Pole Video Fault Detector")
iface.launch()
|