Spaces:
Runtime error
Runtime error
| import torch | |
| from diffusers import StableDiffusionPipeline | |
| import gradio as gr | |
| model_id = "CompVis/stable-diffusion-v1-4" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id) | |
| pipe = pipe.to("cpu") # Use CPU instead of CUDA | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| demo = gr.Interface( | |
| fn=generate_image, | |
| inputs=gr.Textbox(label="Text Prompt"), | |
| outputs="image", | |
| title="AI Image Generator", | |
| description="Generate images from text prompts using Stable Diffusion." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |