Spaces:
Runtime error
Runtime error
Remove requirement of auth token
Browse files
app.py
CHANGED
@@ -1,40 +1,31 @@
|
|
1 |
from datasets import load_dataset
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
winoground =
|
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()
|
|
|
1 |
from datasets import load_dataset
|
2 |
import gradio as gr
|
3 |
+
import os
|
4 |
+
import random
|
5 |
|
6 |
+
auth_token = os.environ.get("token")
|
7 |
+
winoground = load_dataset("facebook/winoground", use_auth_token=auth_token)["test"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def func(index):
|
10 |
example = winoground[index]
|
11 |
return example["image_0"], example["caption_0"], example["image_1"], example["caption_1"]
|
12 |
|
|
|
13 |
demo = gr.Blocks()
|
14 |
|
|
|
15 |
with demo:
|
16 |
+
gr.Markdown("# Slide across the slider to see various examples from WinoGround")
|
17 |
|
18 |
with gr.Column():
|
|
|
|
|
19 |
slider = gr.Slider(minimum=0, maximum=400)
|
20 |
with gr.Row():
|
21 |
+
index = random.choice(range(0, 400))
|
22 |
with gr.Column():
|
23 |
+
image_input_1 = gr.Image(value=winoground[index]["image_0"])
|
24 |
+
text_input_1 = gr.Textbox(value=winoground[index]["caption_0"])
|
25 |
with gr.Column():
|
26 |
+
image_input_2 = gr.Image(value=winoground[index]["image_1"])
|
27 |
+
text_input_2 = gr.Textbox(value=winoground[index]["caption_1"])
|
28 |
|
|
|
29 |
slider.change(func, inputs=[slider], outputs=[image_input_1, text_input_1, image_input_2, text_input_2])
|
30 |
|
31 |
demo.launch()
|