Gradient LabStart the lesson

Lessons › Chapter 12: Generative models

Diffusion models

Take a real image and add a little random noise. Then a little more, and more, until it’s pure static. This part is easy and needs no learning.

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Pictures for the help pages

The design team asks for illustrations for Pip’s help pages.

Concept

Add noise, step by step

Take a real image and add a little random noise. Then a little more, and more, until it’s pure static. This part is easy and needs no learning.

Key idea

Learn to undo one step

Train a network to look at a noisy image and predict the noise that was added. If you can predict the noise, you can subtract it and make the image a bit cleaner.

Build

Start from pure static

To make something new, start from fresh random static. No image is hidden inside it.

Build

Denoise into a picture

Apply the denoiser over and over, guided by a text prompt. Structure appears out of the static, step by step, until a brand-new image emerges. This is how a diffusion model works.

Real life

In real life: text-to-image apps

Type “a cat sitting in a teacup” into an image generator and a diffusion model starts from static and denoises it into a picture that matches your words, typically in a few seconds. Video and audio generators use similar ideas.

Quick check: How does a diffusion model generate an image?

Generation runs the learned denoising steps starting from random static.

Pseudocode

training:
    take a real image, add a little noise, again and again → pure static
    teach a network to predict the noise added at each step

generating:
    start from pure static
    repeat about 50 times: remove a bit of the predicted noise
    guided by the text prompt → an image appears

Key terms

diffusion model
A model that learns to remove noise step by step, so it can turn pure static into a new image.