Skip to main content

Classic design · Senior

Realistic face generation

Classic interview design. Key points: GAN/StyleGAN, mode collapse, FID, and watermarking.

16 min read · Content reviewed on October 23, 2026

Short answer

Classic interview design. Key points: GAN/StyleGAN, mode collapse, FID, and watermarking. Chapter 7 of the book Generative AI System Design Interview is titled Realistic Face Generation.

01 · CONTEXT

The problem: generating faces that look real

Chapter 7 of the book Generative AI System Design Interview is titled Realistic Face Generation.

A GAN trains two models at the same time: a generator, which captures the data distribution, and a discriminator, which estimates whether a sample came from the training data or from the generator.

The generator's training aims to maximize the probability that the discriminator makes a mistake.

02 · TRAINING

The adversarial training loop

The diagram below shows the training loop and the periodic evaluation of the generator.

  1. The diagram starts with the face dataset and the batch loader, which deliver real images to the discriminator.

    Architecture diagram: Face generation: training loop
    DBFace dataset
    CPBatch loader
    CPNoise sampler
    CPGenerator
    CPDiscriminador
    DBCheckpoints
    CPFID evaluator
    NWTraining metrics
  2. The generator turns noise into images, and the discriminator estimates whether a sample came from the training data or from the generator.

    Architecture diagram: Face generation: training loop
    DBFace dataset
    CPBatch loader
    CPNoise sampler
    CPGenerator
    CPDiscriminador
    DBCheckpoints
    CPFID evaluator
    NWTraining metrics
  3. The generator is trained to maximize the chance that the discriminator makes a mistake.

    Architecture diagram: Face generation: training loop
    DBFace dataset
    CPBatch loader
    CPNoise sampler
    CPGenerator
    CPDiscriminador
    DBCheckpoints
    CPFID evaluator
    NWTraining metrics
  4. The two sides need to move in sync: the generator must not be trained too much without the discriminator being updated.

    Architecture diagram: Face generation: training loop
    DBFace dataset
    CPBatch loader
    CPNoise sampler
    CPGenerator
    CPDiscriminador
    DBCheckpoints
    CPFID evaluator
    NWTraining metrics
  5. One training option is to give the discriminator and the generator individual learning rates, as in TTUR.

    Architecture diagram: Face generation: training loop
    DBFace dataset
    CPBatch loader
    CPNoise sampler
    CPGenerator
    CPDiscriminador
    DBCheckpoints
    CPFID evaluator
    NWTraining metrics
  6. The evaluator generates images from a checkpoint, passes them through Inception-v3, and computes the mean and covariance for the FID.

    Architecture diagram: Face generation: training loop
    DBFace dataset
    CPBatch loader
    CPNoise sampler
    CPGenerator
    CPDiscriminador
    DBCheckpoints
    CPFID evaluatornew
    NWTraining metrics

03 · STABILITY

When the generator loses diversity

The original GAN paper lists as a disadvantage the need to synchronize D and G well: G must not be trained too much without updating D, to avoid the scenario in which G maps too many values of z to the same value of x.

The TTUR authors propose one individual learning rate for the discriminator and another for the generator.

04 · CONTROL

StyleGAN: more control over the generated face

StyleGAN starts from a learned constant input and adjusts the image style at each convolution layer based on the latent code.

According to the paper, the result is an automatic, unsupervised separation between high-level attributes, such as pose and identity in faces, and stochastic variation, such as freckles and hair.

Before that, the latent code passes through an intermediate latent space; the mapping network that produces it has 8 layers.

The same work presents FFHQ, a dataset of human faces with much higher quality and much wider variation than existing high-resolution datasets.

In the illustrative examples, the authors avoided sampling extreme regions of W with the truncation trick, but all the FIDs in the paper are computed without it.

05 · EVALUATION AND SERVING

Measuring quality and serving the images

FID was proposed to evaluate GANs and, according to the authors, is more consistent than the Inception Score. The latter does not compare the statistics of real samples with those of synthetic ones.

For the computation, the authors generate 50,000 images, pass them through Inception-v3, and compute the mean and covariance.

The diagram below shows the path of a synthetic face request in production.

  1. The diagram starts with the client, who requests a synthetic face through the API gateway.

    Architecture diagram: Face generation: inference service
    CLClient
    NWAPI gateway
    CPGeneration service
    DBGenerator weights
    DBImage storage
    EDGCDN
    NWMonitoramento
  2. Generator sampling uses only a forward pass.

    Architecture diagram: Face generation: inference service
    CLClient
    NWAPI gateway
    CPGeneration service
    DBGenerator weights
    DBImage storage
    EDGCDN
    NWMonitoramento
  3. When showing examples, StyleGAN avoided sampling extreme regions of W with the truncation trick.

    Architecture diagram: Face generation: inference service
    CLClient
    NWAPI gateway
    CPGeneration service
    DBGenerator weights
    DBImage storage
    EDGCDN
    NWMonitoramento
  4. The diagram continues with the image written to storage and delivered to the client through the CDN.

    Architecture diagram: Face generation: inference service
    CLClient
    NWAPI gateway
    CPGeneration service
    DBGenerator weights
    DBImage storage
    EDGCDN
    NWMonitoramento
  5. The diagram ends with the service metrics going to monitoring.

    Architecture diagram: Face generation: inference service
    CLClient
    NWAPI gateway
    CPGeneration service
    DBGenerator weights
    DBImage storage
    EDGCDN
    NWMonitoramento

Frequently asked questions

What is Realistic face generation?

Classic interview design. Key points: GAN/StyleGAN, mode collapse, FID, and watermarking.

What does the Realistic face generation design cover?

It is organized in these sections: The problem: generating faces that look real, The adversarial training loop, When the generator loses diversity, StyleGAN: more control over the generated face, and Measuring quality and serving the images.

How long is Realistic face generation and what level is it?

It takes about 16 minutes to read and is rated Senior level.

Now design it yourself

Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.