Update app.py
Browse files
app.py
CHANGED
@@ -26,6 +26,16 @@ Please note that the following list of image descriptions (visual details) was o
|
|
26 |
Audio events are actually the entire scene description based only on the audio of the video. Your job is to integrate these multimodal inputs intelligently and provide a very short resume about what is happening in the origin video. Provide a succinct overview of what you understood.
|
27 |
"""
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def extract_frames(video_in, interval=24, output_format='.jpg'):
|
30 |
"""Extract frames from a video at a specified interval and store them in a list.
|
31 |
|
@@ -190,11 +200,17 @@ with gr.Blocks(css=css) as demo :
|
|
190 |
<h2 style="text-align: center;">Soft video understanding</h2>
|
191 |
""")
|
192 |
video_in = gr.Video(label="Video input")
|
|
|
193 |
submit_btn = gr.Button("Submit")
|
194 |
video_description = gr.Textbox(label="Video description", elem_id="video-text")
|
|
|
|
|
|
|
|
|
|
|
195 |
submit_btn.click(
|
196 |
fn = infer,
|
197 |
-
inputs = [
|
198 |
outputs = [video_description]
|
199 |
)
|
200 |
demo.queue().launch()
|
|
|
26 |
Audio events are actually the entire scene description based only on the audio of the video. Your job is to integrate these multimodal inputs intelligently and provide a very short resume about what is happening in the origin video. Provide a succinct overview of what you understood.
|
27 |
"""
|
28 |
|
29 |
+
def trim_video(input_path, output_path, max_duration=10):
|
30 |
+
video_clip = VideoFileClip(input_path)
|
31 |
+
|
32 |
+
if video_clip.duration > max_duration:
|
33 |
+
trimmed_clip = video_clip.subclip(0, max_duration)
|
34 |
+
trimmed_clip.write_videofile(output_path, audio_codec='aac')
|
35 |
+
return output_path
|
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 |
|
|
|
200 |
<h2 style="text-align: center;">Soft video understanding</h2>
|
201 |
""")
|
202 |
video_in = gr.Video(label="Video input")
|
203 |
+
video_cut = gr.Video(label="Video cut")
|
204 |
submit_btn = gr.Button("Submit")
|
205 |
video_description = gr.Textbox(label="Video description", elem_id="video-text")
|
206 |
+
video_in.upload(
|
207 |
+
fn = trim_video,
|
208 |
+
inputs = [video_in],
|
209 |
+
outputs = [video_cut]
|
210 |
+
)
|
211 |
submit_btn.click(
|
212 |
fn = infer,
|
213 |
+
inputs = [video_cut],
|
214 |
outputs = [video_description]
|
215 |
)
|
216 |
demo.queue().launch()
|