File size: 1,242 Bytes
cbaea01
 
 
 
 
 
 
 
 
c8e34aa
 
 
 
cbaea01
 
 
f3092a6
 
 
 
 
cbaea01
 
f3092a6
cbaea01
 
eef7aed
cbaea01
f3092a6
 
 
cbaea01
 
 
 
 
c8e34aa
cbaea01
 
 
 
 
 
2689a69
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
37
38
39
40
41
42
43
44
45
import gradio as gr

# Load multiple models
model1 = gr.load("models/Lykon/dreamshaper-xl-turbo")
model2 = gr.load("models/hakurei/waifu-diffusion")
model3 = gr.load("models/runwayml/stable-diffusion-v1-5")
model4 = gr.load("models/stablediffusionapi/juggernaut-xl-v5")
model5 = gr.load("models/stabilityai/stable-diffusion-xl-base-1.0")

# Function to switch between models and generate image
def generate_image(selected_model_name, text_input):
    selected_model = models[selected_model_name]
    return selected_model(text_input)

# Define the models and their names
models = {
    "dreamshaper-xl-turbo": model1,
    "waifu-diffusion": model2,
    "runwayml sdxl": model3,
    "juggernaut-xl-v5": model4,
    "stable-diffusion-xl": model5
}



# Create the input text box
input_text = gr.Textbox(label="Input Text", placeholder="Enter text here")  # Set placeholder instead of default

# Create a dropdown to select the model
model_dropdown = gr.Dropdown(choices=list(models.keys()), label="Select Model")

# Create the output image
output_image = gr.Image()

# Create the interface
iface = gr.Interface(
    fn=generate_image,
    inputs=[model_dropdown, input_text],
    outputs=output_image,
)

# Launch the interface
iface.launch()