XYZNOT

Papers · arXiv 2112.10752

High-Resolution Image Synthesis with Latent Diffusion Models

Published cs.CV arXivPDF

Read with translation and AI

Summary in three lines

  1. 🎯 Standard pixel-space diffusion models waste massive compute and memory modeling imperceptible high-frequency details across iterative denoising steps.
  2. 🔧 Decouple perceptual compression from generative modeling by training diffusion models inside the lower-dimensional latent space of pretrained autoencoders using cross-attention conditioning.
  3. 📈 Achieved state-of-the-art FID of 5.11 on CelebA-HQ, 3.60 FID on class-conditional ImageNet 256x256, and cut training and inference compute by multiples compared to pixel-space diffusion models.

Abstract

By decomposing the image formation process into a sequential application of denoising autoencoders, diffusion models (DMs) achieve state-of-the-art synthesis results on image data and beyond. Additionally, their formulation allows for a guiding mechanism to control the image generation process without retraining. However, since these 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. To enable DM training on limited computational resources while retaining their quality and flexibility, we apply them in the latent space of powerful pretrained autoencoders. In contrast to previous work, training diffusion models on such a representation allows for the first time to reach a near-optimal point between complexity reduction and detail preservation, greatly boosting visual fidelity. By introducing cross-attention layers into the model architecture, we turn diffusion models into powerful and flexible generators for general conditioning inputs such as text or bounding boxes and high-resolution synthesis becomes possible in a convolutional manner. Our latent diffusion models (LDMs) achieve a new state of the art for image inpainting and highly competitive performance on various tasks, including unconditional image generation, semantic scene synthesis, and super-resolution, while significantly reducing computational requirements compared to pixel-based DMs. Code is available at https://github.com/CompVis/latent-diffusion .

Reading guide

Problem and motivation

Diffusion probabilistic models generate high-fidelity, mode-covering imagery by inverting a forward noise process with a sequence of denoising autoencoders. However, training and evaluating them directly in high-dimensional RGB pixel space is computationally demanding. Optimization often takes hundreds of GPU days (e.g., 150 to 1000 V100 days), and multi-step sequential sampling can take days for standard evaluation runs. Because likelihood-based generative modeling spends excessive capacity on high-frequency imperceptible image details before learning semantic structures, direct pixel-space evaluations lead to wasteful gradient and function evaluations.

Key ideas

  • Two-stage decomposition: Separate perceptual compression (eliminating imperceptible details) from semantic generative modeling (learning image structure and composition).
  • Latent Diffusion Models (LDMs): Train denoising diffusion models inside the latent space of an autoencoder trained with perceptual and adversarial losses.
  • Moderate spatial compression: Unlike autoregressive models that need heavy spatial reduction (e.g., or ), LDMs maintain spatial inductive bias with a 2D convolutional UNet, allowing moderate downsampling factors like or that preserve fine details.
  • Universal cross-attention conditioning: Generalize UNets to multimodal inputs (text descriptions, bounding boxes, semantic maps) using domain-specific encoders mapped into intermediate network layers via cross-attention.

Method

  1. Perceptual Image Compression: An encoder maps an image to a lower-dimensional latent representation , where downsampling factor . A decoder reconstructs . The model is regularized using either a weak KL-divergence penalty towards (KL-reg.) or vector quantization (VQ-reg.) absorbed into the decoder.

  2. Generative Latent Modeling: A time-conditional UNet is trained on the latents using the reweighted denoising objective:

  3. Cross-Attention Conditioning: For conditioning input (e.g., text, classes, layouts), a domain encoder is introduced. Intermediate UNet features interact with conditioning via cross-attention: where , , and . The conditional objective is:

Results

  • Perceptual compression trade-off: Downsampling factors and strike the best balance between reconstruction accuracy, synthesis quality, and throughput. On ImageNet, an FID gap of 38 points separates pixel-based LDM-1 from LDM-8 after 2M training steps under identical computational budgets.
  • Unconditional generation: Achieved state-of-the-art FID of on CelebA-HQ (), on FFHQ, on LSUN-Churches, and on LSUN-Bedrooms.
  • Class-conditional ImageNet: LDM-4 with classifier-free guidance reached an FID of and Inception Score of , outperforming ADM () while requiring fewer parameters (400M vs. 608M) and substantially less training compute (271 vs. 962 V100 days).
  • Text-to-image: A 1.45B parameter model (LDM-KL-8-G) achieved an FID of on MS-COCO with 250 DDIM steps.
  • Super-resolution and inpainting: LDM-4 set a new state-of-the-art inpainting FID of on Places (and on hard 40–50% masked images), while operating at over higher throughput than pixel-space diffusion.

Limitations and open questions

  • Sampling latency: While significantly faster than pixel-based diffusion models, sequential multi-step sampling is still slower than single-pass GAN generators.
  • Reconstruction bottleneck: Even with low downsampling (), compression can lose fine-grained high-frequency pixel details, making it slightly suboptimal for ultra-precise pixel-critical tasks.
  • Societal impact & safety: Lower compute barriers democratize creative tools but also ease creation of deepfakes and misuse, while potentially inheriting biases from uncurated web-scale training datasets.

Key terms

Latent Diffusion Models (LDMs)
Diffusion models trained inside a lower-dimensional, perceptually equivalent latent space provided by a trained autoencoder.
Perceptual Image Compression
A first-stage autoencoding model trained with perceptual and patch-based adversarial losses that removes imperceptible high-frequency noise from images.
Cross-Attention
An attention mechanism incorporated into UNet intermediate layers where queries come from image representations and keys/values come from conditioning representations.
Downsampling Factor ($f$)
The spatial scaling ratio between the original pixel dimensions and the autoencoder latent grid dimensions.
KL-reg. / VQ-reg.
The latent space regularization schemes tested: a mild Kullback-Leibler penalty toward a standard normal, or a vector quantization codebook layer absorbed into the decoder.
Classifier-Free Guidance
A sampling technique that jointly evaluates conditioned and unconditioned model predictions to steer generation quality without a separate classifier network.
Convolutional Sampling
Evaluating a convolutional UNet model on larger spatial grids than seen during training to generate high-resolution or megapixel imagery in tasks like semantic synthesis or super-resolution.

Questions

Why train diffusion models in latent space instead of raw pixel space?

Pixel-space diffusion wastes substantial computation repeatedly calculating gradients and evaluating networks on imperceptible high-frequency image details. By shifting into an autoencoder's latent space, the generative model focuses purely on semantic concepts with much smaller feature maps, accelerating both training and inference.

How does conditioning on non-image data like text work in LDMs?

Non-image conditions are tokenized and processed by a domain-specific encoder (such as a BERT-tokenized Transformer for text) into an intermediate representation. This representation is injected into the UNet backbone via cross-attention layers.

What downsampling factor $f$ provides the best performance?

Downsampling factors of and strike the best balance. Smaller factors () retain too much perceptual compression for the diffusion model and train slowly, whereas larger factors () lose too much spatial detail in the first stage, capping synthesis quality.

Can Latent Diffusion Models generate images larger than their training resolution?

Yes. For spatially conditioned tasks (such as semantic synthesis, inpainting, and super-resolution), the convolutional nature of the UNet enables convolutional sampling over larger latent grids, rendering coherent images at or megapixel sizes from models trained at .

The overview on this page was written by AI from the paper and may contain mistakes. Read the paper for the details.

Read with translation and AI