🚀 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-4-steps'
pipe.transformer = PeftModel.from_pretrained(
pipe.transformer,
lora_path,
)
generator = torch.Generator().manual_seed(1)
prompt = 'A cat holding a sign that reads Sample Faster'
sigmas = [1.0000, 0.8959, 0.7371, 0.6022, 0.0000]
scales = [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}
}