Home/Learn/3D lessons/Inside an image generator

Inside an image generator.

See how a diffusion model turns random noise into a picture. Turn the 3D model, add noise to small training pictures, then generate new ones with a prompt and compare them with the training set. The model is real but tiny: twelve pictures of 16 by 16 pixels, computed in your browser. The lesson inside a language model shows the other main way AI generates, one token at a time.

Building the 3D model
The 3D model of the lesson: four round platforms in a row, with a noisy picture made of tiles, a layered denoiser with its guess on top, a generated picture and a prompt tag with a guidance post.The 3D model of the lesson: four round platforms in a row, with a noisy picture made of tiles, a layered denoiser with its guess on top, a generated picture and a prompt tag with a guidance post.

Drag to turn the model. Click it once, then scroll to zoom. On a phone, use two fingers. Click a station or its label to learn what it does. The model follows the exercises below. The first platform shows the noisy picture, the denoiser shows its guess on top, the third platform shows the generated picture you pick, and the post grows with the guidance setting. The small traveling dot only shows the order of the steps.

Your turn, part 1

Add noise, then let the model guess

Pick a training picture and an amount of noise. The denoiser sees only the noisy picture and guesses what is underneath.

The clean picture
With noise, what the model sees
The denoiser’s guess

Which picture could it be?

    Your turn, part 2

    Generate six pictures from noise

    Each picture starts from its own random noise, set by a seed. Choose a prompt, the number of steps and the guidance, and the six pictures are generated again.

    Prompt
    Steps
    Guidance

    Pick a picture above to follow it. The top row is the picture during generation, the bottom row is the model’s guess of the clean picture at the same step.

    The twelve training pictures

    Pictures copied in the results above are outlined.

    How this model works

    Noise is added with the linear schedule of Ho and colleagues (2020), over 1000 levels. Generation uses deterministic DDIM steps, spread evenly from level 1000 to 0. At each step the denoiser computes, for every training picture, how likely it is to lie under the noisy picture, and returns the weighted average. That is the best possible guess for these twelve pictures, and it is the function a trained network tries to learn.

    With a prompt, the guess is computed twice, from all twelve pictures and from the four of the prompt’s shape, and the guidance scale mixes the two as in classifier-free guidance. Real image generators use networks with billions of parameters, trained on very large sets of captioned pictures.

    Take it into real work

    Rating generated images

    Three points for image generation tasks.

    Key terms

    Short definitions from the site glossary. Each term links to its full entry.

    Open the full AI glossary, with about 200 terms in eight groups.

    Six short questions

    Pick an answer to see a short explanation. Nothing is scored or saved.

    Where these ideas come from

    The lesson is a teaching model with twelve tiny pictures. Real generators work in the same steps at a vastly larger scale, and many work on a compressed version of the picture.

    How AI systems work

    Related lessons

    Another way a model generates, and where the training pictures come from.

    1. Text instead of pictures

      Inside a language model

      How a model splits text into tokens and picks the next one, step by step.

      Open the lesson
    2. Where pictures get their labels

      Inside image annotation

      How boxes drawn on pictures become training data, and how they are checked.

      Open the lesson