Spaces:
Runtime error
Runtime error
File size: 1,455 Bytes
1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 1ef0f8e a070fb2 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 45 46 47 48 49 50 51 52 53 54 55 56 |
import gradio as gr
import cv2
import os
import sys
# Add services path
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
# Initialize video reader from sample video
frame_generator = get_video_frame("data/sample_pole_video.mp4")
def detect_faults():
try:
frame = next(frame_generator)
if frame is None:
return None # Gradio will skip frame
# Save temporary frame
temp_path = "temp.jpg"
cv2.imwrite(temp_path, frame)
# Fault detection
intrusion = detect_objects(temp_path)
thermal = detect_thermal_anomalies(temp_path)
shadow = detect_shadow_coverage(temp_path)
# Print for debugging
print("Intrusion:", intrusion)
print("Thermal:", thermal)
print("Shadow:", shadow)
# Send to Salesforce mock
send_to_salesforce({
"detections": intrusion,
"thermal": thermal,
"shadow_issue": shadow
})
return frame
except StopIteration:
return None
gr.Interface(
fn=detect_faults,
inputs=[],
outputs="image",
title="VIEP Live Fault Detection (Simulated)",
live=True
).launch()
|