Spaces:
Running
Running
| 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() | |