Book Deep Read · Generative AI System Design Interview · Ch 7

Realistic Face Generation: you think you are training a painter — you are training a yardstick

Generative AI System Design Interview · Ch 7 · Ali Aminian, Hao Sheng & Alex Xu · 2024

中文 →

What is this chapter about?

You have seen these photos online: someone smiling naturally, every hair, pore and earlobe lit correctly — and that person has never existed. This chapter is about how a machine paints a real face out of nothing, and about a harder question: once it is painted, who says whether it is any good?

A strange thing first

Every other task has a right answer. Cat or dog — right is right. But "paint a face" has none. You cannot point at any photograph and say "this is what you should have painted." No answer means no score, and no score means no way to tell the machine which way to move next.

Why the old ways don't work

The early idea was to have it paint toward the average of everyone. The result is absurd: average ten thousand faces position by position and you get a grey smear with the features melted together — averaging ten thousand faces never gives you a good face, only a face that is nobody. Want sharpness, stop averaging; stop averaging, and you are back to having no way to score.

How it actually works

The fix is strange: if nobody can be the judge, then train a judge too.

Put two people in a room. One is a forger, starting out by smearing paint around blindly. The other is an appraiser, with a stack of genuine photographs on the desk and whatever the forger just handed over, and exactly one job: point at the fake. The forger wants to fool the appraiser; the appraiser wants not to be fooled. The beauty is that the appraiser improves too — a blur gets through today; tomorrow the appraiser has learned to read the eyes; the day after, ears and hairlines. The yardstick keeps getting stricter, so the forger gets pushed all the way to indistinguishable.

Later the forger was given a layered palette: settle the big things first (which way the head faces, the shape of the face), then the middle (features, expression), and only then the fine things (skin tone, stray hairs, pores). To change the hairstyle without touching the face shape, you turn only the middle dial — that is where control comes from. There is one more handy trick: have it paint a little closer to the average face, so it makes fewer mistakes and looks more convincing; the price is that everyone it paints starts to look faintly related.

So how do you know it has learned?

Still not by looking at one picture. Lay out fifty thousand real photographs and fifty thousand painted ones, and compare the character of the two piles — the real pile has old and young, profiles, people in hats; if the painted pile spreads just as wide and holds just as much detail, it passes. This is the general move against "no right answer": one picture cannot be graded, a crowd can.

What you gain, and what it costs

The gain is speed: once trained, a face comes out in the blink of an eye, which is why live avatars, stock imagery and using synthetic faces in place of real ones for testing all lean on it. The cost is one sentence, and a hard one: the sparring can break down at any moment — most often by the forger discovering one face that always works and painting nothing else ever again.

One line to remember

You think the hard part is painting something lifelike. The hard part is that nobody can say what "lifelike" means. The whole cleverness of this chapter is turning an unstateable standard into an opponent that is also learning.

Want the mechanisms, notation and diagrams? → switch to the deep read