Search

Search papers and lessons

DreamFusion: Text-to-3D using 2D Diffusion

Ben Poole, Ajay Jain, Jonathan T. Barron et al. · 2022

DreamFusion optimises a NeRF so that its random-view renders look plausible to a frozen 2D text-to-image diffusion model, using no 3D training data.

On this page

  • Colour = topic mix
  • Probability
  • Linear algebra
  • Architectures
  • Calculus
  • Discrete math
  • Generative models
  • ReadReady to readNot yet

TL;DR

DreamFusion makes a 3D model from a text prompt without any 3D training data. It starts with a randomly initialised neural radiance field (NeRF), renders it from random camera angles, and adjusts the NeRF so that each rendering looks like a good image to a frozen pretrained text-to-image diffusion model. The key step is a loss called score distillation sampling, which turns the diffusion model's denoising direction into a gradient for the 3D parameters.

Builds on: NeRF, Imagen, Diffusion Model, Classifier-Free Guidance · Leads to: Score Distillation Sampling, the loss this paper introduces and later text-to-3D methods reuse

Why it mattered

Before this paper, text-to-3D generation was slow or weak. Dream Fields used CLIP to score renderings of a NeRF. CLIP measures how well an image matches a caption, so it gives no generative image prior. DreamFusion showed that a 2D image model trained on billions of image-text pairs could supervise 3D synthesis directly, so no 3D dataset was needed. Its results were judged on CLIP R-Precision and on a set of renderings from random viewpoints, and they beat the Dream Fields and CLIP-Mesh baselines on colour images.

The paper set a template that many later systems follow: a frozen 2D diffusion model as the critic, a differentiable 3D representation as the generator, and a loss applied to renderings from random cameras. The gradient it uses is the same one later reused for other parameterised images, which is why the loss has its own name.

History

Diffusion models were already the standard for text-to-image generation by 2022. The open problem was how to sample from them when the output is not pixels. Dream Fields had shown that a pretrained image-text model could guide a NeRF, but it used CLIP, a model that scores match rather than generating images. DreamFusion replaced that scorer with a diffusion model, and the change from a discriminative score to a denoising direction is the paper's main step.

The problem

A diffusion model generates by starting from noise and removing it step by step. It is trained on pixels, so its natural output is an image. To make a 3D object, one needs a different kind of sampling: optimise the parameters of a 3D generator so that its renderings are plausible. For that, the loss must be low for good images and high for bad ones, and it must be differentiable with respect to the 3D parameters.

Two obstacles stood in the way. Training a 3D generator on 3D data was impossible at scale, because such data is scarce compared with 2D images. And the obvious loss, the diffusion training objective, has a gradient that requires backpropagation through the diffusion network, which is expensive and poorly conditioned at small noise levels. The paper's question is whether a cheaper gradient, without that backpropagation, still moves the 3D parameters in a useful direction.

How it works

Trace one optimisation step for the prompt "a DSLR photo of a peacock on a surfboard".

  1. Start from noise. The NeRF has random weights. Its output at the start is noise, not an object.
  2. Pick a random camera and light. The camera sits at a random elevation, azimuth and distance, and the light direction is random too.
  3. Render an image. The NeRF is rendered at 64 by 64 pixels from that camera. The renderer is randomly chosen to show the lit colour, a textureless shaded view, or the albedo colour alone.
  4. Add noise to the render. Pick a random noise level tt, add Gaussian noise to the rendered image, and get a noisy image zt\mathbf{z}_t.
  5. Ask the frozen diffusion model what the noise is. Pass zt\mathbf{z}_t, the prompt, and the view-dependent text (for example "side view") to the frozen Imagen model. It predicts the noise ϵ^\hat{\epsilon}.
  6. Form the update direction. Compare the predicted noise with the noise that was actually added. The difference points toward a version of the image the diffusion model considers more plausible.
  7. Push the 3D parameters. Use the chain rule through the renderer alone, not through the diffusion network, to turn that image-space direction into a gradient for the NeRF weights, and take one optimiser step.
  8. Repeat for 15,000 iterations. Each pass applies one small update, and the object takes shape over the whole run. The whole run takes about 1.5 hours on four TPU v4 chips, as the paper reports.
flowchart LR
  N[NeRF with random weights] --> R[render from random camera]
  R --> Z[add noise at level t]
  Z --> D[frozen Imagen predicts noise]
  D --> G[noise difference as image-space direction]
  G --> B[chain rule through the renderer]
  B --> N

The diffusion model acts as a fixed critic. It never changes, and no 3D data enters at any point.

The math

The symbols follow the paper. The generator gg maps parameters θ\theta to an image x=g(θ)\mathbf{x} = g(\theta), here a rendering of the NeRF.

Step 5 in symbols: the noisy image and the noise prediction

The forward process gives zt=αtx+σtϵ\mathbf{z}_t = \alpha_t \mathbf{x} + \sigma_t \epsilon, with ϵ\epsilon a standard Gaussian noise sample. The diffusion network predicts the noise, ϵ^ϕ(zt;y,t)\hat{\epsilon}_\phi(\mathbf{z}_t; y, t), where yy is the text embedding and ϕ\phi the frozen weights. With classifier-free guidance at scale ω\omega, the guided prediction is

ϵ^ϕ(zt;y,t)=(1+ω) ϵϕ(zt;y,t)−ω ϵϕ(zt;t).\hat{\epsilon}_\phi(\mathbf{z}_t; y, t) = (1 + \omega)\, \epsilon_\phi(\mathbf{z}_t; y, t) - \omega\, \epsilon_\phi(\mathbf{z}_t; t).

A large ω\omega improves quality, and the paper reports that it matters for this task.

Step 6 and 7 in symbols: the score distillation gradient

The paper's gradient is

∇θLSDS=Et,ϵ[w(t) (ϵ^ϕ(zt;y,t)−ϵ) ∂x∂θ],\nabla_\theta \mathcal{L}_{\text{SDS}} = \mathbb{E}_{t, \epsilon}\left[ w(t)\, \big(\hat{\epsilon}_\phi(\mathbf{z}_t; y, t) - \epsilon\big)\, \frac{\partial \mathbf{x}}{\partial \theta} \right],

where w(t)w(t) is a weighting that depends on the noise level. The term ϵ^ϕ−ϵ\hat{\epsilon}_\phi - \epsilon is the noise residual. The Jacobian of the diffusion network is left out, which is what makes the gradient cheap. The paper shows in its appendix that this expression is the gradient of a weighted KL divergence between Gaussians centred on the rendering and the diffusion model's density, which is where "distillation" comes from.

A tiny numerical step

Take one pixel, one parameter, w(t)=1w(t) = 1, the noise residual ϵ^−ϵ=0.5−0.2=0.3\hat{\epsilon} - \epsilon = 0.5 - 0.2 = 0.3, and ∂x/∂θ=2\partial x / \partial \theta = 2.

  1. The gradient is 1×0.3×2=0.61 \times 0.3 \times 2 = 0.6.
  2. With a learning rate of 0.1, the update is θ←θ−0.1×0.6=θ−0.06\theta \leftarrow \theta - 0.1 \times 0.6 = \theta - 0.06.
  3. The parameter moves so that the pixel value moves in the direction the diffusion model prefers.

Interpretation: the diffusion model never sees gradients through its own network. It only supplies the sign and size of a residual, and the renderer carries that back to the 3D parameters.

Step 3 in symbols: volume rendering

The NeRF renders a pixel by compositing samples along the ray. With density τi\tau_i and spacing ∥μi−μi+1∥\|\bm{\mu}_i - \bm{\mu}_{i+1}\| between samples,

αi=1−exp⁡(−τi∥μi−μi+1∥),wi=αi∏j<i(1−αj),C=∑iwici.\alpha_i = 1 - \exp\left(-\tau_i \|\bm{\mu}_i - \bm{\mu}_{i+1}\|\right), \qquad w_i = \alpha_i \prod_{j < i} (1 - \alpha_j), \qquad \mathbf{C} = \sum_i w_i \mathbf{c}_i.

Here ci\mathbf{c}_i is the colour at sample ii, and the samples are indexed from the camera outward.

A tiny compositing example

Two samples on a ray, with α1=0.5\alpha_1 = 0.5 (red, c1=(1,0,0)\mathbf{c}_1 = (1, 0, 0)) and α2=0.8\alpha_2 = 0.8 (blue, c2=(0,0,1)\mathbf{c}_2 = (0, 0, 1)).

  1. w1=0.5w_1 = 0.5.
  2. w2=0.8×(1−0.5)=0.4w_2 = 0.8 \times (1 - 0.5) = 0.4.
  3. C=0.5(1,0,0)+0.4(0,0,1)=(0.5,0,0.4)\mathbf{C} = 0.5 (1, 0, 0) + 0.4 (0, 0, 1) = (0.5, 0, 0.4).

Interpretation: the first sample dominates, the second shows through the remaining transparency, and the 0.1 left over is the background share that the example leaves out.

Results

Text-to-3D with CLIP R-Precision. The paper uses 153 prompts from the object-centric COCO validation subset of Dream Fields. R-Precision is the share of renderings for which CLIP retrieves the correct caption from a set of distractors. DreamFusion beats Dream Fields and CLIP-Mesh on colour renders and approaches the ground-truth image oracle. The paper notes that CLIP-based baselines have an unfair advantage on this metric, since they optimise against CLIP directly.

Geometry. On textureless renders, a reimplemented Dream Fields is near chance, while DreamFusion is consistent with its caption 58.5 percent of the time. This is the paper's main evidence that the shapes are right and not just the colours.

Ablations. Adding wider viewpoints, view-dependent prompts, lighting and textureless geometry improves the geometry scores at each step, and full renderings improve by 12.5 percent. The paper also shows that the albedo-only base model can look good while its geometry is poor, for example a dog with several heads, which is why it measures the textureless render separately.

Limits. The paper lists its own limits. Score distillation tends to produce oversaturated and oversmoothed results compared with ancestral sampling, and the samples lack diversity. The base Imagen model works at 64 by 64 pixels, which likely limits fine detail. The optimisation is non-convex, and the paper still sees local minima, such as 3D reconstructions where all scene content is painted onto a single flat surface.

Reading guide

Read the paper in this order.

  1. Section 1, Introduction. The motivation and the comparison with Dream Fields. Needs NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis and Learning Transferable Visual Models From Natural Language Supervision (CLIP).
  2. Section 2, Diffusion Models and Score Distillation Sampling. The forward and reverse processes, the denoising loss and classifier-free guidance. Needs Diffusion Model, Score Matching, Score Function, U-Net and Classifier-Free Guidance. Read the SDS gradient equation twice.
  3. Section 2.1, How can we sample in parameter space, not pixel space? Why the diffusion training loss fails as a sampler, and how SDS fixes it. Needs Kullback–Leibler Divergence and Gradient Descent.
  4. Section 3, the DreamFusion algorithm. The NeRF rendering equations and the four-step loop. Needs Volume Rendering, Spherical Coordinates and Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding.
  5. Section 4, Experiments. The R-Precision protocol and the ablations. Needs Learning Transferable Visual Models From Natural Language Supervision (CLIP) for the metric.
  6. Section 5 and Appendix A.4. The limits and the derivation of the SDS gradient. The derivation needs Latent Variable Model and Score Distillation Sampling.

Takeaways

  • DreamFusion optimises a NeRF so that its random-view renderings look good to a frozen text-to-image diffusion model.
  • The gradient is score distillation sampling: the diffusion model's noise residual, passed back through the renderer, with no backpropagation through the diffusion network.
  • No 3D training data is needed. The approach scores well on colour renders and on geometry measured with textureless renders.
  • The results are limited by the 64 by 64 base model, by oversaturated samples from the loss, and by local minima.

Read next: Score Distillation Sampling for the loss on its own.

Check yourself

QuestionRecall: which part of the diffusion network is left out of the SDS gradient, and why does that matter?Show answer

The Jacobian of the diffusion U-Net is left out. Computing it requires backpropagating through the large diffusion network, which is expensive and poorly conditioned at small noise levels. Leaving it out keeps only the noise residual and the generator's Jacobian, so each step is cheap.

QuestionCompute: the noise residual is 0.4 minus 0.1 = 0.3, w(t)=1w(t) = 1, and ∂x/∂θ=5\partial x / \partial \theta = 5. What is the SDS gradient for this one pixel and parameter?Show answer

1×0.3×5=1.51 \times 0.3 \times 5 = 1.5.

QuestionWhy: DreamFusion reports geometry on textureless renders as well as on colour renders. Why is the colour score alone not enough?Show answer

Colour renders can look right when the geometry is wrong. The paper's ablation shows a base model with high albedo R-Precision and a dog with several heads, so a colour score cannot detect bad shape. The textureless shaded render removes colour cues and tests the shape directly.

QuestionScenario: a team reruns DreamFusion and gets a 3D object that is very saturated and smooth, with little variety across seeds. Which limit from the paper matches this, and what would you try first?Show answer

This matches the paper's noted limits: score distillation over-saturates and over-smooths relative to ancestral sampling, and it gives less diversity. A reasonable first try is a different guidance weight, since the paper says a large classifier-free guidance weight helps quality, and then a different random seed set to check variety.

Sources

Read the full paper

Ben Poole, Ajay Jain, Jonathan T. Barron et al., 2022. arXiv:2209.14988