
UNet2DConditionModel
Diffusion and generative1,209 ops872.3M params
The cross-attention UNet that denoises in a pretrained autoencoder's latent space, as in Stable Diffusion.
Diffusion and generative · 1,209 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Latent diffusion models (LDMs) start from a cost problem: because diffusion models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. The fix is to apply them in the latent space of powerful pretrained autoencoders. Training is split into two distinct phases, where first an autoencoder is trained that provides a lower-dimensional representational space which is perceptually equivalent to the data space. That autoencoder comes in two regularized variants: the KL variant imposes a slight KL-penalty towards a standard normal on the learned latent, whereas the VQ variant uses a vector quantization layer within the decoder.
The neural backbone of the model is realized as a time-conditional UNet. To accept conditioning beyond class labels, the authors augment the underlying UNet backbone with the cross-attention mechanism. A domain specific encoder projects the conditioning input to an intermediate representation, which is then mapped to the intermediate layers of the UNet via cross-attention. This turns diffusion models into flexible generators for general conditioning inputs such as text or bounding boxes, and high-resolution synthesis becomes possible in a convolutional manner. Comparing downsampling factors, LDM-4 and -8 offer the best conditions for achieving high-quality synthesis results. On CelebA-HQ the paper reports a new state-of-the-art FID of 5.11, outperforming previous likelihood-based models as well as GANs.
The captured member is the UNet in the Stable Diffusion configuration. Stable Diffusion v1 is a specific configuration that uses a downsampling-factor 8 autoencoder with an 860M UNet and a CLIP ViT-L/14 text encoder. It is conditioned on the non-pooled text embeddings of that text encoder, and the model was pretrained on 256x256 images and then finetuned on 512x512 images. The diffusion codebase builds heavily on OpenAI's ADM codebase.
Key idea. LDMs train diffusion models on a pretrained autoencoder's latent representation, which the paper says allows for the first time to reach a near-optimal point between complexity reduction and detail preservation. Cross-attention layers in the UNet make the same backbone a general conditional generator for inputs such as text or bounding boxes.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{rombach2022highresolutionimagesynthesislatent,
title={High-Resolution Image Synthesis with Latent Diffusion Models},
author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
year={2022},
eprint={2112.10752},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2112.10752},
}