Text-to-Image
Diffusers
Safetensors

Add pipeline tag, library_name and code snippet

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +54 -1
README.md CHANGED
@@ -1,6 +1,9 @@
1
  ---
2
  license: apache-2.0
 
 
3
  ---
 
4
  # Scale-wise Distillation 3.5 Medium
5
  Scale-wise Distillation (SwD) is a novel framework for accelerating diffusion models (DMs)
6
  by progressively increasing spatial resolution during the generation process.
@@ -10,4 +13,54 @@ while maintaining or even improving image quality.
10
 
11
  ## Usage
12
  To generate images using SwD, go to <a href="https://github.com/yandex-research/swd ">GitHub</a>
13
- or <a href="https://huggingface.co/spaces/dbaranchuk/Scale-wise-Distillation">Hugging Face's demo </a>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  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.
 
13
 
14
  ## Usage
15
  To generate images using SwD, go to <a href="https://github.com/yandex-research/swd ">GitHub</a>
16
+ or <a href="https://huggingface.co/spaces/dbaranchuk/Scale-wise-Distillation">Hugging Face's demo </a>.
17
+
18
+ ```py
19
+ import torch
20
+ from inference import run
21
+ from diffusers import StableDiffusion3Pipeline
22
+ from peft import LoraConfig, get_peft_model, PeftModel
23
+
24
+ pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-large", torch_dtype=torch.float16)
25
+ pipe = pipe.to("cuda")
26
+ lora_path = 'yresearch/swd-large-6-steps'
27
+ pipe.transformer = PeftModel.from_pretrained(
28
+ pipe.transformer,
29
+ lora_path,
30
+ )
31
+ generator = torch.Generator().manual_seed(0)
32
+ prompt = 'cat reading a newspaper'
33
+ sigmas = [1.0000, 0.9454, 0.8959, 0.7904, 0.7371, 0.6022]
34
+ scales = [32, 48, 64, 80, 96, 128]
35
+
36
+ images = run(
37
+ pipe,
38
+ prompt,
39
+ sigmas=torch.tensor(sigmas).to('cuda'),
40
+ timesteps=torch.tensor(sigmas[:-1]).to('cuda') * 1000,
41
+ scales=scales,
42
+
43
+ guidance_scale=0.0,
44
+ height=int(scales[0] * 8),
45
+ width=int(scales[0] * 8),
46
+ generator=generator,
47
+ ).images
48
+ ```
49
+ <p align="center">
50
+ <img src="assets/cat.png" width="512px"/>
51
+ </p>
52
+
53
+ ## 🔧 Training
54
+
55
+ Coming soon!
56
+
57
+ ## Citation
58
+
59
+ ```bibtex
60
+ @article{starodubcev2025swd,
61
+ title={Scale-wise Distillation of Diffusion Models},
62
+ author={Nikita Starodubcev and Denis Kuznedelev and Artem Babenko and Dmitry Baranchuk},
63
+ journal={arXiv preprint arXiv:2503.16397},
64
+ year={2025}
65
+ }
66
+ ```