pix2pix is the model from the 2017 CVPR paper “Image-to-Image Translation with Conditional Adversarial Networks” by Phillip Isola, Jun-Yan Zhu, Tinghui Zhou and Alexei Efros. It is a conditional GAN that takes an input image and produces the matching output image: a photo from a label map, an object from its edge map, a colour image from a greyscale one. The generator is a U-Net and the discriminator is a PatchGAN classifier. The generator is trained on an adversarial loss plus an L1 pixel loss against the ground-truth target, and the discriminator on the standard adversarial loss. The paper’s central idea is that the network learns the loss as well as the mapping, so the same generic approach applies to problems that traditionally needed very different loss formulations.
What the pix2pix Paper Proposes, and How a Conditional GAN Differs from an Unconditional One
In any GAN, the generator learns to produce samples that fool the discriminator, and the discriminator learns to tell real samples from generated ones. An unconditional GAN starts its generator from random noise, so you get a plausible sample but have no say over which one.
Mirza and Osindero introduced the conditional version in 2014: you feed the data you want to condition on, y, to both the generator and the discriminator. That y can be a class label or another modality, concatenated with the input, and it gives you control over what kind of data is generated. In pix2pix the condition is a whole image, and the output is the corresponding image.
In pix2pix there is no random noise vector going into the generator: it learns a direct mapping from the input image x to the output G(x). As in any conditional GAN, the discriminator is also fed the conditioning input, so it judges the input and output together.
The paper presents the approach as a general-purpose solution to image-to-image translation. The authors used the same architecture and objective for every task and changed only the training data. Their demonstrations include photos from label maps, objects from edge maps and colourisation, and the TensorFlow tutorial adds map-to-aerial-photo and sketch-to-photo.
Why the pix2pix Generator Is a U-Net with Skip Connections
The U-Net has a contracting path that captures context and a symmetric expanding path that allows precise localisation. In the pix2pix generator as the TensorFlow tutorial builds it, each encoder block is convolution, batch normalisation and Leaky ReLU, and each decoder block is transposed convolution, batch normalisation, dropout (on the first three blocks) and ReLU. Skip connections run between matching encoder and decoder layers.
In image-to-image translation, input and output share most of their low-level structure: edges, object outlines, layout. In a plain encoder-decoder, all of that has to squeeze through the bottleneck and be rebuilt on the other side. Skip connections pass the encoder’s features at each resolution straight to the matching decoder layer, so fine structure reaches the output without being compressed away. The bottleneck can then concentrate on what actually changes between the two domains, such as texture, colour and appearance.
PatchGAN: Why pix2pix Judges the Image Patch by Patch
The discriminator is a convolutional PatchGAN classifier, a design proposed in the pix2pix paper. It does not return one real-or-fake score for the whole image. It returns a grid of scores, each one judging an N×N patch, and those scores are averaged to give the verdict.
How pix2pix Combines the Conditional Adversarial Loss with L1
The full objective is a minimax game on the conditional adversarial loss plus an L1 term:
G* = arg min_G max_D L_cGAN(G, D) + λ · L_L1(G)
L_cGAN(G, D) = E_{x,y}[ log D(x, y) ] + E_x[ log(1 − D(x, G(x))) ]
L_L1(G) = E_{x,y}[ ‖y − G(x)‖₁ ]
The adversarial term in this form follows the standard conditional GAN objective, with the discriminator seeing the input alongside the real or generated output.
The L1 term keeps the output faithful to the ground truth, and the adversarial term stops it from going blurry. On the L1 side, the pixel-distance loss pushes the generated image for a given input towards its real target, which makes convergence faster and training more stable. On its own, though, a pixel loss rewards the average of all plausible outputs, and that average is blurry. The adversarial term penalises blur because a blurry patch is easy for the discriminator to flag as fake. The weight λ sets the balance between the two. Weighting L1 more heavily trades sharpness for closeness to the target.
In practice, the discriminator loss in the TensorFlow implementation is a sigmoid cross-entropy against ones for real images plus a sigmoid cross-entropy against zeros for generated ones. The tutorial gives log(2) ≈ 0.69 as a reference point. A discriminator loss below that means the discriminator beats chance, and a generator adversarial loss below it means the generator is fooling the discriminator more often than chance.
What Paired Training Data pix2pix Needs, and When CycleGAN Is the Better Choice
pix2pix needs paired images: every input has to come with its own aligned target. A 2021 GAN review calls this its fatal flaw, because it rules out data that has no input-output pairs. The requirement follows from the objective. Both the L1 term and the pair-scoring discriminator compare the output with a specific target.
On some tasks, the pair count can be modest. The authors trained their facades model on 400 images for about two hours on one Pascal Titan X GPU, and they also warn that harder problems may need far larger datasets and hours or days of training. The standard recipe from the paper, as the TensorFlow tutorial applies it, uses random jitter: each 256×256 image is resized to 286×286, randomly cropped back to 256×256, randomly flipped horizontally, then normalised to [-1, 1]. The tutorial also keeps a batch size of 1, which gave better results for the U-Net in the original pix2pix experiments.
CycleGAN, the same group’s follow-up, handles the case where pairs do not exist. It learns a mapping G from domain X to domain Y so that G(X) cannot be told apart from Y, then adds an inverse mapping F from Y back to X and a cycle-consistency loss that pushes F(G(X)) back towards X, and the same in the other direction. The cycle constraint is needed because translation without pairs is highly under-constrained.
So the decision is mostly about your data. If you can collect aligned pairs, pix2pix gets direct supervision, and the MRI-to-CT comparison notes that supervised methods relying on paired images have generally done better than unsupervised ones. If you cannot collect pairs, because the domains have no one-to-one correspondence or aligning them costs too much, CycleGAN is the option to use.
How pix2pixHD Extends pix2pix to High-Resolution Image Synthesis
pix2pixHD starts from the observation that conditional GAN results were often low-resolution and far from realistic, and it produces 2048×1024 output using a new adversarial loss and multi-scale generator and discriminator architectures. For scale, the standard pix2pix tutorial setup works on 256×256 images. Before pix2pixHD, Chen and Koltun’s model, the first to reach 2048×1024, used a direct regression objective with a perceptual loss and lacked fine detail and realistic texture.
The main changes are:
- Coarse-to-fine generator. A global generator G1 runs at 1024×512, and a local enhancer G2 outputs four times as many pixels (twice each dimension), giving 2048×1024. Adding a third network G3 reaches 4096×2048.
- Three multi-scale discriminators. They share one architecture and run on an image pyramid made by downsampling by factors of 2 and 4. The coarsest has the largest receptive field and pushes global consistency, and the finest pushes detail. Without them, the generated images often show repeated patterns.
- Feature matching loss. The generator has to match intermediate features taken from several discriminator layers on real and synthesised images, which stabilises training. The full objective is the GAN loss summed over the three discriminators plus λ times the feature matching loss, with an optional VGG perceptual loss that improves results slightly in some cases.
- Instance maps. Object boundaries from instance segmentation separate adjacent objects of the same class, such as parked cars in a street scene. They also enable object-level editing and diverse outputs for the same input.
In the paper’s human preference tests, the final model was preferred over a GAN-loss-only version in 68.55% of comparisons and over GAN plus feature matching (without the VGG loss) in 58.90%. NVIDIA’s official PyTorch implementation targets the same jobs: label maps to photorealistic images, and face label maps to portraits.
Are Conditional GANs Like pix2pix Still Worth Using Now That Diffusion Models Exist?
Yes, for some jobs. Conditional diffusion models produced better images than GAN baselines in the Palette study and, on larger datasets, in the DiT study. Where the dataset is small, inference has to be fast or compute is tight, pix2pix is still a strong choice. The evidence supports both halves of that answer, so no single ranking holds.
On the diffusion side, Dhariwal and Nichol (2021) reported an FID of 4.59 on ImageNet 256×256 and matched BigGAN-deep with as few as 25 forward passes per sample. That result is about class-conditional ImageNet synthesis, not translation. For translation itself, the Palette paper’s conditional diffusion model beat strong GAN and regression baselines on colourisation, inpainting, uncropping and JPEG restoration without task-specific tuning. A study comparing a CLIP-conditioned diffusion transformer (DiT) with Pix2Pix on face2comics and edges2shoes found sharper detail and fewer artefacts from DiT, while Pix2Pix produced blurred regions and occasional mis-generations. An MRI-to-CT comparison of Pix2Pix against Palette found the diffusion model ahead on SSIM, PSNR and FID, and it cites earlier work in which a GAN hallucinated “severe” artefacts that the diffusion models did not.
Other studies come out in the GAN’s favour. In a 2025 benchmark of T1w-to-T2w MRI translation, Pix2Pix beat both the diffusion and the flow-matching models, with SSIM 0.862 and PSNR 22.915. The authors put this down to small datasets and simple 2D slices, a setting where the flow-based models overfitted. They also found that the diffusion models failed to carry lesions across accurately, while Pix2Pix preserved them. The DiT study points the same way on small data: on the 400-image CMP Facade set, Pix2Pix beat the diffusion transformer. The MRI-to-CT paper also cites work finding diffusion better for brain images and cGANs better for the pelvis. The two MRI studies therefore reach opposite conclusions. They addressed different tasks, MRI-to-CT and T1w-to-T2w. We read them as showing that dataset size and the anatomy or content involved shape which family comes out ahead.
In all three studies that report cost, the GAN was much faster. All three come from different tasks:
| Study (task) | GAN | Diffusion / alternative |
|---|---|---|
| T1w-to-T2w MRI benchmark, 2025 | Pix2Pix: 0.05 s inference, 8.88 MB memory | ControlNet: 57.87 s; flow matching around 11–12 s |
| DiT vs GANs on paired data, 2025 | Pix2Pix: 0.04 s per image, 1.4 h training, 207.6 MB; pix2pixHD: 0.8 s, 3.7 h, 696 MB | DiT: 36.1 s per image, 23.1 h training, 12.92 GB |
| MRI-to-CT comparison, 2025 | cGAN sampled about 378.5× faster and ran about 11.05 more training iterations per second | cDDPM (Palette) |
The newest work blurs the boundary between the two families. pix2pix-Turbo adapts a single-step diffusion model to new tasks using adversarial objectives, which tackles diffusion’s slow iterative inference. On Sketch2Photo and Edge2Image it is on par with ControlNet with a single inference step. The img2img-turbo maintainers report 0.29 s on an A6000 and 0.11 s on an A100 for a 512×512 image with these one-step models. The same family’s CycleGAN-Turbo outperformed earlier GAN and diffusion methods on unpaired scene translation, such as day to night and adding or removing weather effects.
Choosing Between pix2pix, CycleGAN, pix2pixHD and Diffusion
| Your situation | Lean towards | Basis |
|---|---|---|
| Aligned pairs, small dataset (hundreds of images) | pix2pix | Beat DiT on a 400-image facade set and diffusion on small-data MRI slices |
| No paired data available | CycleGAN, or CycleGAN-Turbo | Cycle-consistency replaces pairs; Turbo variant for unpaired scenes |
| Label maps to 2048×1024 output, object-level editing | pix2pixHD | Multi-scale generator and discriminators, instance maps |
| Large paired dataset, fidelity first, latency relaxed | Conditional diffusion (Palette, DiT) | Beat GAN baselines on image-to-image tasks |
| Sketch-to-photo or edge-to-image with one inference step | pix2pix-Turbo | On par with ControlNet in a single step |
| Invented structure is unacceptable (for example medical) | Test both on your own data | Hallucination reports cut both ways |
The published comparisons disagree on which family hallucinates or drops detail. A held-out evaluation on your own pairs, using the metric your downstream use depends on, is the only result that carries over.
FAQ
Is GAN Obsolete?
No. Diffusion models led on fidelity in the Palette and DiT studies, but Pix2Pix came out ahead on small paired datasets and ran far faster in the 2025 comparisons. Hybrids such as pix2pix-Turbo also use adversarial objectives to make diffusion fast.
What Are Pix2Pix and CycleGAN Known for in Generative AI?
In generative AI, Pix2Pix is a general-purpose conditional GAN for image-to-image translation trained on paired images. CycleGAN is known for unpaired translation through its cycle-consistency loss. Both are listed among multimodal image-to-image translation models in a 2021 GAN review.
What Is GAN in Image Processing?
A GAN pairs a generator, which produces images, with a discriminator, which learns to tell them from real ones, and trains the two against each other. In image processing, GANs are used for data generation and augmentation, image-to-image translation and super-resolution, among other tasks.