TuanScientist commited on
Commit
0da2b4b
·
1 Parent(s): 4b79df0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -55
app.py CHANGED
@@ -112,60 +112,23 @@ def predict(youtube_url_or_file_path):
112
  return label_to_score, gif_path
113
 
114
 
115
- app = gr.Blocks()
116
- with app:
117
- gr.Markdown("# **<p align='center'>Video Classification with 🤗 Transformers</p>**")
118
- gr.Markdown(
119
- """
120
- <p style='text-align: center'>
121
- Perform video classification with <a href='https://huggingface.co/models?pipeline_tag=video-classification&library=transformers' target='_blank'>HuggingFace Transformers video models</a>.
122
- <br> For zero-shot classification, you can use the <a href='https://huggingface.co/spaces/fcakyon/zero-shot-video-classification' target='_blank'>zero-shot classification demo</a>.
123
- </p>
124
- """
125
- )
126
-
127
- with gr.Row():
128
- with gr.Column():
129
- model_names_dropdown = gr.Dropdown(
130
- choices=VALID_VIDEOCLASSIFICATION_MODELS,
131
- label="Model:",
132
- show_label=True,
133
- value=DEFAULT_MODEL,
134
- )
135
- model_names_dropdown.change(fn=select_model, inputs=model_names_dropdown)
136
- with gr.Tab(label="Youtube URL"):
137
- gr.Markdown("### **Provide a Youtube video URL**")
138
- youtube_url = gr.Textbox(label="Youtube URL:", show_label=True)
139
- youtube_url_predict_btn = gr.Button(value="Predict")
140
- with gr.Tab(label="Local File"):
141
- gr.Markdown("### **Upload a video file**")
142
- video_file = gr.Video(label="Video File:", show_label=True)
143
- local_video_predict_btn = gr.Button(value="Predict")
144
- with gr.Column():
145
- video_gif = gr.Image(
146
- label="Input Clip",
147
- show_label=True,
148
- )
149
- with gr.Column():
150
- predictions = gr.Label(
151
- label="Predictions:", show_label=True, num_top_classes=5
152
- )
153
-
154
- gr.Markdown("**Examples:**")
155
- gr.Examples(
156
- examples,
157
- youtube_url,
158
- [predictions, video_gif],
159
- fn=predict,
160
- cache_examples=True,
161
- )
162
-
163
- youtube_url_predict_btn.click(
164
- predict, inputs=youtube_url, outputs=[predictions, video_gif]
165
- )
166
- local_video_predict_btn.click(
167
- predict, inputs=video_file, outputs=[predictions, video_gif]
168
- )
169
-
170
 
171
  app.launch()
 
112
  return label_to_score, gif_path
113
 
114
 
115
+ app = gr.Interface(
116
+ fn=predict,
117
+ inputs=[
118
+ gr.Interface.Dropdown(
119
+ choices=VALID_VIDEOCLASSIFICATION_MODELS,
120
+ label="Model:",
121
+ show_label=True,
122
+ value=DEFAULT_MODEL,
123
+ ),
124
+ gr.Interface.Textbox(label="Youtube URL:", show_label=True),
125
+ gr.Interface.Video(label="Video File:", show_label=True),
126
+ ],
127
+ outputs=[
128
+ gr.Interface.Label(label="Predictions:", show_label=True, num_top_classes=5),
129
+ gr.Interface.Image(label="Input Clip", show_label=True),
130
+ ],
131
+ layout="vertical",
132
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  app.launch()