te's picture
first commit
b152d54
raw
history blame contribute delete
893 Bytes
import gradio as gr
questions = [
{"image": "imgs/IMG_1.jpg", "options": ["a", "b", "c", "d"], "answer": "b"},
{"image": "imgs/IMG_2.jpg", "options": ["w", "x", "y", "z"], "answer": "y"},
]
def check_question(option, ind):
print(option)
print(questions[ind]["answer"])
if option == questions[ind]["answer"]:
return "Correcto"
else:
return "Incorrecto"
ind = 0
with gr.Blocks() as demo:
# image = gr.Image(value="imgs/IMG_1.jpg", height=200, width=200)
# name = gr.Textbox(label="Name")
# output = gr.Textbox(label="Output Box")
image = gr.Image(value=questions[ind]["image"])
options = gr.Radio(choices=questions[ind]["options"])
button = gr.Button("Siguiente pregunta")
output = gr.Textbox(label="Output Box")
button.click(fn=check_question, inputs=[options, ind], outputs=output)
ind += 1
demo.launch()