File size: 2,055 Bytes
3d12539
 
 
 
 
47eceb1
3d12539
 
 
 
0319821
3d12539
7a44257
0319821
3d12539
a581eb7
 
3d12539
a581eb7
3d12539
a581eb7
 
3d12539
a581eb7
 
 
 
3d12539
a581eb7
3d12539
a581eb7
 
 
3d12539
a581eb7
47eceb1
 
a581eb7
 
 
3d12539
a581eb7
3d12539
47eceb1
3d12539
a581eb7
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
import gradio as gr
from utils.predict import predict_action
import os
import glob

##Create list of examples to be loaded
example_list = glob.glob("examples/*")
example_list = list(map(lambda el:[el], example_list))


demo = gr.Blocks()


with demo:
    
    gr.Markdown("# **<p align='center'>Video Classification with Transformers</p>**")
    gr.Markdown("This space demonstrates the use of hybrid Transformer-based models for video classification that operate on CNN feature maps.")
    
    with gr.Tabs():
                
        with gr.TabItem("Upload & Predict"):
            with gr.Box():
                
                with gr.Row():
                    input_video = gr.Video(label="Input Video", show_label=True)
                    output_label = gr.Label(label="Model Output", show_label=True)
                    output_gif = gr.Image(label="Video Gif", show_label=True)
            
            gr.Markdown("**Predict**")
            
            with gr.Box():
                with gr.Row():
                    submit_button = gr.Button("Submit")
            
            gr.Markdown("**Examples:**")
            gr.Markdown("The model is trained to classify videos belonging to the following classes: CricketShot, PlayingCello, Punch, ShavingBeard, TennisSwing")
            # gr.Markdown("CricketShot, PlayingCello, Punch, ShavingBeard, TennisSwing")

            with gr.Column():
                gr.Examples(example_list, [input_video], [output_label,output_gif], predict_action, cache_examples=True)
        
    submit_button.click(predict_action, inputs=input_video, outputs=[output_label,output_gif])
    
    gr.Markdown('\n Demo created by: <a href=\"https://www.linkedin.com/in/shivalika-singh/\">Shivalika Singh</a> <br> Based on this <a href=\"https://keras.io/examples/vision/video_transformers/\">Keras example</a> by <a href=\"https://twitter.com/RisingSayak\">Sayak Paul</a> <br> Demo Powered by this <a href=\"https://huggingface.co/shivi/video-transformers/\"> Video Classification</a> model')
    
demo.launch()