Latent Diffusion Models

Machine Learning
Introduced by
Robin Rombach
Year
2022
Type
Neural network architecture
Family
Deep Learning, Generative Models

What does it do?

Latent Diffusion Models (LDMs) are generative models introduced by Rombach, Blattmann, Lorenz, Esser and Ommer and published at CVPR 2022.

Instead of running the diffusion process on pixels, they train the diffusion model in the latent space of a pretrained autoencoder, which the cited abstract reports as significantly reducing computational requirements compared with pixel-based diffusion models. Cross-attention layers allow the same architecture to be conditioned on inputs such as text or bounding boxes.

The intuition behind the method

Diffusion models generate images by iteratively denoising random noise. The cited abstract notes that working directly in pixel space makes optimisation very costly, with powerful models often requiring hundreds of GPU days, and that inference is expensive because generation involves sequential evaluations. LDMs instead train the diffusion model on the latent representation produced by a pretrained autoencoder, which the authors describe as reaching a near-optimal balance between complexity reduction and detail preservation. Because denoising runs on this smaller representation, training and sampling need less computation than in pixel space. Cross-attention layers let the denoiser accept conditioning inputs, so one framework covers several generation tasks.

History

Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser and Björn Ommer introduced Latent Diffusion Models in the paper “High-Resolution Image Synthesis with Latent Diffusion Models”, published at CVPR 2022. The cited abstract presents the method as applying diffusion models in the latent space of pretrained autoencoders, with cross-attention layers added to support general conditioning. Stable Diffusion, which the page lists as an alias, is named among notable recent text-to-image generative models, and a related study notes that the work of Rombach et al. gave rise to the popular latent diffusion approach.

When to use it

Choose LDMs for image generation tasks that need high visual quality, including text-to-image generation, image inpainting, super-resolution, and class-conditional or unconditional synthesis, which are the tasks the cited abstract reports. They are a suitable choice when conditioning inputs such as text or bounding boxes must steer the output, and when pixel-space diffusion is too costly to train or run. Pixel-space diffusion is the alternative when computation is not the constraint and the model must work directly on pixels, for instance when the reconstruction limits of an autoencoder would be unacceptable for the required detail. LDMs are a poor fit when inference latency is the main constraint, because sampling requires many sequential denoising evaluations.

Limitations and considerations

  • Output quality is bounded by the pretrained autoencoder: the diffusion model can only produce detail that the latent space and decoder are able to represent.
  • Training involves two networks, an autoencoder and a diffusion model, so substantial data and compute are still needed even though the latent approach reduces the cost of pixel-space diffusion.
  • Sampling is iterative and sequential, which the cited abstract identifies as a source of expensive inference; LDMs are therefore slower at generation than single-pass generators.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Diffusion runs on a compressed latent representation rather than full-resolution pixels, which the cited abstract reports as significantly reducing computational requirements relative to pixel-based diffusion models.
  • Adding cross-attention layers to the architecture allows general conditioning inputs such as text or bounding boxes to guide generation.
  • The cited abstract reports new state-of-the-art scores for image inpainting and class-conditional synthesis, and highly competitive performance on unconditional generation, text-to-image synthesis and super-resolution.
  • The abstract reports that high-resolution synthesis becomes possible in a convolutional manner, which is a stated feature of the architecture.

Applications

  • Text-to-image generation, with text embeddings supplied through cross-attention layers
  • Image inpainting, where the cited abstract reports state-of-the-art results
  • Super-resolution
  • Class-conditional and unconditional image synthesis
  • Image generation guided by bounding boxes or other conditioning inputs

How it works

How it works

1

A pretrained autoencoder maps the input image to a lower-dimensional latent representation. The representation is meant to keep the visual information needed for generation while reducing the amount of data the diffusion model must process.

2

The diffusion model is trained to denoise latent vectors step by step, reversing the noise added at each diffusion step. The cited abstract describes diffusion models as a sequential application of denoising autoencoders. Conditioning information, such as text embeddings, is supplied through cross-attention layers in the architecture.

3

At generation time, sampling starts from random noise in the latent space and applies the learned denoising steps in sequence to produce a clean latent representation. Each step depends on the previous one, so these evaluations cannot be run in parallel across steps.

4

The decoder of the autoencoder maps the final latent representation back to pixel space, producing the output image.

Common pitfalls

  • The diffusion model operates in the autoencoder's latent space, so the autoencoder's reconstruction limits can constrain the detail available in generated images. The cited abstract frames the autoencoder as a trade-off between complexity reduction and detail preservation.
  • Training on small datasets risks overfitting, a general concern for large generative models, so results on limited data should be checked on held-out images.

Frequently asked questions

What is the latent space and why is it important?

The latent space is the compressed representation produced by a pretrained autoencoder. The diffusion model runs in this space rather than on raw pixels, which the cited abstract reports as significantly reducing computational requirements. The autoencoder's decoder then maps the generated latent back to an image.

How does conditioning work in latent diffusion models?

Conditioning inputs such as text embeddings are introduced through cross-attention layers added to the architecture. These layers let the denoiser use the conditioning signal while it denoises. The cited abstract describes this mechanism for general conditioning inputs, including text and bounding boxes.

Why use latent rather than pixel-space diffusion?

The cited abstract's motivation is that pixel-space diffusion models are expensive to optimise and to sample from. Working in a latent space reduces complexity while the authors report retaining detail. The abstract emphasises large reductions in computational requirements together with high visual fidelity and benchmark results on specific tasks, so the advantage over pixel-space diffusion is best judged per task and per metric.

Related methods

Sources

  1. Rombach, R., Blattmann, A., Lorenz, D., Esser, P., & Ommer, B. (2022). High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 10684-10695).

    Open DOI reference
  2. Intelligent-and-Fuzzy-Systems, p. 191