Spaces:
Runtime error
Runtime error
Download src/models.py from KaliumPotas/KaliumHaircutGenerate: direct link, hf CLI and curl.
- Browser
- Download file 402 Bytes
-
https://huggingface.co/spaces/KaliumPotas/KaliumHaircutGenerate/resolve/main/src/models.py
- Command line
-
hf download hf://spaces/KaliumPotas/KaliumHaircutGenerate/src/models.py
-
curl -L -o models.py https://huggingface.co/spaces/KaliumPotas/KaliumHaircutGenerate/resolve/main/src/models.py
402 Bytes
| import torch | |
| from diffusers import DiffusionPipeline | |
| pipe = None | |
| def load_model(): | |
| global pipe | |
| if pipe is None: | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "stablediffusionapi/deliberate-v2", | |
| torch_dtype=torch.float16 | |
| ).to("cuda") | |
| return pipe | |
| def generate(prompt: str): | |
| pipe = load_model() | |
| image = pipe(prompt).images[0] | |
| return image |