Free | No tracking | Every fact with a source|German and English

AI course / Module 1: Basics

Lesson 3/12 How image and video models work

Diffusion explained: how a picture emerges step by step from noise. · 5 min.

One sentence in, one image out: That feels like magic. In fact, there’s a clever process behind it that you can understand in the basics without any formulas. Once you get it, you’ll also understand the many settings in programs like ComfyUI much better.

The basic idea: from noise to image

Most current image models work on the principle of diffusion. The name sounds complicated, but the idea isn’t.

Imagine an old TV screen with no signal: just gray static, known as noise. A diffusion model starts with exactly that, pure random noise. Then it removes part of that noise step by step. After each step, you can see a little more. First rough color patches, then shapes, then details. In the end, you get a finished image.

A comparison: A sculptor looks at a block of marble and chips away everything that doesn’t belong to the figure. The model “chips away” the noise that doesn’t fit the desired image.

How the model learned this

During training, the process works the other way around. Millions of real images with descriptions are used. Noise is added to each image step by step until only static is left. The model learns one task: given a noisy image and a description, estimate which part of it is noise.

If you can do that well enough, you can also work backward. You start with pure noise and keep subtracting the estimated noise. The model has not stored images and pasted them together. It has learned what images typically look like.

The text encoder: making your sentence understandable

How does the model know what to draw? That’s what the text encoder is for. It translates your text, the so-called prompt, into a form the image model can work with. At each denoising step, the model looks at this translation and asks: What noise needs to be removed so the result fits “red cat on a sofa” better?

Older models tend to use smaller text encoders. They mainly understand keywords. Newer models use larger text encoders, sometimes even a whole language model. That helps them understand full sentences, quantities, and positions better, such as “a dog on the left, two cats on the right.” You’ll notice that later when prompting in lesson 10.

Important: The text encoder is often a separate file that you have to download in addition to the actual image model. It also needs storage, and with newer models, quite a lot of it.

The detour through the “latent space”

One detail is still missing. Denoising an image with many millions of pixels directly would be extremely expensive. That’s why most models work in a reduced, compressed representation of the image. This is called Latent Space.

At the end, another component, the VAE (Variational Autoencoder), converts the result back into a normal image with pixels. In ComfyUI, you’ll often see a component called “VAE Decode.” It does exactly this final step.

So a typical image model consists of three parts:

  • the text encoder, which translates your prompt,
  • the actual diffusion model, which denoises,
  • the VAE, which turns the result into pixels.

Sometimes all three are in one file, sometimes they’re separate files.

Steps, seed, and other controls

When you generate images, you’ll keep coming across the same terms:

  • Steps: How many times the model denoises. More steps take longer and, up to a point, add more detail. After that, there’s barely any improvement. Some models are optimized for very few steps.
  • Seed: The starting number for the random noise. Same seed, same settings, same prompt usually gives the same image. A different seed gives you a new variation.
  • CFG or guidance: How strictly the model follows your prompt. Too low becomes random, too high often looks exaggerated and artificial. With some newer models, this value hardly matters or is built in.
  • Sampler: The calculation method used for denoising. To start, just use the one the template specifies.
  • Resolution: Every model was trained for certain image sizes. If you deviate too much, you often get duplicate heads or strange proportions.

Tip: At first, keep everything fixed and change only one setting at a time. That’s the fastest way to learn what each control does.

And videos?

Video models work on the same principle. They just denoise not one image, but many frames together. The model makes sure the images match each other so people and objects move smoothly and don’t flicker.

That’s much more demanding. Videos need far more storage and computing time than single images. A few seconds of video can take several minutes on a home PC. That’s why clips are usually short. For getting started, we recommend practicing with images first. You can see what others get out of their models in the gallery.

The key points in brief

  • Diffusion models start with random noise and remove it step by step until an image appears.
  • The text encoder translates your prompt so the model knows where to denoise.
  • An image model usually consists of a text encoder, a diffusion model, and a VAE.
  • Steps, seed, and guidance are the most important controls.
  • Video models work similarly, but need much more storage and time.

Short quiz

1. What does a diffusion model start with when generating an image?
2. What does the text encoder do?
3. What does the same seed do with otherwise identical settings?