File size: 580 Bytes
1e1071a
6f56cb9
 
 
 
 
86e89ea
1e1071a
 
e6c92b5
6f56cb9
1e1071a
 
 
 
 
 
6f56cb9
1e1071a
 
 
 
6f56cb9
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 diffusers import StableDiffusionPipeline
import torch

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
pipe.to("cpu")

def generate_image(prompt):
    image = pipe(prompt, num_inference_steps=10).images[0]  
    return image

iface = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(label="Enter a prompt"),
    outputs="image",
    title="AI Image Generator (CPU Version)",
    description="Type a description, and AI will generate an image.",
)

iface.launch()