Spaces:
Runtime error
Runtime error
Commit
Β·
a581eb7
1
Parent(s):
0319821
1. changed app design from interface to blocks API based
Browse files- app.py +32 -33
- examples/v_PlayingCello_g04_c02.avi +0 -0
- examples/v_Punch_g03_c03.avi +0 -0
- examples/v_TennisSwing_g02_c01.avi +0 -0
app.py
CHANGED
|
@@ -13,51 +13,50 @@ example_list = list(map(lambda el:[el], example_list))
|
|
| 13 |
|
| 14 |
demo = gr.Blocks()
|
| 15 |
|
| 16 |
-
#input_video = gr.Video(label="Input Video", show_label=True)
|
| 17 |
-
#output_label = gr.Label(label="Model Output", show_label=True)
|
| 18 |
-
#output_gif = gr.Image(label="Video Gif", show_label=True)
|
| 19 |
-
#title = "Video Classification with Transformers"
|
| 20 |
-
#description = "This space demonstrates the use of a hybrid (CNN-Transformer based) model for video classification. \n The model can classify videos belonging to the following action categories: CricketShot, Punch, ShavingBeard, TennisSwing, PlayingCello. \n Upload a video and try out π€ "
|
| 21 |
|
| 22 |
-
#article = '\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'
|
| 23 |
|
| 24 |
-
#gr.Interface(predict_action, input_video, [output_label, output_gif], examples=example_list, allow_flagging=False, analytics_enabled=False,
|
| 25 |
-
#
|
| 26 |
|
| 27 |
|
| 28 |
with demo:
|
| 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 |
-
|
|
|
|
| 13 |
|
| 14 |
demo = gr.Blocks()
|
| 15 |
|
| 16 |
+
# input_video = gr.Video(label="Input Video", show_label=True)
|
| 17 |
+
# output_label = gr.Label(label="Model Output", show_label=True)
|
| 18 |
+
# output_gif = gr.Image(label="Video Gif", show_label=True)
|
| 19 |
+
# title = "Video Classification with Transformers"
|
| 20 |
+
# description = "This space demonstrates the use of a hybrid (CNN-Transformer based) model for video classification. \n The model can classify videos belonging to the following action categories: CricketShot, Punch, ShavingBeard, TennisSwing, PlayingCello. \n Upload a video and try out π€ "
|
| 21 |
|
| 22 |
+
# article = '\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'
|
| 23 |
|
| 24 |
+
# gr.Interface(predict_action, input_video, [output_label, output_gif], examples=example_list, allow_flagging=False, analytics_enabled=False,
|
| 25 |
+
# title=title, description=description, cache_examples=True, article=article).launch(enable_queue=True,share=True)
|
| 26 |
|
| 27 |
|
| 28 |
with demo:
|
| 29 |
|
| 30 |
+
gr.Markdown("# **<p align='center'>Video Classification with Transformers</p>**")
|
| 31 |
+
gr.Markdown("This space demonstrates the use of hybrid Transformer-based models for video classification that operate on CNN feature maps.")
|
| 32 |
|
| 33 |
+
with gr.Tabs():
|
| 34 |
|
| 35 |
+
with gr.TabItem("Upload & Predict"):
|
| 36 |
+
with gr.Box():
|
| 37 |
|
| 38 |
+
with gr.Row():
|
| 39 |
+
input_video = gr.Video(label="Input Video", show_label=True)
|
| 40 |
+
output_label = gr.Label(label="Model Output", show_label=True)
|
| 41 |
+
output_gif = gr.Image(label="Video Gif", show_label=True)
|
| 42 |
|
| 43 |
+
gr.Markdown("**Predict**")
|
| 44 |
|
| 45 |
+
with gr.Box():
|
| 46 |
+
with gr.Row():
|
| 47 |
+
submit_button = gr.Button("Submit")
|
| 48 |
|
| 49 |
+
gr.Markdown("**Examples:**")
|
| 50 |
+
gr.Markdown("The model is trained to classify videos belonging to the following classes:")
|
| 51 |
+
gr.Markdown("CricketShot, PlayingCello, Punch, ShavingBeard, TennisSwing")
|
| 52 |
+
|
| 53 |
+
with gr.Column():
|
| 54 |
+
gr.Examples(example_list, [input_video], [output_label,output_gif], predict_action, cache_examples=True)
|
| 55 |
+
# examples = gr.components.Dataset(components=[input_video], samples=example_list, type='values')
|
| 56 |
+
# examples.click(load_example, examples, input_video)
|
| 57 |
|
| 58 |
+
submit_button.click(predict_action, inputs=input_video, outputs=[output_label,output_gif])
|
| 59 |
|
| 60 |
+
gr.Markdown('\n Author: <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')
|
| 61 |
|
| 62 |
+
demo.launch()
|
|
|
examples/v_PlayingCello_g04_c02.avi
DELETED
|
Binary file (781 kB)
|
|
|
examples/v_Punch_g03_c03.avi
DELETED
|
Binary file (400 kB)
|
|
|
examples/v_TennisSwing_g02_c01.avi
DELETED
|
Binary file (189 kB)
|
|
|