Spaces:
Build error
Build error
Download app.py from SnapTrend/ai-image-generator: direct link, hf CLI and curl.
- Browser
- Download file 486 Bytes
-
https://huggingface.co/spaces/SnapTrend/ai-image-generator/resolve/main/app.py
- Command line
-
hf download hf://spaces/SnapTrend/ai-image-generator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SnapTrend/ai-image-generator/resolve/main/app.py
486 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Load model (for CPU) | |
| pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5") | |
| pipe = pipe.to("cpu") | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| gr.Interface( | |
| fn=generate_image, | |
| inputs=gr.Textbox(label="Enter your prompt"), | |
| outputs=gr.Image(type="pil", label="Generated Image"), | |
| title="SnapTrend AI Image Generator" | |
| ).launch() | |