Sanjayraju30's picture
Update app.py
1ef0f8e verified
raw
history blame
1.13 kB
import gradio as gr
import os, sys
import cv2
# Ensure services is importable
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_generator = get_video_frame("data/sample_pole_video.mp4")
def detect_frame():
try:
frame = next(frame_generator)
temp_path = "temp.jpg"
cv2.imwrite(temp_path, frame)
objects = detect_objects(temp_path)
thermal = detect_thermal_anomalies(temp_path)
shadow = detect_shadow_coverage(temp_path)
alert = {
"detections": objects,
"thermal": bool(thermal),
"shadow_issue": shadow,
}
send_to_salesforce(alert)
return frame
except StopIteration:
return None
gr.Interface(
fn=detect_frame,
inputs=[],
outputs="image",
live=True,
title="VIEP Smart Pole Live Fault Detection"
).launch()