Spaces:
Sleeping
Sleeping
import gradio as gr | |
from utils import get_youtube | |
from model import summarize_video | |
root_dir = '/home/user/app/video' | |
# ---- Gradio Layout ----- | |
youtube_url_in = gr.Textbox(label="Youtube url", lines=1, interactive=True) | |
video_in = gr.Video(label="Input Video", mirror_webcam=False, interactive=True) | |
video_out = gr.Video(label="Output Video") | |
summary_text = gr.Textbox(label="Video Transcription Summary") | |
transcription_text = gr.HTML(label="Full Transcription") | |
demo = gr.Blocks() | |
demo.encrypt = False | |
with demo: | |
with gr.Column(): | |
gr.Markdown(''' | |
<div style="text-align: center"> | |
<h1 style='text-align: center'>Video Summarization</h1> | |
</div> | |
''') | |
with gr.Row(): | |
gr.Markdown(''' | |
### Summarize video | |
<ul> | |
<li>Step 1. download a video from youtube (select one of the examples and press the Download button)</li> | |
<li>Step 2: Select the summary rate and playback speed</li> | |
<li>Step 3: Generate a summarized video (press the Summarize button)</li> | |
</ul> | |
A summarized video will be generated on the right side of the original video. In addition, the summarized text of the video and in the video | |
''') | |
with gr.Row(): | |
gr.Markdown(''' | |
### User ID | |
Fill in the user ID if the author of this system has instructed you to do so. | |
''') | |
user_id = gr.Textbox(placeholder="Flip your user ID") | |
with gr.Row(): | |
gr.Markdown(''' | |
### You can test by following examples: | |
''') | |
examples = gr.Examples(examples= | |
[ "https://www.youtube.com/watch?v=QghjaS0WQQU", | |
"https://www.youtube.com/watch?v=cUS_22_lDiM", | |
"https://www.youtube.com/watch?v=80yqL2KzBVw"], | |
label="Examples", inputs=[youtube_url_in]) | |
with gr.Column(): | |
youtube_url_in.render() | |
download_youtube_btn = gr.Button("Download Youtube video") | |
download_youtube_btn.click(get_youtube, [youtube_url_in], [video_in]) | |
print(video_in) | |
with gr.Row(): | |
ratio_sum = gr.Slider(label="Summarize Ratio", minimum=0.3, maximum=0.8, step=0.05, value=0.6) | |
playback_speed = gr.Slider(label="Playback Speed", minimum=0.5, maximum=2.0, step=0.25, value=1.0) | |
with gr.Row(): | |
upload_output_video_btn = gr.Button("Summarize Video") | |
upload_output_video_btn.click(summarize_video, [video_in, ratio_sum, playback_speed], [video_out, summary_text, transcription_text]) | |
with gr.Row(): | |
video_in.render() | |
video_out.render() | |
with gr.Row(): | |
summary_text.render() | |
with gr.Row(): | |
transcription_text.render() | |
# demo.launch(debug=True) | |
demo.launch(debug=True) |