Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| # Load multiple models | |
| model1 = gr.load("models/Lykon/dreamshaper-xl-turbo") | |
| model2 = gr.load("models/dataautogpt3/ProteusV0.2") | |
| 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, | |
| "ProteusV0.2": 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() | |