File size: 893 Bytes
b152d54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()