Update README.md
Browse files
README.md
CHANGED
|
@@ -3,7 +3,6 @@ license: apache-2.0
|
|
| 3 |
library_name: diffusers
|
| 4 |
pipeline_tag: text-to-image
|
| 5 |
---
|
| 6 |
-
|
| 7 |
# Scale-wise Distillation 3.5 Medium
|
| 8 |
Scale-wise Distillation (SwD) is a novel framework for accelerating diffusion models (DMs)
|
| 9 |
by progressively increasing spatial resolution during the generation process.
|
|
@@ -11,9 +10,49 @@ by progressively increasing spatial resolution during the generation process.
|
|
| 11 |
while maintaining or even improving image quality.
|
| 12 |

|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
## Usage
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## Citation
|
| 19 |
|
|
|
|
| 3 |
library_name: diffusers
|
| 4 |
pipeline_tag: text-to-image
|
| 5 |
---
|
|
|
|
| 6 |
# Scale-wise Distillation 3.5 Medium
|
| 7 |
Scale-wise Distillation (SwD) is a novel framework for accelerating diffusion models (DMs)
|
| 8 |
by progressively increasing spatial resolution during the generation process.
|
|
|
|
| 10 |
while maintaining or even improving image quality.
|
| 11 |

|
| 12 |
|
| 13 |
+
Project page: https://yandex-research.github.io/swd <br>
|
| 14 |
+
GitHub: https://github.com/yandex-research/swd <br>
|
| 15 |
+
Demo: https://huggingface.co/spaces/dbaranchuk/Scale-wise-Distillation
|
| 16 |
+
|
| 17 |
## Usage
|
| 18 |
+
Upgrade to the latest version of the [🧨 diffusers library](https://github.com/huggingface/diffusers)
|
| 19 |
+
```
|
| 20 |
+
pip install -U diffusers
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
and then you can run
|
| 24 |
+
```py
|
| 25 |
+
import torch
|
| 26 |
+
from diffusers import StableDiffusion3Pipeline
|
| 27 |
+
from peft import PeftModel
|
| 28 |
+
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium",
|
| 29 |
+
torch_dtype=torch.float16,
|
| 30 |
+
custom_pipeline='quickjkee/swd_pipeline')
|
| 31 |
+
pipe = pipe.to("cuda")
|
| 32 |
+
lora_path = 'yresearch/swd-medium-4-steps'
|
| 33 |
+
pipe.transformer = PeftModel.from_pretrained(
|
| 34 |
+
pipe.transformer,
|
| 35 |
+
lora_path,
|
| 36 |
+
)
|
| 37 |
+
generator = torch.Generator().manual_seed(1)
|
| 38 |
+
prompt = 'A dog holding a sign that reads Sample Faster'
|
| 39 |
+
sigmas = [1.0000, 0.9454, 0.7904, 0.6022, 0.0000]
|
| 40 |
+
scales = [32, 64, 96, 128]
|
| 41 |
+
|
| 42 |
+
images = pipe(
|
| 43 |
+
prompt,
|
| 44 |
+
sigmas=torch.tensor(sigmas).to('cuda'),
|
| 45 |
+
timesteps=torch.tensor(sigmas[:-1]).to('cuda') * 1000,
|
| 46 |
+
scales=scales,
|
| 47 |
+
guidance_scale=0.0,
|
| 48 |
+
height=int(scales[0] * 8),
|
| 49 |
+
width=int(scales[0] * 8),
|
| 50 |
+
generator=generator,
|
| 51 |
+
).images
|
| 52 |
+
```
|
| 53 |
+
<p align="center">
|
| 54 |
+
<img src="medium.jpg" width="512px"/>
|
| 55 |
+
</p>
|
| 56 |
|
| 57 |
## Citation
|
| 58 |
|