71 min total

Generative AI

Latent diffusion: paper notes

Latent diffusion: paper notes

Paper introduces Latent diffusion models, which improves efficiency and quality of DMs, instead of working at pixel level, they utilize latent space which drastically reduces computational costs while preserving high visual fidelity.

What does conditioning/conditional generation means?

Unconditional generation:

Conditional generation:

Conditioning means generating output based on some conditions

GenAI / Assignments — Latent diffusion: paper notes — notes

Recap: Attention = What parts of input are most relevant at any moment

Cross Attention?

Is an attention mechanism where the queries come from one input/modality, keys and queries come from different input/modality. Allows one input to learn and incorporate relevant information from another input

Self-Attention?

Special case of attention where QKV all come from same input allows us to capture dependencies regardless of their distance in the same sequence

Tou whats Attention?

Umbrella term under which cross attention and self attention comes, Q and KV can come from different sources or can be from the same source doesn’t matter.

Whats wrong with image synthesis before?

  1. High resolution image synthesis is computationally expensive
  2. GANs struggle with mode collapse
  3. Diffusion models SOTA performance but very computationally expensive

Why computational efficiency important?

  1. Training DMs take hundreds/thousands of GPU days
  2. Only organizations with access to massive computational resources can afford to train or use these models
  3. Leads to high carbon emission

Key contributions of this paper

  1. Their approach scales better to high-dimensional data by using mild-compression
  2. Despite matching performance on SOTA models, reduces computational power
  3. Extremely faithful reconstructions
  4. Incorporates different input modalities using cross attention mechanism
  5. Provides link to pretrained latent diffusion models

Existing solutions for image generation tasks

  1. VQVAEs converts images into latent space then uses autoregressive models to generate images, another study extends VQVAE by learning a joint distribution over image and text tokens, another study uses conditionally invertible functions to map between different latent spaces to provide flexibility across domains
  2. VQGANs adds adversarial loss instead of VAEs
  3. Diffusion models exist but are compute heavy

Method

Compression stage: auto encoder compresses the high-dim image into low-dim latent, involves an autoencoder

Generation stage: diffusion model operates within this latent space performing generative process, involves a UNET and cross attention mechanism

How does the architecture does the conditioning?

Can do

Z = latent representation

Y = conditioning input (text, semantic maps)

Author augments Unet backbone with a cross-attention mechanism which involves conditioning input y and projects in into intermediate representation

Cross attention layer integrates intermediate representation into Unets intermediate layers using attention formulae

GenAI / Assignments — Latent diffusion: paper notes — notes
GenAI / Assignments — Latent diffusion: paper notes — notes

Experiments

  1. Experimented with downsampling factors 1,2,4,8,16,32

LDM1 represents pixel based diffusion model without any compression

LDM2 to LDM32 represents increasing levels of compression

  1. Each model were trained on a single NVIDIA A100 GPU, underwent same number of training steps, number of parameters was kept the same
  2. Evaluated on MS-COCO, dataset for text-to-image generation

FID scores (the lower the better) were best at LDM-8, LDM-32 had very high FID scores

Text prompts are encoded using BERT tokenizer, representation is injected into UNET through multi head cross attention layers

Trained on low res, and can generalize to higeher resolutions during inference because Unet is fully convolutional, once trained on 256^2 we can sample on bigger images wihtout training.

GenAI / Assignments — Latent diffusion: paper notes — notes