reab5555 commited on
Commit
69dc1f7
·
verified ·
1 Parent(s): 7f942f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -57,9 +57,14 @@ def process_video(video_path, target, progress=gr.Progress()):
57
  return None, f"Error: Unable to open video file at {video_path}"
58
 
59
  frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
 
 
 
60
  processed_frames = []
 
61
 
62
- for frame in progress.tqdm(range(frame_count)):
 
63
  ret, img = cap.read()
64
  if not ret:
65
  break
@@ -84,7 +89,7 @@ def load_sample_frame(video_path):
84
 
85
  def gradio_app():
86
  with gr.Blocks() as app:
87
- gr.Markdown("# Video Object Detection with Owlv2")
88
 
89
  video_input = gr.Video(label="Upload Video")
90
  target_input = gr.Textbox(label="Target Object", value="Elephant")
 
57
  return None, f"Error: Unable to open video file at {video_path}"
58
 
59
  frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
60
+ original_fps = int(cap.get(cv2.CAP_PROP_FPS))
61
+ output_fps = 3
62
+
63
  processed_frames = []
64
+ frame_interval = max(1, round(original_fps / output_fps))
65
 
66
+ for frame in progress.tqdm(range(0, frame_count, frame_interval)):
67
+ cap.set(cv2.CAP_PROP_POS_FRAMES, frame)
68
  ret, img = cap.read()
69
  if not ret:
70
  break
 
89
 
90
  def gradio_app():
91
  with gr.Blocks() as app:
92
+ gr.Markdown("# Video Object Detection with Owlv2 (3 FPS)")
93
 
94
  video_input = gr.Video(label="Upload Video")
95
  target_input = gr.Textbox(label="Target Object", value="Elephant")