Spaces:
Sleeping
Sleeping
Download app.py from Python25/my-image-generator: direct link, hf CLI and curl.
- Browser
- Download file 424 Bytes
-
https://huggingface.co/spaces/Python25/my-image-generator/resolve/8f54e56bb7df4a42e759aad74f83f295f2198744/app.py
- Command line
-
hf download hf://spaces/Python25/my-image-generator@8f54e56bb7df4a42e759aad74f83f295f2198744/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Python25/my-image-generator/resolve/8f54e56bb7df4a42e759aad74f83f295f2198744/app.py
424 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| "CompVis/stable-diffusion-v1-4", | |
| torch_dtype=torch.float16, | |
| revision="fp16" | |
| ) | |
| pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu") | |
| def generate(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| gr.Interface(fn=generate, inputs="text", outputs="image").launch() | |