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()