Sanjayraju30 commited on
Commit
b84252e
·
verified ·
1 Parent(s): 0fb01ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -1,18 +1,34 @@
1
  import gradio as gr
2
- from utils.detector import detect_faults
3
- from PIL import Image
 
 
 
 
4
 
5
- def analyze_image(image):
6
- results = detect_faults(image)
7
- return results
8
 
9
- demo = gr.Interface(
10
- fn=analyze_image,
11
- inputs=gr.Image(type="pil"),
12
- outputs="json",
13
- title="VIEP Smart Pole Fault Detection",
14
- description="Upload a surveillance image to detect faults like intrusion, overheating, or dust/shade issues."
15
- )
16
 
17
- if __name__ == "__main__":
18
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import cv2
3
+ from services.video_service import get_video_frame
4
+ from services.detection_service import detect_objects
5
+ from services.thermal_service import detect_thermal_anomalies
6
+ from services.shadow_detection import detect_shadow_coverage
7
+ from services.salesforce_dispatcher import send_to_salesforce
8
 
9
+ # Video generator
10
+ frame_gen = get_video_frame("data/sample_pole_video.mp4")
 
11
 
12
+ def monitor_feed():
13
+ try:
14
+ frame = next(frame_gen)
15
+ cv2.imwrite("temp.jpg", frame)
 
 
 
16
 
17
+ detections = detect_objects("temp.jpg")
18
+ thermal = detect_thermal_anomalies("temp.jpg")
19
+ shadow_flag = detect_shadow_coverage("temp.jpg")
20
+
21
+ alert_payload = {
22
+ "detections": detections,
23
+ "thermal": bool(thermal),
24
+ "shadow_issue": shadow_flag,
25
+ }
26
+
27
+ send_to_salesforce(alert_payload)
28
+
29
+ return frame
30
+ except StopIteration:
31
+ return None
32
+
33
+ iface = gr.Interface(fn=monitor_feed, inputs=[], outputs="image", live=True, title="VIEP Smart Pole Video Fault Detector")
34
+ iface.launch()