File size: 659 Bytes
6637607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()