fffiloni commited on
Commit
44284c4
·
verified ·
1 Parent(s): bc31078

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -88,8 +88,19 @@ def image_vision(image_input_path, prompt):
88
  else:
89
  return answer, None
90
 
91
- def video_vision(video_input_path, prompt):
92
- vid_frames, image_paths = read_video(video_input_path, video_interval=1)
 
 
 
 
 
 
 
 
 
 
 
93
  # create a question (<image> is a placeholder for the video frames)
94
  question = f"<image>{prompt}"
95
  result = model.predict_forward(
@@ -179,6 +190,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
179
  with gr.Row():
180
  with gr.Column():
181
  video_input = gr.Video(label="Video IN")
 
182
  with gr.Row():
183
  vid_instruction = gr.Textbox(label="Instruction", scale=4)
184
  submit_video_btn = gr.Button("Submit", scale=1)
@@ -188,7 +200,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
188
 
189
  submit_video_btn.click(
190
  fn = video_vision,
191
- inputs = [video_input, vid_instruction],
192
  outputs = [vid_output_res, output_video]
193
  )
194
 
 
88
  else:
89
  return answer, None
90
 
91
+ def video_vision(video_input_path, prompt, video_interval):
92
+ # Open the original video
93
+ cap = cv2.VideoCapture(input_video_path)
94
+
95
+ # Get original video properties
96
+ original_fps = cap.get(cv2.CAP_PROP_FPS)
97
+
98
+ frame_skip_factor = video_interval
99
+
100
+ # Calculate new FPS
101
+ new_fps = original_fps / frame_skip_factor
102
+
103
+ vid_frames, image_paths = read_video(video_input_path, video_interval)
104
  # create a question (<image> is a placeholder for the video frames)
105
  question = f"<image>{prompt}"
106
  result = model.predict_forward(
 
190
  with gr.Row():
191
  with gr.Column():
192
  video_input = gr.Video(label="Video IN")
193
+ frame_interval = gr.Slider(label="Frame interval", minimum=1, maximum=12, value=6)
194
  with gr.Row():
195
  vid_instruction = gr.Textbox(label="Instruction", scale=4)
196
  submit_video_btn = gr.Button("Submit", scale=1)
 
200
 
201
  submit_video_btn.click(
202
  fn = video_vision,
203
+ inputs = [video_input, vid_instruction, frame_interval],
204
  outputs = [vid_output_res, output_video]
205
  )
206