File size: 1,212 Bytes
efabbbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from app.app_utils import preprocess_video_and_predict

def clear_dynamic_info():
    return [gr.Video(value=None)] * 4 + [gr.Plot(value=None)]

def create_face_expressions_tab():
    with gr.Row():
        with gr.Column(scale=1):
            input_video = gr.Video(elem_classes="video1")
            with gr.Row():
                clear_btn = gr.Button("Clear")
                submit_btn = gr.Button("Analyze", elem_classes="submit")
        with gr.Column(scale=1, elem_classes="dl4"):
            output_videos = [
                gr.Video(label=label, elem_classes=f"video{i+2}")
                for i, label in enumerate(["Original video", "Pre-processed video", "Heatmaps"])
            ]
            output_statistics = gr.Plot(label="Statistics of emotions", elem_classes="stat")
    
    submit_btn.click(
        fn=preprocess_video_and_predict,
        inputs=input_video,
        outputs=output_videos + [output_statistics],
        queue=True,
    )
    
    clear_btn.click(
        fn=clear_dynamic_info,
        outputs=[input_video] + output_videos + [output_statistics],
        queue=True,
    )
    
    gr.Examples(["./assets/videos/fitness.mp4"], inputs=[input_video])