Please enable JavaScript to use CodeHS

AI literacy / how it works

How do AI image generators work?

An AI image generator starts with random static and cleans it up a little at a time until a picture appears. Learn how that trick works, why it draws strange hands, and how to spot an AI image.

Grades 6-12 ~12 min 5 hands-on demos
The short answer

How does AI make pictures?

Most popular AI image generators use a method called a diffusion model. It makes a picture by starting with random noise, like TV static, and removing a little of the noise at a time. A neural network (a program that learns patterns from lots of examples) decides what to remove. Your prompt, which is the text you type, nudges each step toward what you asked for.

01Words become numbersYour prompt is turned into a list of numbers the model can use.
02Start from staticThe model begins with a grid of random pixels.
03Clean up, step by stepEach step removes a bit of noise, guided by the prompt.

This page explains that idea, lets you try it, and then covers the big questions around it: who made the training pictures, who gets left out, and how to tell what is real. We simplify in places, and we tell you where.


Step 1 / Interactive

Pictures are grids of numbers

Every digital picture is a grid of tiny squares called pixels. Each pixel is stored as three numbers: how much red, green, and blue light to show. Each number goes from 0 (none) to 255 (the most). A phone photo has millions of pixels. The grid below has 144.

Pixel grid · 12 × 12
Hover over a pixel, or move to one with the arrow keys, to read its numbers.

Brightness is one number for how light a pixel looks. Here we get it by mixing the three colors, with green counting the most because our eyes are most sensitive to it. Click or drag to paint, then watch the numbers change.

A computer does not see a cat or a sun. It sees a long list of numbers. So making a picture means picking the right numbers for every pixel. That is the whole job of an image generator.


Step 2

What is a diffusion model?

A diffusion model is an AI that learns to make images by learning to undo noise. The name comes from physics. Think of a drop of ink spreading out in a glass of water until the color is the same everywhere. Diffusion models run a version of that idea backward.

There are two phases. Training happens once, before you ever use the tool. Generating happens every time you press the button.

Training (learning)
  1. Take a real picture from the training set.
  2. Add a little random noise. Then a little more. Keep going until only static is left.
  3. Show the model a noisy version and ask: what noise was added?
  4. Check its guess. If it is off, adjust the model's numbers (called weights) so it guesses better next time.
  5. Repeat with millions of pictures and many noise levels.
Generating (making)
  1. Start with a fresh grid of random noise.
  2. Ask the model to guess the noise hiding in it, given your prompt.
  3. Subtract a small part of that guess. The image is now a bit cleaner.
  4. Repeat. Many tools use somewhere around 20 to 50 steps.
  5. What is left is a brand new picture.

Notice what the model never learned: how to draw. It only learned to remove noise. But if you start from pure static and keep removing noise in a way that matches the patterns it has seen, a picture shows up.

Honest simplification: many real systems do this on a smaller, compressed version of the image, then expand it to full size at the end. The idea is the same.


Step 3 / Interactive

The denoising lab

Drag the slider to the right to denoise, which is how a picture gets generated. Drag it to the left to add noise, which is how training examples get made. Pick a picture, then try a new noise seed to start from a different pattern of static.

Denoising lab
0: pure static20: clean picture
Step 0 of 20 · noise 100%

This is a simplified model. Here we mix a known picture with random static: at each step the blend has a little less static. A real diffusion model has no stored picture to mix in. At each step a neural network looks at the current noisy image and your prompt, then predicts which noise to remove. It does this over dozens of steps on much bigger grids. The lab fakes the network's guess so you can see the process.

A seed is just a number that decides which random noise you get. The same seed gives the same static every time. A different seed gives different static.


Step 4 / Interactive

How does the model know what to draw?

Static does not contain a cat. So where does the cat come from? From the training data: the huge collection of examples a model learns from. For image generators, that is billions of images, each paired with a text caption, like a photo with the caption "orange cat asleep on a sofa."

Computers cannot use words directly, so a second neural network, a text encoder, turns your prompt into a list of numbers. Prompts with similar meanings get similar numbers. That list is fed into the image model at every denoising step. During training, the model learned that noise next to the numbers for "cat" tends to turn into whiskers and fur. So with that prompt, each step is nudged toward a cat.

Below, the starting static is exactly the same every time. Only the prompt changes.

Prompt steers the noise

Most tools also have a setting, often called guidance, that controls how hard each step follows the prompt. Low guidance gives the model more freedom. High guidance sticks closer to your words, sometimes at the cost of looking natural.


Step 5

Why does the same prompt give different pictures?

Because the starting static is different. Most tools pick a random seed each time you press the button, so the model starts from fresh noise and the denoising path goes somewhere new. Same prompt, new seed: a different pose, different colors, a different layout. Same prompt and same seed and same settings: usually the same picture.

Try the "New noise seed" button in the lab above. You will see the static change. One more honest note: our lab always ends at the same picture, because it blends in a stored one. A real model has nothing stored, so a different seed changes the final picture too.

This is also why AI art can feel like a slot machine. You are not asking for one exact picture. You are asking the model to find one that fits your words, starting from a random place.


When it goes wrong

Why do AI images get hands and text wrong?

Extra fingers and garbled signs are famous AI mistakes. They are not random bad luck. They come from how the model learned.

Six fingers. The model has seen millions of hands, so it knows a hand has a palm and a row of finger-like shapes. It does not hold a rule that says "exactly five." It learned what hands usually look like, not how many bones they have.

Hands are hard to learn

In photos, hands bend, overlap, hold things, and hide behind each other. The same hand looks different from every angle, so the pattern is much messier than a face.

Counting is not built in

The model matches patterns. "Five fingers" is a precise fact, and patterns are fuzzy. Teeth, tree branches, and windows in a building have the same problem.

Letters are shapes, not spelling

The model sees text as a texture that looks like writing. It can copy the look of a sign without knowing the word is spelled wrong. Every letter has to be exact, so small slips show.

Small slips pile up

Each step builds on the last one. If an early step puts a finger in a slightly odd place, later steps work around it instead of going back to fix it.

Newer models are much better at hands and text, and tips like "count the fingers" get less reliable over time. The deeper lesson holds: a generator copies patterns. It does not understand what it draws.


AI literacy

Whose pictures did it learn from?

To learn what "cat" or "oil painting" looks like, a model needs a lot of examples. Many training sets were built by collecting images and their captions from across the public web. Others come from licensed or stock image libraries. The model keeps patterns in its weights. It does not keep a folder of the pictures. Still, the pictures came from people, and that raises a real question: is it fair to train on someone's work without asking?

People disagree, and courts and lawmakers in different countries have not settled it. Here are the main arguments.

Many artists and photographers say

  • Their work was copied into training sets without asking or paying.
  • A model can imitate a living artist's style on request, which may compete with that artist for jobs.
  • Creators should get to say yes or no, and be paid if they say yes.
  • Models can sometimes produce images very close to ones that appeared many times in the training data.

Many AI companies and some others say

  • The model learns patterns from images, much like a student who studies many paintings. It does not store copies.
  • Style and general ideas are not owned by anyone, and learning from public work is a use the law may allow.
  • The tools let more people, including those who cannot draw, make and share images.
  • Strict rules could make AI only available to a few large companies that can afford licenses.

Where things are heading: some companies now train on licensed images, pay contributors, or let creators opt out. Lawsuits and new laws are still working through the question. A good habit while it is unsettled: read a tool's rules, credit your sources, and do not present AI output as a specific person's work.


AI literacy / Interactive

Why does bias show up in the pictures?

A model learns what is common in its training data. If most of the "doctor" pictures it saw show one kind of person, then "a doctor" will usually draw that kind of person. Researchers and journalists who tested popular generators found this kind of skew for jobs, and it can reinforce stereotypes. The model is not choosing to be unfair. It is repeating the pattern it was given, and the pattern can reflect the past or whoever took and posted the photos.

Try a toy version. The two shapes stand for two groups of people. Set how often group A appears in the training pictures for "a doctor," then generate 24 images.

Toy: skew in, skew out

Press the button to generate.

Real generators are more complex than a coin flip, and the pattern can show up even stronger in the output than in the data. What can be done? Builders can balance the training data, test for skewed results, and adjust prompts behind the scenes. As a user, you can ask for specific details instead of accepting the default, and you can notice what a tool treats as the "normal" version of a person.


AI literacy / Interactive

Real or AI? Spot the clues

As generators improve, fake images get harder to spot, and they are used for jokes, ads, scams, and false news. A deepfake is a realistic fake of a real person's face or voice. To go deeper, read Deepfakes and Synthetic Media and Can You Trust That Photo?

Below are six clues described with small drawings. For each one, decide what it tells you. Careful: some clues prove little on their own.

Clue checkScore: 0 / 0

1. Shadows

The picture shows outdoors in daylight with one sun. One person's shadow points left. Another person's shadow points right.

CAFFE LATTTEROSTRS OPPEN

2. Text on a sign

The letters look like real lettering, but the words are almost right: "CAFFE LATTTE" and "ROSTRS OPPEN."

3. Blurry background

A portrait where the person is sharp and everything behind them is a soft blur.

4. Faces and hands in a crowd

In the back of a crowd, two faces seem to melt into one, and a raised hand has six fingers.

5. Perfect skin

A portrait where the skin has no pores, freckles, or flaws at all, and the lighting looks like a studio shoot.

BREAKING!!0 followers · no source

6. The source

A dramatic image of a news event is posted by a brand new account with no followers. No outlet, date, or place is given, and you cannot find it anywhere else.

The habit that lasts: look at the details, but also ask who posted it, why, and whether anyone reliable shows the same thing. Visual clues expire as AI gets better. Checking the source does not.


Fighting back

Watermarks and content credentials

If it is getting hard to tell by eye, can the image carry a label? Two ideas are being used.

Watermarks

A watermark is a mark placed in an image. Some are visible, like a logo in the corner. Others are invisible: the tool changes pixels in a pattern a person cannot see, and a detector can find it later. Some are built to survive resizing and compression.

Content credentials

Content Credentials are a standard label attached to a file. It is signed with a digital signature and can record which tool made the image and what edits were made. Some cameras, apps, and websites can show it.

These help, but they are not magic. A label can be stripped away by a screenshot, and not every tool adds one. An image with no label is not proven real, and a label says how a file was made, not whether what it shows is true. Think of them as one more clue next to checking the source.


Check yourself

Quick quiz

1. What does a diffusion model do while it generates a picture?

2. You use the same prompt twice and get two different images. What is the most likely reason?

3. Why might "a doctor" mostly draw one kind of person?

Keep learning about AI

Now you know how an AI image is made. Next, learn how to judge what you see online, or build your own AI skills with a CodeHS course.

Part of the AI literacy tutorials. Browse all tutorials.