Spaces:
Sleeping
Sleeping
Download app.py from B-Bhuvanesh/stable_diffusion: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/spaces/B-Bhuvanesh/stable_diffusion/resolve/main/app.py
- Command line
-
hf download hf://spaces/B-Bhuvanesh/stable_diffusion/app.py
-
curl -L -o app.py https://huggingface.co/spaces/B-Bhuvanesh/stable_diffusion/resolve/main/app.py
551 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Load model | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| "runwayml/stable-diffusion-v1-5", | |
| torch_dtype=torch.float32 | |
| ) | |
| pipe.to("cpu") # Spaces free tier uses CPU | |
| def generate(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| gr.Interface( | |
| fn=generate, | |
| inputs=gr.Textbox(label="Enter your prompt"), | |
| outputs="image", | |
| title="Stable Diffusion Generator", | |
| description="Generate images from text using Stable Diffusion" | |
| ).launch() |