Spaces:
Runtime error
Runtime error
Download app.py from farhup/Connect-v1: direct link, hf CLI and curl.
- Browser
- Download file 548 Bytes
-
https://huggingface.co/spaces/farhup/Connect-v1/resolve/main/app.py
- Command line
-
hf download hf://spaces/farhup/Connect-v1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/farhup/Connect-v1/resolve/main/app.py
548 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch, os | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| "stabilityai/stable-diffusion-2", | |
| torch_dtype=torch.float16, | |
| ).to("cuda" if torch.cuda.is_available() else "cpu") | |
| def generate(prompt): | |
| image = pipe(prompt, num_inference_steps=25).images[0] | |
| return image | |
| demo = gr.Interface( | |
| fn=generate, | |
| inputs=gr.Textbox(label="Prompt"), | |
| outputs=gr.Image(type="pil"), | |
| title="Stable Diffusion Demo", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |