SakuraD commited on
Commit
aa286ed
1 Parent(s): fd1f0a4
Files changed (3) hide show
  1. .gitattributes +1 -1
  2. README.md +4 -37
  3. app.py +35 -12
.gitattributes CHANGED
@@ -1,7 +1,6 @@
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bin.* filter=lfs diff=lfs merge=lfs -text
5
  *.bz2 filter=lfs diff=lfs merge=lfs -text
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
@@ -21,6 +20,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
  *.tar.* filter=lfs diff=lfs merge=lfs -text
22
  *.tflite filter=lfs diff=lfs merge=lfs -text
23
  *.tgz filter=lfs diff=lfs merge=lfs -text
 
24
  *.xz filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
 
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
 
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
5
  *.ftz filter=lfs diff=lfs merge=lfs -text
6
  *.gz filter=lfs diff=lfs merge=lfs -text
 
20
  *.tar.* filter=lfs diff=lfs merge=lfs -text
21
  *.tflite filter=lfs diff=lfs merge=lfs -text
22
  *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
  *.xz filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,46 +1,13 @@
1
  ---
2
  title: Uniformer_video_demo
3
- emoji: 📚
4
- colorFrom: gray
5
  colorTo: green
6
  sdk: gradio
 
7
  app_file: app.py
8
  pinned: false
9
  license: mit
10
  ---
11
 
12
- # Configuration
13
-
14
- `title`: _string_
15
- Display title for the Space
16
-
17
- `emoji`: _string_
18
- Space emoji (emoji-only character allowed)
19
-
20
- `colorFrom`: _string_
21
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
22
-
23
- `colorTo`: _string_
24
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
25
-
26
- `sdk`: _string_
27
- Can be either `gradio`, `streamlit`, or `static`
28
-
29
- `sdk_version` : _string_
30
- Only applicable for `streamlit` SDK.
31
- See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
32
-
33
- `app_file`: _string_
34
- Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
35
- Path is relative to the root of the repository.
36
-
37
- `models`: _List[string]_
38
- HF model IDs (like "gpt2" or "deepset/roberta-base-squad2") used in the Space.
39
- Will be parsed automatically from your code if not specified here.
40
-
41
- `datasets`: _List[string]_
42
- HF dataset IDs (like "common_voice" or "oscar-corpus/OSCAR-2109") used in the Space.
43
- Will be parsed automatically from your code if not specified here.
44
-
45
- `pinned`: _boolean_
46
- Whether the Space stays on top of your list.
 
1
  ---
2
  title: Uniformer_video_demo
3
+ emoji: 📹
4
+ colorFrom: pink
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 3.0.3
8
  app_file: app.py
9
  pinned: false
10
  license: mit
11
  ---
12
 
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -90,15 +90,38 @@ def inference(video):
90
  return {kinetics_id_to_classname[str(i)]: float(prediction[i]) for i in range(400)}
91
 
92
 
93
- inputs = gr.inputs.Video()
94
- label = gr.outputs.Label(num_top_classes=5)
95
-
96
- title = "UniFormer-S"
97
- description = "Gradio demo for UniFormer: To use it, simply upload your video, or click one of the examples to load them. Read more at the links below."
98
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2201.04676' target='_blank'>[ICLR2022] UniFormer: Unified Transformer for Efficient Spatiotemporal Representation Learning</a> | <a href='https://github.com/Sense-X/UniFormer' target='_blank'>Github Repo</a></p>"
99
-
100
- gr.Interface(
101
- inference, inputs, outputs=label,
102
- title=title, description=description, article=article,
103
- examples=[['hitting_baseball.mp4'], ['hoverboarding.mp4'], ['yoga.mp4']]
104
- ).launch(enable_queue=True, cache_examples=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  return {kinetics_id_to_classname[str(i)]: float(prediction[i]) for i in range(400)}
91
 
92
 
93
+ def set_example_video(example: list) -> dict:
94
+ return gr.Video.update(value=example[0])
95
+
96
+
97
+ demo = gr.Blocks()
98
+ with demo:
99
+ gr.Markdown(
100
+ """
101
+ # UniFormer-S
102
+ Gradio demo for <a href='https://github.com/Sense-X/UniFormer' target='_blank'>UniFormer</a>: To use it, simply upload your video, or click one of the examples to load them. Read more at the links below.
103
+ """
104
+ )
105
+
106
+ with gr.Box():
107
+ with gr.Row():
108
+ with gr.Column():
109
+ with gr.Row():
110
+ input_video = gr.Video(label='Input Video')
111
+ with gr.Row():
112
+ submit_button = gr.Button('Submit')
113
+ with gr.Column():
114
+ label = gr.Label(num_top_classes=5)
115
+ with gr.Row():
116
+ example_videos = gr.Dataset(components=[input_video], samples=[['hitting_baseball.mp4'], ['hoverboarding.mp4'], ['yoga.mp4']])
117
+
118
+ gr.Markdown(
119
+ """
120
+ <p style='text-align: center'><a href='https://arxiv.org/abs/2201.04676' target='_blank'>[ICLR2022] UniFormer: Unified Transformer for Efficient Spatiotemporal Representation Learning</a> | <a href='https://github.com/Sense-X/UniFormer' target='_blank'>Github Repo</a></p>
121
+ """
122
+ )
123
+
124
+ submit_button.click(fn=inference, inputs=input_video, outputs=label)
125
+ example_videos.click(fn=set_example_video, inputs=example_videos, outputs=example_videos.components)
126
+
127
+ demo.launch(enable_queue=True)