Spaces:
Runtime error
Runtime error
Initial Commit
Browse files- README.md +5 -6
- app.py +40 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.0.19
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces
|
|
|
1 |
---
|
2 |
+
title: WinoGround Demo
|
3 |
+
emoji: 💻
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: gray
|
6 |
sdk: gradio
|
|
|
7 |
app_file: app.py
|
8 |
pinned: false
|
9 |
---
|
10 |
|
11 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
winoground = None
|
6 |
+
|
7 |
+
def fetch(auth_token):
|
8 |
+
global winoground
|
9 |
+
if winoground is None:
|
10 |
+
winoground = load_dataset("facebook/winoground", use_auth_token=auth_token)["test"]
|
11 |
+
example = winoground[0]
|
12 |
+
return example["image_0"], example["caption_0"], example["image_1"], example["caption_1"]
|
13 |
+
|
14 |
+
def func(index):
|
15 |
+
example = winoground[index]
|
16 |
+
return example["image_0"], example["caption_0"], example["image_1"], example["caption_1"]
|
17 |
+
|
18 |
+
|
19 |
+
demo = gr.Blocks()
|
20 |
+
|
21 |
+
|
22 |
+
with demo:
|
23 |
+
gr.Markdown("Slide across the slider to see various examples from WinoGround")
|
24 |
+
|
25 |
+
with gr.Column():
|
26 |
+
auth_token = gr.Textbox(label="Hugging Face Access Token")
|
27 |
+
button = gr.Button("Get dataset")
|
28 |
+
slider = gr.Slider(minimum=0, maximum=400)
|
29 |
+
with gr.Row():
|
30 |
+
with gr.Column():
|
31 |
+
image_input_1 = gr.Image()
|
32 |
+
text_input_1 = gr.Textbox()
|
33 |
+
with gr.Column():
|
34 |
+
image_input_2 = gr.Image()
|
35 |
+
text_input_2 = gr.Textbox()
|
36 |
+
|
37 |
+
button.click(fetch, inputs=[auth_token], outputs=[image_input_1, text_input_1, image_input_2, text_input_2])
|
38 |
+
slider.change(func, inputs=[slider], outputs=[image_input_1, text_input_1, image_input_2, text_input_2])
|
39 |
+
|
40 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
datasets
|
2 |
+
gradio
|