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

GANs and VAEs

The older ideas that paved the way.

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

Before diffusion, two other ideas led the way. Generative adversarial networks, and variational autoencoders. They are still used today, and understanding them deepens your picture of how machines create. In this lesson, you will meet both, without any maths.

GANs and VAEs
From the video: GANs and VAEs
  • Two older ideas
  • Still used today
  • Understood without maths

GANs: forger versus detective

A G A N is a game between two networks. The generator is a forger, trying to create fake pictures. The discriminator is a detective, trying to tell real pictures from fakes. At first, the forger is terrible, and the detective wins easily. But each time the detective catches a fake, the forger learns, and improves. After many rounds, the fakes become so good, that even the detective is fooled.

A game
  1. Forgercreates fake images
  2. Detectivespots fakes from real
  3. Feedbackthe forger learns from mistakes
  4. Better fakesuntil they look real

GANs compared with diffusion

G A Ns can be very fast, producing an image in a single step, and they were behind the first stunning fake faces. But they are tricky to train, they can collapse into producing the same few pictures, and they are harder to steer with text. Diffusion models are slower, but more stable, more varied, and much easier to guide. That is why diffusion took over for general image creation.

GANs

  • Very fast, one step
  • Tricky, unstable training
  • Can repeat the same few pictures
  • Hard to steer with text

Diffusion

  • Slower, many steps
  • Stable training
  • Varied results
  • Easy to guide with text

VAEs: compress and rebuild

A variational autoencoder learns to squeeze an image into a small code, and then rebuild it. Because the codes are arranged smoothly, you can pick a new code, and decode a brand new image. By itself, the results are a little blurry. But the idea lives on, inside every latent diffusion model, as the compressor, and decompressor, that make it fast.

  1. Encodersqueezes the image into a small code
  2. Latent codea compact description of the picture
  3. Decoderrebuilds an image from the code

Summary

Good. A G A N is a forger versus a detective, fast, but delicate. A V A E compresses and rebuilds, and lives on inside latent diffusion. Diffusion won for its stability, variety, and control. Next, a practical lesson, how to prompt, and control image models, to get exactly what you imagine.

Key takeaways
  • GAN: forger vs detective
  • VAE: compress and rebuild
  • Diffusion: stable, varied, steerable
Next up: Image Prompting and Control — getting exactly what you imagine