Sanjayraju30 commited on
Commit
6076bdd
·
verified ·
1 Parent(s): 30b1c77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -2,20 +2,22 @@ import gradio as gr
2
  import os, sys
3
  import cv2
4
 
5
- # Ensure services is importable
6
  sys.path.append(os.path.join(os.path.dirname(__file__), "services"))
7
 
8
- from video_service import get_video_frame
9
  from detection_service import detect_objects
10
  from thermal_service import detect_thermal_anomalies
11
  from shadow_detection import detect_shadow_coverage
12
  from salesforce_dispatcher import send_to_salesforce
13
 
14
- frame_generator = get_video_frame("data/sample_pole_video.mp4")
 
 
15
 
16
- def detect_frame():
17
  try:
18
- frame = next(frame_generator)
19
  temp_path = "temp.jpg"
20
  cv2.imwrite(temp_path, frame)
21
 
@@ -35,9 +37,11 @@ def detect_frame():
35
  return None
36
 
37
  gr.Interface(
38
- fn=detect_frame,
39
  inputs=[],
40
  outputs="image",
41
  live=True,
42
- title="VIEP Smart Pole Live Fault Detection"
 
43
  ).launch()
 
 
2
  import os, sys
3
  import cv2
4
 
5
+ # Add 'services' folder to Python path
6
  sys.path.append(os.path.join(os.path.dirname(__file__), "services"))
7
 
8
+ from video_service import get_live_frame
9
  from detection_service import detect_objects
10
  from thermal_service import detect_thermal_anomalies
11
  from shadow_detection import detect_shadow_coverage
12
  from salesforce_dispatcher import send_to_salesforce
13
 
14
+ # 🔁 Live stream: Use webcam (0) or RTSP stream
15
+ cap = cv2.VideoCapture(0) # Replace 0 with RTSP URL if needed
16
+ frame_gen = get_live_frame(cap)
17
 
18
+ def detect_live_faults():
19
  try:
20
+ frame = next(frame_gen)
21
  temp_path = "temp.jpg"
22
  cv2.imwrite(temp_path, frame)
23
 
 
37
  return None
38
 
39
  gr.Interface(
40
+ fn=detect_live_faults,
41
  inputs=[],
42
  outputs="image",
43
  live=True,
44
+ title="📡 VIEP Live Smart Pole Fault Detection",
45
+ description="Live AI detection of faults like overheating, intrusion, and shadow coverage."
46
  ).launch()
47
+