File size: 1,199 Bytes
1dd4dbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

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