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

model_id = "runwayml/stable-diffusion-v1-5"  # You can change to your own model
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

def generate(prompt):
    image = pipe(prompt).images[0]
    return image

gr.Interface(
    fn=generate,
    inputs=gr.Textbox(label="Enter your prompt"),
    outputs=gr.Image(type="pil"),
    title="🎨 AI Image Generator",
    description="Enter a prompt to generate images using Stable Diffusion",
).launch()