Spaces:
Runtime error
Runtime error
from datasets import load_dataset | |
import gradio as gr | |
winoground = None | |
def fetch(auth_token): | |
global winoground | |
if winoground is None: | |
winoground = load_dataset("facebook/winoground", use_auth_token=auth_token)["test"] | |
example = winoground[0] | |
return example["image_0"], example["caption_0"], example["image_1"], example["caption_1"] | |
def func(index): | |
example = winoground[index] | |
return example["image_0"], example["caption_0"], example["image_1"], example["caption_1"] | |
demo = gr.Blocks() | |
with demo: | |
gr.Markdown("Slide across the slider to see various examples from WinoGround") | |
with gr.Column(): | |
auth_token = gr.Textbox(label="Hugging Face Access Token") | |
button = gr.Button("Get dataset") | |
slider = gr.Slider(minimum=0, maximum=400) | |
with gr.Row(): | |
with gr.Column(): | |
image_input_1 = gr.Image() | |
text_input_1 = gr.Textbox() | |
with gr.Column(): | |
image_input_2 = gr.Image() | |
text_input_2 = gr.Textbox() | |
button.click(fetch, inputs=[auth_token], outputs=[image_input_1, text_input_1, image_input_2, text_input_2]) | |
slider.change(func, inputs=[slider], outputs=[image_input_1, text_input_1, image_input_2, text_input_2]) | |
demo.launch() |