How does an AI image generator turn noise into a picture? Diffusion, step by step
Most AI images start life as random static. A model wipes a little of it away, again and again, and your prompt nudges every wipe. In this lesson you drag a picture out of the noise yourself and turn the guidance dial until it breaks.
- Say in one sentence how a diffusion model makes a picture
- Explain what the model learns in training: to guess the noise in a noisy picture
- Say what the steps setting and the guidance scale change, and pick sensible values
- Explain why hands and written words went wrong for years, and what made them much better
In this lesson
What happens when you type a prompt into an image generator?
The short answer: the tool starts with a square of random static, and a model cleans it up a little at a time, usually 20 to 50 times. Each time, it looks at the static and your prompt and guesses which part is noise. It takes some of that noise away. After the last step, what is left is your picture.
That is called diffusion, and it is how Stable Diffusion and many of the well-known image tools of the last few years work inside. The model does not search the web for a photo. It does not cut and paste bits of pictures it has seen, either. It makes new pixels by removing noise, guided by what it learned from millions of pictures with captions.
To see why that works, we start with how the model is trained.

How do you train a model to remove noise?
Take a real photo. Add a little random noise. Now add a bit more, and more, a thousand times, until nothing of the photo is left. The 2020 paper that made diffusion work well, by Jonathan Ho and two colleagues at Berkeley, used exactly 1,000 of these noise steps, with the amount added each time growing slowly from 0.0001 to 0.02.
Training runs the other way. We show the model a photo at some random noise level and ask one question: which part of this is the noise? It makes a guess, the training code tells it how wrong it was, and it adjusts. Repeat that across millions of pictures and every noise level, and you get a model that is good at one small job, which is cleaning up a noisy picture by a little bit.
Once the model can clean up any noise level, you can hand it pure static and ask it to clean that up too. It guesses what picture could be under there, removes a little noise, and does it again on the result. After enough rounds you have a picture that was never in the training data.
The lab lets you step through that process. It is a simulation, and it says so on the lab. The amount of noise at each step follows the real 2020 schedule. The pictures are not made by a model: they are three small scenes we drew ourselves, so the "guess" panel shows our drawing, blurred the way a real model's early guesses are blurry.
A simulation: the noise schedule is the real one from the 2020 paper, the pictures are ours. Drag the Step slider from 0 to the end. The left square is what the image looks like at that step; the right square is the model's guess of the finished picture. Then try a guidance of 0, 1 and 20, and try 4 total steps.
Why does the picture appear so late?
Drag the slider slowly and you will see that halfway through, the left square is still mostly static. The picture only shows up near the end. That is the real noise schedule at work: with the 2020 settings, only about 8% of the picture is there at step 500 of 1,000, and half of it arrives only by step 741. Going forward, each step adds a bit more noise than the last, and by the halfway point about 92% of the picture is buried. Run backwards, the first half of the steps barely changes what you see.
Now look at the right square again. Even at the early steps, when the left side is nearly pure static, the guess already has the big shapes: a dark sky, a bright tower, a light patch where the moon will be. The 2020 paper saw the same thing in real models, and showed it with rows of tiny pictures, each row one image being made from left to right. Its authors wrote that "large scale image features appear first and details appear last." The model settles the layout early, when the picture is still noise, and fills in edges and small parts at the end.
This is why the first few steps matter so much. Once the layout is set, later steps mostly add detail. And it is why a picture made with too few steps looks soft and smudgy: with only 4 steps, each one has to remove a big chunk of noise at once, and fine detail is what gets lost. Try 4 total steps in the lab and look at the result.
How does the prompt steer each step?
First, a text model turns your prompt into numbers. In the first Stable Diffusion that text model is CLIP. It always turns your prompt into 77 tokens, and each token is a list of 768 numbers. Inside the image model, a step called cross-attention lets each part of the picture look at those words and pick the ones that matter to it. It is the same attention idea as in our transformers lesson, but here the picture is looking at the text.
Stable Diffusion adds one more trick to save time. It does not clean up a full 512 by 512 picture. It works on a small, packed version of it, a grid of 64 by 64, and a separate decoder turns that grid into full-size pixels at the end. The 2021 paper behind it called this latent diffusion. It is a big reason the model can run on a home graphics card.
The setting you can control here is guidance. At every step the model makes two guesses. One uses your prompt, one uses an empty prompt. The tool then pushes the result away from the empty-prompt guess and toward the prompt guess. The guidance scale is how hard it pushes. This method, called classifier-free guidance, came from a 2022 paper by Ho and Tim Salimans, and the latent diffusion paper says it "greatly boosts sample quality".

Steps and guidance scale: what should you set them to?
Most image tools show these two settings somewhere, often under "advanced". Here is what they do and the values we use.
Steps is how many times the model removes noise. The popular diffusers library sets 50 as the default, and its docs say more steps usually give a better picture but take longer. In our use the gain past about 30 is small, so we start at 25 to 30 and only go higher for fine detail.
Guidance scale is how hard the prompt pulls. The diffusers default is 7.5, and its docs warn that higher values follow the prompt more closely "at the expense of lower image quality". At 1 the model adds no extra push, and low values let the picture drift away from what you asked for. The Hugging Face guide calls values around 7 to 8.5 usually good. High values make colours oversaturated, as the 2022 guidance paper showed and our lab imitates at 15 or 20.
Seed is the number that picks the starting static. The same prompt, seed and settings give the same picture again. A new seed gives a new picture from the same prompt, which is what "New noise" did in the lab. A negative prompt takes the place of the empty prompt in the guidance step, so the model pushes away from it. That is why "blurry, extra fingers" in a negative prompt can help.

Why were hands and words so hard for image AI?
For years the easiest way to spot an AI picture was to count the fingers or read the sign in the background. The two failures have different causes.
Hands are small. Say a hand is about 60 pixels wide in a 512 pixel image. In Stable Diffusion's packed 64 by 64 grid, that is about 7 or 8 cells for a whole hand, so a finger is barely one cell. That is our own arithmetic, but it shows how little room there is. A hand can also bend into a huge number of shapes, and in everyday photos it is often half hidden, in a pocket, behind a cup or curled into a fist. Our reading is that the model learned what fingers look like side by side, and nothing in training made it check how many there are. One 2024 paper on fixing hands, HanDiffuser, lists the faults: odd poses, odd shapes and the wrong number of fingers.
Text failed for a related reason. The model had to spell words it only knew as meanings. You saw it in the street sign shown above, from the 2021 latent diffusion paper. The model was asked twice for a sign reading "Latent Diffusion". It got it right once and wrote "LATETEN DIFFUSION" the other time. That model used its own small text model. The first Stable Diffusion used CLIP, which was trained to match pictures with their captions, so its numbers carry much more about a word's meaning than about its letters. Google's 2022 Imagen paper found that making the text model bigger helped overall quality and prompt matching more than making the image model bigger. Stable Diffusion 3 in 2024 used three text models, one of them a large language model called T5. Its paper tested the model with T5 taken out. People liked the overall look as much, a 50% win rate against the full model, but for writing in the picture the stripped model won only 38% of the time.
In our use, newer and much bigger models, with stronger text models built in, get hands and short words right far more often. We still check long passages of text and hands that hold things before we use a picture.
Q1What does a diffusion model learn to do in training?
Training shows it real pictures with noise added and asks it to predict the noise. Making a new picture is that same skill run over and over, starting from pure static.
Q2Halfway through the steps, the image is still mostly static. Why?
By the halfway point of the forward process, about 92% of the picture is buried, so going backwards it shows up near the end. The layout is already set in the model's guess well before you can see it.
Q3You set the guidance scale to 20. What happens?
Guidance pushes away from the empty-prompt guess. Push too hard and the picture overshoots. The diffusers docs say higher values cost image quality; around 7 to 8.5 is the usual range.
Q4Why did early image models get fingers wrong so often?
A hand gets only a few cells in the model's small grid, and photos show it in endless poses, often partly hidden. Our reading is that it learned how fingers look side by side and never had to count them.
What to take with you
- An image generator starts from random static. It removes a little noise at a time, usually 20 to 50 times.
- In training the model only learns to guess the noise in a noisy picture. Running that skill from pure static is what makes a new picture.
- The big shapes are decided early and the details come last, which is why too few steps look smudgy.
- The prompt steers every step. Guidance scale sets how hard; around 7.5 is normal and values like 20 oversaturate the picture.
- Hands failed because they are small and bend every way. Text failed because the text model knew meanings, not spelling. Bigger text models made spelling much better.
Questions people are asking
/01How do AI image generators work?
Many of the best-known ones use diffusion. The tool starts with random noise, and a trained model removes a little of it at a time, usually 20 to 50 times. At every step the text prompt steers which way the clean-up goes. What is left at the end is a new picture.
/02What is a diffusion model?
A model trained to guess the noise in a noisy picture. In training, it sees real pictures with different amounts of noise added. To make an image, it starts from pure noise and removes noise step by step until a picture is left.
/03What does the guidance scale do?
It sets how strongly the picture follows the prompt. At each step the model makes one guess with the prompt and one without, and the guidance scale is how hard it pushes toward the prompt guess. The common default is 7.5. High values like 15 or 20 give oversaturated colours.
/04How many steps should I use in Stable Diffusion?
The diffusers library defaults to 50. We start at 25 to 30 for most pictures, because the gain past that is small, and go higher only for fine detail. Too few steps give a soft, smudgy picture.
/05Why is AI bad at drawing hands?
Hands take up few pixels in most images, bend into many shapes and are often half hidden in photos. In our reading the model learned how fingers look next to each other but never had to count them. In our use, newer and larger models get hands right much more often.
/06Does an AI image generator copy existing pictures?
It does not paste parts of saved images. It makes new pixels by removing noise, using patterns it learned from millions of captioned pictures in training. Those patterns come from real images, which is why style and copyright questions around training data are still argued.
Sources 8
- Ho, Jain and Abbeel, Denoising Diffusion Probabilistic Models, Jun 2020 arxiv.org/abs/2006.11239
- Rombach et al., High-Resolution Image Synthesis with Latent Diffusion Models, Dec 2021 arxiv.org/abs/2112.10752
- Ho and Salimans, Classifier-Free Diffusion Guidance, Jul 2022 arxiv.org/abs/2207.12598
- Hugging Face, Stable Diffusion text-to-image pipeline docs (steps and guidance defaults) huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/text2img
- Hugging Face, Stable Diffusion with Diffusers (latents, CLIP, guidance) huggingface.co/blog/stable_diffusion
- Saharia et al., Imagen: Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding, May 2022 arxiv.org/abs/2205.11487
- Esser et al., Scaling Rectified Flow Transformers for High-Resolution Image Synthesis (Stable Diffusion 3), Mar 2024 arxiv.org/abs/2403.03206
- Narasimhaswamy et al., HanDiffuser: Text-to-Image Generation With Realistic Hand Appearances, CVPR 2024 arxiv.org/abs/2403.01693
What is a reasoning model? What AI "thinking" is, what it costs, and whether you can trust it
Start the lessonGet the next lesson in your inbox.
New lessons and how-tos, the tools we tested and what we think, in one short email.
Learning something?
Every Friday we send one short email with the newest lesson and the AI news that matters, in plain words.