fffiloni commited on
Commit
2c12515
1 Parent(s): 24987c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -36,7 +36,14 @@ def trim_video(input_path, max_duration=10):
36
  else:
37
  return input_path
38
 
39
- def extract_frames(video_in, interval=24, output_format='.jpg'):
 
 
 
 
 
 
 
40
  """Extract frames from a video at a specified interval and store them in a list.
41
 
42
  Args:
@@ -209,16 +216,23 @@ with gr.Blocks(css=css) as demo :
209
  <h2 style="text-align: center;">Soft video understanding</h2>
210
  """)
211
  with gr.Row():
212
- video_in = gr.Video(label="Video input")
213
  with gr.Column():
214
- video_cut = gr.Video(label="Video cut to 10 seconds")
 
 
 
 
 
 
 
215
  submit_btn = gr.Button("Submit")
216
  video_description = gr.Textbox(label="Video description", elem_id="video-text")
217
 
218
  video_in.upload(
219
  fn = trim_video,
220
  inputs = [video_in],
221
- outputs = [video_cut]
 
222
  )
223
  submit_btn.click(
224
  fn = infer,
 
36
  else:
37
  return input_path
38
 
39
+ def extract_frames(video_in, output_format='.jpg'):
40
+ # Adjust interval to video length
41
+ video_clip = VideoFileClip(video_in)
42
+ if video_clip.duration <= 5:
43
+ interval = 12
44
+ else :
45
+ interval = 24
46
+
47
  """Extract frames from a video at a specified interval and store them in a list.
48
 
49
  Args:
 
216
  <h2 style="text-align: center;">Soft video understanding</h2>
217
  """)
218
  with gr.Row():
 
219
  with gr.Column():
220
+ video_in = gr.Video(label="Video input")
221
+ with gr.Accordion("System Instructions", open=False):
222
+ system_instruction = gr.Textbox(
223
+ value= standard_sys,
224
+ interactive = False
225
+ )
226
+ with gr.Column():
227
+ video_cut = gr.Video(label="Video cut to 10 seconds", interactive=False)
228
  submit_btn = gr.Button("Submit")
229
  video_description = gr.Textbox(label="Video description", elem_id="video-text")
230
 
231
  video_in.upload(
232
  fn = trim_video,
233
  inputs = [video_in],
234
+ outputs = [video_cut],
235
+ queue = False
236
  )
237
  submit_btn.click(
238
  fn = infer,