Omnibus's picture
Duplicate from Omnibus/Gradio-Dropdown-Model-Select
1dd4dbb
raw
history blame
No virus
1.2 kB
import gradio as gr
models=[
"runwayml/stable-diffusion-v1-5",
"claudfuen/photorealistic-fuen-v1",
"nitrosocke/redshift-diffusion",
]
model_box=[
gr.Interface.load(f"models/{models[0]}",live=True,preprocess=True),
gr.Interface.load(f"models/{models[1]}",live=True,preprocess=True),
gr.Interface.load(f"models/{models[2]}",live=True,preprocess=True),
]
current_model=model_box[0]
def the_process(input_text, model_choice):
a_variable = model_box[model_choice]
output = a_variable(input_text)
return(output)
with gr.Blocks() as demo:
gr.HTML("""<h1 style="font-weight:600;font-size:50;margin-top:4px;margin-bottom:4px;text-align:center;">Example Space to copy/paste</h1></div>""")
with gr.Row():
with gr.Column():
model_choice = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index", interactive=True)
input_text = gr.Textbox(label="Input Prompt")
the_button = gr.Button(label="Run")
with gr.Column():
output_window = gr.Image(label="Generated Image")
the_button.click(the_process, inputs=[input_text, model_choice], outputs=[output_window])
demo.launch()