DSatishchandra commited on
Commit
7b0883c
Β·
verified Β·
1 Parent(s): 8f1b390

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -43,7 +43,7 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
43
  video_path = VIDEO_PATHS.get(video_type)
44
  print(f"Selected video path: {video_path}")
45
  if not video_path or not os.path.exists(video_path):
46
- print("Video file not found or path is incorrect.")
47
  yield gr.update(value="Video file not found."), None, None, None, None, None, None
48
  return
49
 
@@ -66,17 +66,24 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
66
  # Perform detection based on video type
67
  if video_type == "Thermal Feed":
68
  detections = thermal_service.detect_hotspots(frame_pil, detection_service, confidence_threshold)
 
69
  alert_type = "Overheating"
70
  elif video_type == "Shadow/Dust Feed":
71
  detections = shadow_detection.detect_shadow_dust(frame_pil, detection_service, confidence_threshold)
 
72
  alert_type = "Shadow/Dust"
73
  else:
74
  detections = detection_service.detect_objects(frame_pil, confidence_threshold)
 
75
  alert_type = "General"
76
 
77
  # Draw detections on frame
78
  annotated_frame = video_service.draw_detections(frame, detections)
79
  annotated_frame_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)
 
 
 
 
80
 
81
  # Update state
82
  num_anomalies = len(detections)
@@ -140,14 +147,15 @@ def live_feed_generator(video_type, confidence_threshold=0.9):
140
 
141
  # Yield updated UI components
142
  yield (
143
- gr.update(value=annotated_frame_rgb), # Live Video Feed
144
- gr.update(value=metrics_str), # Live Metrics
145
- gr.update(value="\n".join(state.logs)), # Live Logs
146
- gr.update(value=trend_plot), # Detection Trend
147
- gr.update(value=anomaly_types_str), # Anomaly Types
148
- gr.update(value=list(state.captured_events)), # Captured Events
149
- gr.update(value=timestamp_str) # Timestamp
150
- )
 
151
 
152
  # Simulate real-time by sleeping between frames
153
  time.sleep(frame_interval)
 
43
  video_path = VIDEO_PATHS.get(video_type)
44
  print(f"Selected video path: {video_path}")
45
  if not video_path or not os.path.exists(video_path):
46
+ print("Video file not found or path is incorrect.")
47
  yield gr.update(value="Video file not found."), None, None, None, None, None, None
48
  return
49
 
 
66
  # Perform detection based on video type
67
  if video_type == "Thermal Feed":
68
  detections = thermal_service.detect_hotspots(frame_pil, detection_service, confidence_threshold)
69
+ print(f"Detections for Frame {state.frame_count}: {detections}")
70
  alert_type = "Overheating"
71
  elif video_type == "Shadow/Dust Feed":
72
  detections = shadow_detection.detect_shadow_dust(frame_pil, detection_service, confidence_threshold)
73
+ print(f"Detections for Frame {state.frame_count}: {detections}")
74
  alert_type = "Shadow/Dust"
75
  else:
76
  detections = detection_service.detect_objects(frame_pil, confidence_threshold)
77
+ print(f"Detections for Frame {state.frame_count}: {detections}")
78
  alert_type = "General"
79
 
80
  # Draw detections on frame
81
  annotated_frame = video_service.draw_detections(frame, detections)
82
  annotated_frame_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)
83
+ cv2.imshow("Debug Frame", annotated_frame_rgb)
84
+ cv2.waitKey(1)
85
+
86
+ print(f"Annotated frame shape: {annotated_frame_rgb.shape}")
87
 
88
  # Update state
89
  num_anomalies = len(detections)
 
147
 
148
  # Yield updated UI components
149
  yield (
150
+ annotated_frame_rgb,
151
+ metrics_str,
152
+ "\n".join(state.logs),
153
+ trend_plot,
154
+ anomaly_types_str,
155
+ list(state.captured_events),
156
+ timestamp_str
157
+ )
158
+
159
 
160
  # Simulate real-time by sleeping between frames
161
  time.sleep(frame_interval)