Sanjayraju30's picture
Update app.py
b84252e verified
raw
history blame
1.06 kB
import gradio as gr
import cv2
from services.video_service import get_video_frame
from services.detection_service import detect_objects
from services.thermal_service import detect_thermal_anomalies
from services.shadow_detection import detect_shadow_coverage
from services.salesforce_dispatcher import send_to_salesforce
# Video generator
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()