Download app.py from MISHI9/README: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/spaces/MISHI9/README/resolve/main/app.py
- Command line
-
hf download hf://spaces/MISHI9/README/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MISHI9/README/resolve/main/app.py
622 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 genera_imatge(text): | |
| imatge = pipe(text).images[0] | |
| return imatge | |
| demo = gr.Interface(fn=genera_imatge, | |
| inputs="text", | |
| outputs="image", | |
| title="Generador d’Imatges") | |
| demo.launch() | |