AI Hints
Home›Generative AI Tutorial›How AI Creates Images
Generative AI · Lesson 43 of 77

Text to Image

How words steer the picture.

⏱ 2 min read▶ Video at 1:39:19🎓 Free
Watch this lesson in the Generative AI courseWatch on YouTube ↗Full Generative AI course

Pure diffusion makes random pictures. To get the picture you asked for, the words must steer the process. In this lesson, you will learn how text and images are connected, and what the guidance dial does.

Text to Image
From the video: Text to Image
  • Random pictures are not enough
  • Words must steer the process
  • Connecting text and images

Connecting words and pictures

First, the model needs to understand your prompt. A text encoder turns your words into embeddings, the same idea as before. A famous model called C L I P, was trained on hundreds of millions of pictures with captions, so that a picture and its caption, land close together in the same map of meaning. Now the denoising network can be told, at every step, remove the noise in a way that fits this description.

  1. Your prompta cat in a spacesuit
  2. Text encoderwords become embeddings
  3. Shared meaning mappictures and captions align
  4. Guided denoisingeach step fits the prompt
Every step is steered by the text
Connecting words and pictures
From the video: Connecting words and pictures

The guidance dial

A setting called guidance scale, controls how strongly the prompt steers the picture. Low guidance gives the model freedom. Pictures look natural and varied, but may ignore parts of your prompt. High guidance forces it to follow the words closely, but pictures may look harsh, over saturated, or strange. Most users keep it in the middle, and adjust only when needed.

Low guidance

  • Loose, creative interpretation
  • May ignore parts of the prompt
  • Natural and varied

High guidance

  • Follows the words closely
  • Can look harsh or strange
  • More literal and rigid

The latent trick

Working on every pixel would be slow. So Stable Diffusion uses a trick. A compressor, called an autoencoder, squeezes the image into a much smaller hidden space, called the latent space. Diffusion happens there, which is far cheaper. At the end, a decoder expands the result, back into a full picture. This is why modern image models can run on an ordinary graphics card.

Compress the imageinto a small latent space
Diffuse in latent spacefar cheaper and faster
Decode at the endback into full pixels
Runs on a normal GPUa big practical win

Summary

Excellent. A text encoder turns your prompt into meaning, and every denoising step is guided by it. The guidance scale sets how strictly to follow the words, and the latent trick makes it fast. Next, a look at an older rival, and a sibling, G A Ns, and V A Es.

Key takeaways
  • Prompt > embedding > guided denoising
  • Guidance scale: freedom vs obedience
  • Latent space makes it fast
Next up: GANs and VAEs — the older ideas that paved the way