🚀 Scale-wise Distillation 3.5 Large
Scale-wise Distillation (SwD) 是一个用于加速扩散模型(DMs)的全新框架,它通过在生成过程中逐步提高空间分辨率来实现加速。与全分辨率模型相比,SwD 能实现显著的加速(2.5 倍至 10 倍),同时还能保持甚至提升图像质量。

项目页面:https://yandex-research.github.io/swd
GitHub:https://github.com/yandex-research/swd
演示:https://huggingface.co/spaces/dbaranchuk/Scale-wise-Distillation
🚀 快速开始
安装依赖
将 🧨 diffusers 库 升级到最新版本:
pip install -U diffusers
运行代码
(可能需要指定可见设备:%env CUDA_VISIBLE_DEVICES=0,以确保 LoRAs 正确加载。)
import torch
from diffusers import StableDiffusion3Pipeline
from peft import PeftModel
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-large",
torch_dtype=torch.float16,
custom_pipeline='quickjkee/swd_pipeline')
pipe = pipe.to("cuda")
lora_path = 'yresearch/swd-large-6-steps'
pipe.transformer = PeftModel.from_pretrained(
pipe.transformer,
lora_path,
)
generator = torch.Generator().manual_seed(10)
prompt = 'A cat holding a sign that reads Sample Faster'
sigmas = [1.0000, 0.9454, 0.8959, 0.7904, 0.7371, 0.6022, 0.0000]
scales = [32, 48, 64, 80, 96, 128]
images = pipe(
prompt,
sigmas=torch.tensor(sigmas).to('cuda'),
timesteps=torch.tensor(sigmas[:-1]).to('cuda') * 1000,
scales=scales,
guidance_scale=0.0,
height=int(scales[0] * 8),
width=int(scales[0] * 8),
generator=generator,
).images
📄 许可证
本项目采用 Apache-2.0 许可证。
📚 引用
如果您在研究中使用了本项目,请使用以下 BibTeX 引用:
@article{starodubcev2025swd,
title={Scale-wise Distillation of Diffusion Models},
author={Nikita Starodubcev and Denis Kuznedelev and Artem Babenko and Dmitry Baranchuk},
journal={arXiv preprint arXiv:2503.16397},
year={2025}
}