Translation with pairs: pix2pix
So far a GAN has turned noise into images. The conditional GAN from GANs as a two-player game also took a label , and the previous extension, Autoencoding GANs: AAE and α-GAN, mapped images to codes and back. Now the input is an image and so is the output.
You have a thousand photos of horses and a thousand photos of zebras. You want a network that repaints a given horse as a zebra: same pose, same field, stripes added. This task is image-to-image translation. With four networks in play, we drop the parameter subscripts and write , , , .
Start with the easy case, where every training example is a pair : an edge map and the photo it was drawn from. A generator maps to an image, and a loss compares with .
A pixel loss alone produces blur. When several outputs are plausible for one input, the expected loss is minimized by their per-pixel mean, and the expected loss by their per-pixel median. Neither looks like any of the plausible outputs.
pix2pix (Isola et al., 2017) adds a conditional adversarial loss. Its discriminator sees the pair or and decides whether the output is a real photo for this input:
Here is the sum of absolute pixel differences. The adversarial term makes the output sharp, and the term keeps it near the true target. The discriminator is a PatchGAN: it outputs a grid of verdicts, one per overlapping image patch, and the loss averages them.