Akanksha Tyagi

Reproducing Denoising Diffusion Probabilistic Models

Reproduced the DDPM paper, starting on CIFAR-10, then trained it to generate handwritten digits and textures.

MS coursework · University of Arkansas · Spring 2024 · Team of 2 · Paper reproduction

Built with Python, PyTorch, Diffusion Models and U-Net.

The paper

A generative model learns what a set of images has in common, so that it can produce new images that look as if they came from the same set. Diffusion models do this in two directions. The forward process takes a real image and adds a little Gaussian noise to it, again and again, until nothing is left but noise. The reverse process learns to undo that one small step at a time, so that starting from pure noise it ends with a new image.

The idea came from a 2015 paper inspired by nonequilibrium physics, which was hard to scale. Denoising Diffusion Probabilistic Models (DDPM), from 2020, made it practical. Its network is trained to predict the noise that was added at a given step, rather than the clean image. The authors showed that this gives high quality images with an efficient training procedure, and that training resembles denoising score matching while sampling resembles Langevin dynamics, two known techniques. Those are the paper's results.

Diagram in two rows. Forward process, left to right: a real image; add a little Gaussian noise; again and again; pure noise, where nothing is left but noise. Reverse process, learned, right to left: pure noise, where generation starts; undo one small step, where the network predicts the noise added at that step; again and again, one small step at a time; a new image. A legend marks the network as trained to predict the noise rather than the clean image, a U-Net in our reproduction.
The two directions of a diffusion model. The forward process only adds noise; the reverse process is the one that learns, and DDPM's network learns it by predicting the noise added at each step. Drawn from the text on this page.View full size (opens in a new tab)

What we reproduced

We were a team of two in an MS course.

  • CIFAR-10. We started on CIFAR-10, the small color image dataset the paper itself uses.
  • New datasets. We then trained DDPM on two other datasets: MNIST, to generate handwritten digits, and the Amsterdam Library of Textures (ALOT), in its quarter resolution version of 384 by 256 pixels, to generate textures.
  • Settings. The noise schedule ran for 1,000 steps. The U-Net widened from 32 to 256 channels as it went down in resolution and used attention with 4 heads. We trained for 40 epochs on each dataset at batch size 64.
  • Output. For each dataset we produced grids of generated samples and videos of the generation process, from noise to image.
A strip of square frames, left to right. The first frames are grids of pure black and white noise. In the middle frames, faint digits show through the noise. The last frame shows clean white handwritten digits on black, a few of them malformed.
Frames from our MNIST model's generation process, in order, from pure noise to handwritten digits. Each frame shows the same corner of the sample grid, enlarged without smoothing so the pixels stay sharp. Generated by our model; trained on MNIST.View full size (opens in a new tab)

What we found

After CIFAR-10, one U-Net design and one set of training settings ran on both MNIST, whose digits have a single gray channel, and the color textures of ALOT. Both trained for 40 epochs with the same noise schedule and produced the sample grids and generation videos described above.

A square grid of handwritten digits, white on black. Most are readable digits; a few are malformed or merge two strokes.
A full grid of digits our model generated, the last frame of the process above. Most are readable; some are malformed. Trained on MNIST.View full size (opens in a new tab)
A square grid of small texture patches. Some show grain, stone, fur or leaves in browns, greens and greys; many are flat patches of a single bright color, most often yellow.
Textures our model generated. Some show grain and surface detail; many come out as flat patches of one color, most often yellow. Trained on the Amsterdam Library of Textures (ALOT).View full size (opens in a new tab)

Materials