File size: 1,056 Bytes
d2a63c1
f53a2aa
d2a63c1
0a5203f
 
d2a63c1
17f0aaa
 
8940bbf
403ed9b
 
 
 
 
 
 
0a5203f
 
 
 
 
 
 
 
 
 
 
403ed9b
 
 
f53a2aa
17f0aaa
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
import gradio as gr
import os

from inference import *
from utils import *


with gr.Blocks() as block:
    options = gr.Dropdown(choices=["Model 1", "Model 2", "Model 3"], label="Models", info="Select the model to use..")

    txt = gr.Textbox(label="Insert a question..", lines=2)
    txt_3 = gr.Textbox(value="", label="Your answer is here..")
    btn = gr.Button(value="Submit")

    dogs = os.path.join(os.path.dirname(__file__), "617.jpg")
    image = gr.Image(type="pil", value=dogs)

    selected_option = block.get_element("dropdown").value
    # here we can insert two or more models to inference the data
    if selected_option == "Model 1":
        btn.click(inference, inputs=[image, txt], outputs=[txt_3 + " Model 1"])

    elif selected_option == "Model 2":
        btn.click(inference, inputs=[image, txt], outputs=[txt_3 + " Model 2"])

    elif selected_option == "Model 3":
        btn.click(inference, inputs=[image, txt], outputs=[txt_3 + " Model 3"])

    btn = gr.Button(value="Submit")

if __name__ == "__main__":
    block.launch()