File size: 2,851 Bytes
958c599
 
1f5c279
8ad5dc2
958c599
2af7539
 
958c599
 
 
 
 
 
 
 
 
 
8ad5dc2
 
 
 
 
 
958c599
 
 
c116608
 
 
 
 
8ad5dc2
958c599
c116608
 
 
3cb4906
c116608
 
958c599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c116608
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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)