🚀 Deep Compression Autoencoder for Efficient High-Resolution Diffusion Models
高解像度拡散モデルを高速化するための新しいオートエンコーダモデル、Deep Compression Autoencoder (DC - AE) を紹介します。DC - AE は、高い空間圧縮率でも再構成精度を維持し、拡散モデルの推論と訓練を大幅に高速化します。
[論文] [GitHub]

図1: 高い空間圧縮率のオートエンコーダの再構成精度の低下問題を解決します。

図2: DC - AE は、性能を低下させることなく、訓練と推論の速度を大幅に向上させます。

図3: DC - AE は、ラップトップでの効率的なテキストから画像への生成を可能にします。
📚 ドキュメント
概要
我々は、高解像度拡散モデルを高速化するための新しいオートエンコーダモデルのファミリーである Deep Compression Autoencoder (DC - AE) を提案します。既存のオートエンコーダモデルは、中程度の空間圧縮率(例えば、8倍)では印象的な結果を示しますが、高い空間圧縮率(例えば、64倍)では十分な再構成精度を維持できません。我々は、この課題に対して2つの重要な技術を導入します。(1) Residual Autoencoding:空間 - チャネル変換された特徴に基づいて残差を学習するようにモデルを設計し、高い空間圧縮率のオートエンコーダの最適化の難しさを軽減します。(2) Decoupled High - Resolution Adaptation:高い空間圧縮率のオートエンコーダの汎化ペナルティを軽減するための効率的な3段階の訓練戦略です。これらの設計により、我々は再構成品質を維持しながら、オートエンコーダの空間圧縮率を最大128倍に向上させます。我々の DC - AE を潜在拡散モデルに適用することで、精度を低下させることなく大幅な高速化を達成します。例えば、ImageNet 512x512 では、広く使用されている SD - VAE - f8 オートエンコーダと比較して、UViT - H で H100 GPU 上で19.1倍の推論速度向上と17.9倍の訓練速度向上を達成し、より良い FID を達成します。
💻 使用例
基本的な使用法
Deep Compression Autoencoder
from efficientvit.ae_model_zoo import DCAE_HF
dc_ae = DCAE_HF.from_pretrained(f"mit-han-lab/dc-ae-f64c128-in-1.0")
from PIL import Image
import torch
import torchvision.transforms as transforms
from torchvision.utils import save_image
from efficientvit.apps.utils.image import DMCrop
device = torch.device("cuda")
dc_ae = dc_ae.to(device).eval()
transform = transforms.Compose([
DMCrop(512),
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
])
image = Image.open("assets/fig/girl.png")
x = transform(image)[None].to(device)
latent = dc_ae.encode(x)
print(latent.shape)
y = dc_ae.decode(latent)
save_image(y * 0.5 + 0.5, "demo_dc_ae.png")
Efficient Diffusion Models with DC - AE
from efficientvit.diffusion_model_zoo import DCAE_Diffusion_HF
dc_ae_diffusion = DCAE_Diffusion_HF.from_pretrained(f"mit-han-lab/dc-ae-f64c128-in-1.0-uvit-h-in-512px-train2000k")
import torch
import numpy as np
from torchvision.utils import save_image
torch.set_grad_enabled(False)
device = torch.device("cuda")
dc_ae_diffusion = dc_ae_diffusion.to(device).eval()
seed = 0
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
eval_generator = torch.Generator(device=device)
eval_generator.manual_seed(seed)
prompts = torch.tensor(
[279, 333, 979, 936, 933, 145, 497, 1, 248, 360, 793, 12, 387, 437, 938, 978], dtype=torch.int, device=device
)
num_samples = prompts.shape[0]
prompts_null = 1000 * torch.ones((num_samples,), dtype=torch.int, device=device)
latent_samples = dc_ae_diffusion.diffusion_model.generate(prompts, prompts_null, 6.0, eval_generator)
latent_samples = latent_samples / dc_ae_diffusion.scaling_factor
image_samples = dc_ae_diffusion.autoencoder.decode(latent_samples)
save_image(image_samples * 0.5 + 0.5, "demo_dc_ae_diffusion.png", nrow=int(np.sqrt(num_samples)))
🔖 参考文献
もし DC - AE があなたの研究に有用または関連する場合、以下の論文を引用することで我々の貢献を認識していただけると幸いです。
@article{chen2024deep,
title={Deep Compression Autoencoder for Efficient High-Resolution Diffusion Models},
author={Chen, Junyu and Cai, Han and Chen, Junsong and Xie, Enze and Yang, Shang and Tang, Haotian and Li, Muyang and Lu, Yao and Han, Song},
journal={arXiv preprint arXiv:2410.10733},
year={2024}
}
📄 ライセンス
このプロジェクトは MIT ライセンスの下で公開されています。