import gradio as gr from main_func import video_identity with gr.Blocks() as demo: with gr.Row(variant='compact'): with gr.Column(): gr.Markdown("#### Dynamic Time Warping:") with gr.Row(variant='compact'): dtw_mean = gr.Slider( value=0.5, minimum=0, maximum=1.0, step=0.05, label="Winsorize Mean" ) dtw_filter = gr.Slider( value=3, minimum=1, maximum=20, step=1, label="Savitzky-Golay Filter" ) gr.Markdown("#### Thresholds:") with gr.Row(variant='compact'): angles_sensitive = gr.Number( value=15, minimum=0, maximum=75, step=1, min_width=100, label="Sensitive" ) angles_common = gr.Number( value=25, minimum=0, maximum=75, step=1, min_width=100, label="Standart" ) angles_insensitive = gr.Number( value=45, minimum=0, maximum=75, step=1, min_width=100, label="Insensitive" ) gr.Markdown("#### Patience:") trigger_state = gr.Radio(value="three", choices=["three", "two"], label="Trigger Count") input_teacher = gr.Video(show_share_button=False, show_download_button=False, sources=["upload"], label="Teacher's Video") input_student = gr.Video(show_share_button=False, show_download_button=False, sources=["upload"], label="Student's Video") with gr.Accordion("Clarifications:", open=True): with gr.Accordion("Dynamic Time Warping:", open=False): gr.Markdown(""" Dynamic Time Warping is an algorithm that performs frame-by-frame alignment for videos with different speeds. - **Winsorized mean**: Determines the portion of DTW paths, sorted from best to worst, to use for generating the mean DTW alignment. Reasonable values range from 0.25 to 0.6. - **Savitzky-Golay Filter**: Enhances the capabilities of the Winsorized mean, making DTW alignment more similar to a strict line. Reasonable values range from 2 to 10. """) with gr.Accordion("Thresholds:", open=False): gr.Markdown(""" Thresholds are used to identify student errors in dance. If the difference in angle between the teacher's and student's videos exceeds this threshold, it is counted as an error. - **Sensitive**: A threshold that is currently not used. - **Standard**: A threshold for most angles. Reasonable values range from 20 to 40. - **Insensitive**: A threshold for difficult areas, such as hands and toes. Reasonable values range from 35 to 55. """) with gr.Accordion("Patience:", open=False): gr.Markdown(""" Patience helps prevent model errors by highlighting only errors detected in consecutive frames. - **Three**: Utilizes 3 consecutive frames for error detection. - **Two**: Utilizes 2 consecutive frames for error detection. Both options can be used interchangeably. """) with gr.Row(): gr_button = gr.Button("Run Pose Comparison") with gr.Row(): gr.HTML("
") with gr.Row(): output_merged = gr.Video(show_download_button=True) with gr.Row(): general_log = gr.TextArea(lines=10, max_lines=9999, label="Error log") gr_button.click( fn=video_identity, inputs=[dtw_mean, dtw_filter, angles_sensitive, angles_common, angles_insensitive, trigger_state, input_teacher, input_student], outputs=[output_merged, general_log] ) if __name__ == "__main__": demo.launch()