import gradio as gr from transformers import pipeline # Load the text-to-image pipeline from Hugging Face generator = pipeline('text-to-image', model="CompVis/stable-diffusion-v1-4") def generate_image(description): # Generate the image based on the description image = generator(description) return image[0]['image'] # Create the Gradio interface interface = gr.Interface( fn=generate_image, inputs="text", outputs="image", title="Image Generator from Description", description="Enter a text description and generate an image based on it." ) # Launch the Gradio interface if __name__ == "__main__": interface.launch()