mrbeliever's picture
Update app.py
c8e34aa verified
raw
history blame
1.19 kB
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 = {
"Model 1": model1,
"Model 2": model2,
"Model 3": model3,
"Model 4": model4,
"Model 5": model5
}
# Create a dropdown to select the model
model_dropdown = gr.Dropdown(choices=list(models.keys()), label="Select Model")
# Create the input text box
input_text = gr.Textbox(label="Input Text", placeholder="Enter text here") # Set placeholder instead of default
# 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()