SuriRaja commited on
Commit
f2f9a9a
·
1 Parent(s): 8db9899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -13,9 +13,11 @@ TEMP_IMAGE_PATH = "temp.jpg"
13
 
14
  def monitor_feed():
15
  frame = get_random_video_frame()
 
16
  if frame is None:
 
17
  return None, "No frame available", 0, 0
18
-
19
  # Save current frame
20
  cv2.imwrite(TEMP_IMAGE_PATH, frame)
21
 
@@ -34,12 +36,12 @@ def monitor_feed():
34
  if result_image is not None:
35
  cv2.imwrite(TEMP_IMAGE_PATH, result_image)
36
 
37
- # For metric panel
38
  anomaly_count = len([d for d in all_detections if d[4] != "normal"])
39
  total_count = len(all_detections)
40
 
41
  return TEMP_IMAGE_PATH, f"Detected {anomaly_count} anomalies", anomaly_count, total_count
42
 
 
43
  def build_interface():
44
  with gr.Blocks() as demo:
45
  with gr.Row():
 
13
 
14
  def monitor_feed():
15
  frame = get_random_video_frame()
16
+
17
  if frame is None:
18
+ # Safely return if no frame
19
  return None, "No frame available", 0, 0
20
+
21
  # Save current frame
22
  cv2.imwrite(TEMP_IMAGE_PATH, frame)
23
 
 
36
  if result_image is not None:
37
  cv2.imwrite(TEMP_IMAGE_PATH, result_image)
38
 
 
39
  anomaly_count = len([d for d in all_detections if d[4] != "normal"])
40
  total_count = len(all_detections)
41
 
42
  return TEMP_IMAGE_PATH, f"Detected {anomaly_count} anomalies", anomaly_count, total_count
43
 
44
+
45
  def build_interface():
46
  with gr.Blocks() as demo:
47
  with gr.Row():