nn commited on
Commit
bba1d3f
·
verified ·
1 Parent(s): fe2f102

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -39,9 +39,11 @@ def read_yolo_boxes(file_path):
39
  with open(file_path, 'r') as f:
40
  for line in f:
41
  parts = line.strip().split()
42
- class_name = COCO_CLASSES[int(parts[0])]
43
- x, y, w, h = map(float, parts[1:5])
44
- boxes.append((class_name, x, y, w, h))
 
 
45
  return boxes
46
 
47
  def yolo_to_pixel_coord(x, y, img_width, img_height):
@@ -334,7 +336,7 @@ with gr.Blocks(title="Two-Step Train Obstruction Detection") as iface:
334
  with gr.Tab("Step 2: Object Detection"):
335
  object_input = gr.Image(type="numpy", label="Upload image for object detection")
336
  video_input = gr.Video(label="Or upload video for object detection")
337
- frame_skip = gr.Slider(minimum=1, maximum=30, step=1, value=15, label="Frame Skip Rate (for video)")
338
  object_output = gr.Plot(label="Object Detection Result (Image)")
339
  video_output = gr.Video(label="Object Detection Result (Video)")
340
  object_message = gr.Textbox(label="Object Detection Results")
 
39
  with open(file_path, 'r') as f:
40
  for line in f:
41
  parts = line.strip().split()
42
+ class_id = int(parts[0])
43
+ if COCO_CLASSES[class_id] != 'traffic light': # Skip traffic lights
44
+ class_name = COCO_CLASSES[class_id]
45
+ x, y, w, h = map(float, parts[1:5])
46
+ boxes.append((class_name, x, y, w, h))
47
  return boxes
48
 
49
  def yolo_to_pixel_coord(x, y, img_width, img_height):
 
336
  with gr.Tab("Step 2: Object Detection"):
337
  object_input = gr.Image(type="numpy", label="Upload image for object detection")
338
  video_input = gr.Video(label="Or upload video for object detection")
339
+ frame_skip = gr.Slider(minimum=1, maximum=100, step=1, value=15, label="Frame Skip Rate (for video)")
340
  object_output = gr.Plot(label="Object Detection Result (Image)")
341
  video_output = gr.Video(label="Object Detection Result (Video)")
342
  object_message = gr.Textbox(label="Object Detection Results")