Spaces:
Runtime error
Runtime error
File size: 1,133 Bytes
1ef0f8e |
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 39 40 41 42 43 44 |
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()
|