Spaces:
Sleeping
Sleeping
Download app/model.py from filipvk/tiny-sd-fastapi: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/spaces/filipvk/tiny-sd-fastapi/resolve/main/app/model.py
- Command line
-
hf download hf://spaces/filipvk/tiny-sd-fastapi/app/model.py
-
curl -L -o model.py https://huggingface.co/spaces/filipvk/tiny-sd-fastapi/resolve/main/app/model.py
473 Bytes
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| MODEL_NAME = "segmind/tiny-sd" | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| MODEL_NAME, | |
| cache_dir="./models", | |
| # local_files_only=True, | |
| torch_dtype=torch.float32, | |
| safety_checker=None, | |
| ) | |
| pipe.enable_attention_slicing() | |
| pipe.to("cpu") | |
| def generate_image(prompt): | |
| image = pipe(prompt, height=512, width=512, num_inference_steps=10).images[0] | |
| return image | |