import gradio as gr from diffusers import DiffusionPipeline # Load the pre-trained DiffusionPipeline model pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0") def text_to_image(text): # Generate an image based on the input text image = pipeline(text).images[0] return image text_input = gr.Textbox(label="Enter your text") image_output = gr.Image(label="Generated Image") download_button = gr.DownloadButton(label="Download Image") iface = gr.Interface(fn=text_to_image, inputs=text_input, outputs=[image_output, download_button], title="Text to Image App Using stable-diffusion-xl-base-1.0") iface.launch()