Spaces:
Runtime error
Runtime error
Download app.py from aramkris/stableDiffusiondemo: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/aramkris/stableDiffusiondemo/resolve/main/app.py
- Command line
-
hf download hf://spaces/aramkris/stableDiffusiondemo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/aramkris/stableDiffusiondemo/resolve/main/app.py
1.08 kB
| import gradio as gr | |
| import os | |
| import torch | |
| from diffusers import StableDiffusionPipeline | |
| #print(f"Is CUDA available: {torch.cuda.is_available()}") | |
| #if torch.cuda.is_available(): | |
| # pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, revision="fp16", use_auth_token=os.getenv("HUGGING_FACE_HUB_TOKEN")) | |
| # pipe = pipe.to("cuda") | |
| #else: | |
| pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", use_auth_token=os.getenv("HUGGING_FACE_HUB_TOKEN")) | |
| # prompt = "a photo of an astronaut riding a horse on mars" | |
| # image = pipe(prompt).images[0] | |
| title = "Stable Diffusion Demo" | |
| description = "Just trying Stable Diffusion Demo" | |
| def inference(text): | |
| output_sd = pipe(text).images[0] | |
| return [output_sd] | |
| io = gr.Interface( | |
| inference, | |
| gr.Textbox(lines=3), | |
| outputs=[ | |
| gr.Image(type="pil", label="Stable Diffusion"), | |
| ], | |
| title=title, | |
| description=description, | |
| ) | |
| io.launch() | |
| # iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| # iface.launch() | |