Search

Search papers and lessons

Video Diffusion Models

Jonathan Ho, Tim Salimans, Alexey Gritsenko et al. · 2022

Ho and colleagues extend the image diffusion model to video with a space-time 3D U-Net, train it on images and clips together, and extend clips with a guidance method that keeps frames coherent.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Linear algebra
  • Architectures
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

Ho and colleagues (2022) show that the standard diffusion model, with little change, can generate video. The network is an image U-Net whose 2D convolutions and attention are made space-time, so it denoises a block of frames at once. Training on video together with independent images reduces gradient variance and improves sample quality, and a new "reconstruction guidance" method extends clips into longer videos without the frame-to-frame drift of the simpler approach. The models reach state-of-the-art scores on unconditional UCF101 generation and video prediction, and they give first results on text-conditioned video.

Builds on: Denoising Diffusion Probabilistic Models (DDPM), Classifier-Free Guidance, Attention Mechanism, U-Net · Leads to: Latent Diffusion Model

Why it mattered

Image diffusion models had become the leading approach for image generation by 2022, and video was the obvious next medium. The difficulty was not the idea but the cost: a few seconds of video at a usable resolution is a stack of many frames, and a naive model needs memory and compute that grow with each frame. The paper showed that the standard formulation works with an architecture adjusted for that cost, so video needed no new generative theory.

It also set the template for later video generators. The factorised space-time design, in which spatial layers process each frame and temporal layers mix frames, and the practice of training on images and videos together, appear again in the video models that followed. Its conditional sampling method, reconstruction guidance, gave a way to make long videos from short-clip models, which became a standard problem in the field.

The reported numbers were state-of-the-art on the benchmarks the paper used, which gave strong early evidence that diffusion could compete with adversarial models on video quality. On UCF101, the paper's unconditional model had an Inception Score of 57, against 60.2 for real data and 32.97 for the best previous GAN in its table, and a much lower FVD.

The problem

Video is a block of frames, each with height, width and colour. A 16-frame clip at 64 by 64 pixels has 16×64×64×316 \times 64 \times 64 \times 3 numbers, and the frames are strongly correlated. A generator must produce motion that is smooth over time, consistent in identity and lighting, and plausible in each frame. Earlier video generators were autoregressive models, VAEs, GANs and flows, and each had trade-offs in quality, diversity or training stability.

Three practical problems followed. The first is memory: a 3D network over all frames at once is expensive, so the model has to be trained on short clips. The second is length: a model trained on 16 frames has to produce hundreds or thousands of frames for real use, and extending a clip one block at a time tends to drift. The third is data: video datasets are small compared with image datasets, so the paper asks whether image data can help train a video model.

How it works

Take one training step on a tiny instance, with a clip of 16 frames at 64 by 64 pixels.

  1. Noise the clip. Draw a clip x\mathbf{x} from the data and a random time tt between 0 and 1. Add Gaussian noise to get zt=αtx+σtϵ\mathbf{z}_t = \alpha_t \mathbf{x} + \sigma_t \boldsymbol{\epsilon}, where ϵ\boldsymbol{\epsilon} is standard normal noise and αt\alpha_t, σt\sigma_t come from the noise schedule.

    Check: at tt near 0 the clip is almost clean, and at tt near 1 it is almost pure noise, which is the reason the same network can be used at every level.

  2. Predict the clean clip. The 3D U-Net takes zt\mathbf{z}_t, the time λt\lambda_t and any conditioning c\mathbf{c}, and outputs a prediction of the noise. Each 2D convolution 3×33 \times 3 becomes a 1×3×31 \times 3 \times 3 convolution, so it works within each frame. Each spatial attention block then runs over pixels within a frame, and a temporal attention block runs over frames at each pixel. The frame axis is treated as a batch axis in the spatial layers, which is what keeps the cost manageable.

    Check: a clip of 16 frames is processed as 16 images for spatial layers, and as many short sequences of length 16 for temporal layers, so no layer sees the full 16 by 64 by 64 volume at once.

  3. Score the prediction. The loss is the mean squared error between the predicted noise and the true noise, averaged over random tt. Minimising it trains the network to denoise at every level, which is the same objective as for images.

    Check: if the model predicted zero noise everywhere, the loss would be the average squared noise, which is 1 per value for standard normal noise. A trained model does much better.

  4. Add independent images. For joint training, extra randomly chosen images are attached to the end of the clip. The temporal attention is masked so that these images attend only to themselves, which makes them look like single-frame videos to the network. The paper uses 0, 4 or 8 extra images per clip.

    Check: this adds training signal per step without adding frames to the temporal dimension, and the paper reports that it lowers the variance of the gradient at a small cost in bias.

  5. Sample a clip. Start from noise of shape 16 by 64 by 64, and run a denoising sampler. The paper uses an ancestral sampler with 512 steps and a predictor-corrector sampler with Langevin steps. The output is a clip of 16 frames.

  6. Extend the clip. For a longer video, generate a new block conditioned on the last frames of the previous one. The naive method replaces the conditioned frames with forward-noised copies at each step. The paper's reconstruction guidance instead adds a gradient that pulls the model's reconstruction of the conditioned frames towards the known ones.

    Check: with replacement, the generated frames within a block look good, but do not follow the earlier block. With reconstruction guidance, the blocks join smoothly.

flowchart LR
  C[clip of 16 frames plus optional images] --> N[add noise at time t]
  N --> U[3D U-Net: spatial layers then temporal layers]
  U --> P[predicted noise]
  P --> L[mean squared error to true noise]
  U --> S[sampler: denoise from pure noise]
  S --> E[extend with reconstruction guidance]

The math

The forward process adds Gaussian noise to the data. For 0≤s<t≤10 \le s < t \le 1 it satisfies

q(zt∣x)=N(zt; αtx, σt2I),q(\mathbf{z}_t \mid \mathbf{x}) = \mathcal{N}\big(\mathbf{z}_t;\ \alpha_t \mathbf{x},\ \sigma_t^2 \mathbf{I}\big),

where αt\alpha_t and σt\sigma_t define a noise schedule. The log signal-to-noise ratio is λt=log⁡(αt2/σt2)\lambda_t = \log(\alpha_t^2 / \sigma_t^2), which decreases until the end of the process is close to standard normal noise. The paper's specific schedule is a cosine schedule.

Step 1 in symbols: the noisy clip

zt=αtx+σtϵ\mathbf{z}_t = \alpha_t \mathbf{x} + \sigma_t \boldsymbol{\epsilon}, with ϵ∼N(0,I)\boldsymbol{\epsilon} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}). This is a Gaussian with mean αtx\alpha_t \mathbf{x} and variance σt2\sigma_t^2 per value. Here x\mathbf{x} is the whole clip, a tensor of shape frames by height by width by channels.

Step 2 in symbols: the prediction

The network predicts the noise, and the clean clip is recovered from the prediction by inverting the noising equation:

x^θ(zt)=zt−σt ϵθ(zt)αt.\hat{\mathbf{x}}_\theta(\mathbf{z}_t) = \frac{\mathbf{z}_t - \sigma_t\, \boldsymbol{\epsilon}_\theta(\mathbf{z}_t)}{\alpha_t}.

This is the ϵ\epsilon-prediction parameterisation. The link to the score is that ϵθ(zt)≈−σt∇ztlog⁡p(zt)\boldsymbol{\epsilon}_\theta(\mathbf{z}_t) \approx -\sigma_t \nabla_{\mathbf{z}_t} \log p(\mathbf{z}_t), as in the score of the noisy data.

Step 3 in symbols: the loss

Training minimises the expected squared error in noise space over uniform tt,

L(θ)=Ex,ϵ,t[ ∥ϵθ(zt)−ϵ∥22].\mathcal{L}(\theta) = \mathbb{E}_{\mathbf{x}, \boldsymbol{\epsilon}, t}\Big[\, \big\| \boldsymbol{\epsilon}_\theta(\mathbf{z}_t) - \boldsymbol{\epsilon} \big\|_2^2 \Big].

The paper notes that this is a weighted variational bound on the log likelihood, which is why the loss is principled rather than ad hoc.

Step 5 in symbols: classifier-free guidance

For conditional clips, with conditioning c\mathbf{c} such as a caption, the sampler uses a mixture of the conditional and unconditional predictions:

ϵ~θ(zt,c)=(1+w) ϵθ(zt,c)−w ϵθ(zt).\tilde{\boldsymbol{\epsilon}}_\theta(\mathbf{z}_t, \mathbf{c}) = (1 + w)\, \boldsymbol{\epsilon}_\theta(\mathbf{z}_t, \mathbf{c}) - w\, \boldsymbol{\epsilon}_\theta(\mathbf{z}_t).

A guidance weight w>0w > 0 pushes samples harder towards the condition, which raises sample quality and lowers diversity.

Step 6 in symbols: reconstruction guidance

For a clip with known frames xa\mathbf{x}^a, the model's reconstruction of those frames is x^θa(zt)\hat{\mathbf{x}}^a_\theta(\mathbf{z}_t), obtained by the same network. The guided prediction adds a gradient that lowers the mismatch:

x~θ(zt)=x^θ(zt)−wrαt2∇zt∥xa−x^θa(zt)∥22.\tilde{\mathbf{x}}_\theta(\mathbf{z}_t) = \hat{\mathbf{x}}_\theta(\mathbf{z}_t) - \frac{w_r \alpha_t}{2} \nabla_{\mathbf{z}_t} \big\| \mathbf{x}^a - \hat{\mathbf{x}}^a_\theta(\mathbf{z}_t) \big\|_2^2.

The weight wrw_r controls how strongly the known frames pull the sample. The method is derived from the score of the conditional distribution, and it is the term that the replacement method leaves out.

Results

Unconditional generation on UCF101 (Table 1). The model generates 16-frame clips at 64 by 64 pixels. Its Inception Score is 57±0.6257 \pm 0.62, close to the real-data value of 60.2, and well above the best previous entries in the table, such as TGAN-v2 at 28.87 and DVD-GAN at 32.97 for 128 by 128 clips. Its FVD is 295 ± 3, against 3,431 and 3,497 for the two TGAN-v2 entries in the same table. The comparison uses different resolutions and metrics, so the paper's claim is about the table as a whole.

Video prediction on Kinetics-600 (Table 3). Predicting 11 frames from 5 frames, with FVD on 50,000 test videos, the best model-based settings reached FVD 66.92 with a Langevin sampler at 256 steps and 68.19 with an ancestral sampler at 512 steps. The best earlier entry in the table is NUWA at 86.9.

Joint image and video training (Table 4). On text-conditioned 16-frame clips, adding 0, 4 and 8 independent images per clip lowers FVD from 202 to 68 to 58, with corresponding gains in the image metrics.

Classifier-free guidance (Table 5). At frameskip 1, raising the guidance weight from 1 to 2 to 5 raises the Inception-style score from 10.80 to 13.22 to 14.80, while the FVD first rises from 41.65 to 50.19 and then to 163.74. The sample quality metrics move in different directions, which is why the paper reports both.

Long videos (Table 6, Figure 4). Extending 16-frame blocks to 64-frame videos with guidance weight 2, reconstruction guidance gives FVD 136 against 451 for replacement. At weight 5 the figures are 134 against 456. The FID and Inception numbers follow the same direction.

Limits. The experiments are on short clips at low resolution, mostly 64 by 64 pixels. Video length is handled by extension rather than by a model that sees the whole video.

Tradeoffs and when to use it

It is tempting to think a video diffusion model is just an image model with more frames. In fact the frame axis changes the cost, so the factorised space-time layers and the short training clips are what make it work. A full 3D attention over all frames would cost far more.

A common mistake is to read the FVD and Inception numbers as a single measure of quality. They measure different things, and the guidance table shows that a higher score on one can come with a worse score on another. Check several metrics and look at samples.

Use this approach when you need a video generator built on the same machinery as an image model, and when clips of modest length are enough. Use the extension method for longer videos, with reconstruction guidance rather than replacement. Do not use it when real-time generation or very long coherent videos are the goal. Alternatives include latent video models, which compress frames before diffusion, and autoregressive video models, which generate one frame or block at a time.

Reading guide

Check yourself

QuestionRecall: why does the 3D U-Net use spatial attention within each frame and temporal attention across frames, instead of full attention over all frames?Show answer

Full attention over every pixel of every frame is very costly, because the cost grows with the square of the number of positions. Factorising it into spatial layers, which treat frames as a batch, and temporal layers, which work along the time axis at each pixel, keeps each layer's cost manageable while still letting information flow across time.

QuestionComputation: αt=0.6\alpha_t = 0.6, σt=0.8\sigma_t = 0.8, the clean value is x=1x = 1 and the noise is ϵ=0.5\epsilon = 0.5. What is ztz_t, and does the ϵ\epsilon-prediction formula recover xx?Show answer

zt=0.6×1+0.8×0.5=1.0z_t = 0.6 \times 1 + 0.8 \times 0.5 = 1.0. Using the prediction formula with the true noise, x^=(zt−σtϵ)/αt=(1.0−0.4)/0.6=1.0\hat{x} = (z_t - \sigma_t \epsilon)/\alpha_t = (1.0 - 0.4)/0.6 = 1.0. It recovers xx exactly, as it should when the noise prediction is correct.

QuestionWhy does the replacement method for extending clips fail, even though the frames it generates look good individually?Show answer

Replacement overwrites the known frames with forward-noised copies at each sampling step, so the model never has to make its own reconstruction of those frames agree with them, and the new block is not pushed to match the previous one. Reconstruction guidance adds a gradient that depends on how well the model reconstructs the known frames, so the new frames are pulled towards consistency with them.

QuestionA team wants to generate 10-second clips from a model trained on 16-frame clips, with a text prompt. Would this paper's approach be a reasonable base, and what would they check first?Show answer

Yes, it is a reasonable base: the paper gives a conditional model and an extension method built for exactly this length gap. Before committing, they should check the clip quality at the frame rate they need, and check that the extension keeps identity and motion across block boundaries using the same kind of measure the paper uses (FVD) plus visual inspection, since different metrics can disagree.

Sources

Read the full paper

Jonathan Ho, Tim Salimans, Alexey Gritsenko et al., 2022. arXiv:2204.03458