from gradio import Interface from diffusers import StableDiffusionPipeline # Load the Stable Diffusion model (specific checkpoint for sd-1.5) pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5") def generate(prompt, num_iterations=20): """Generates an image based on the provided prompt.""" images = pipe(prompt, num_iterations=num_iterations).images return images[0] # Gradio interface with basic controls interface = Interface( fn=generate, inputs="text", outputs="image", title="Stable Diffusion (sd-1.5)", description="Create images with text prompts using Stable Diffusion v1.5." ) interface.launch()