File size: 736 Bytes
6559825
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch

# Load the Stable Diffusion model from Hugging Face's diffusers library
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4-original", torch_dtype=torch.float16)
pipe.to("cuda")

def generate_image(prompt):
    # Generate the image based on the text prompt
    image = pipe(prompt).images[0]
    return image

# Create Gradio interface
interface = gr.Interface(fn=generate_image,
                         inputs="text",
                         outputs="image",
                         title="Text to Image Generator",
                         description="Generate images from text using Stable Diffusion.")

interface.launch()