Navigation

Introduction to AI

Machine Learning

Deep Learning

NLP & LLMs

Computer Vision

Generative AI

Reinforcement Learning

AI Ethics & Governance

Tools & Frameworks

General

Image-to-Image Translation - Mapping Images Between Visual Domains

Image-to-image translation learns a mapping from one visual domain to another — sketches to photos, day to night, satellite imagery to maps, horses to zebras — treating the transformation itself as a learned function rather than a hand-designed image processing operation.

Paired Translation with pix2pix

When paired training examples exist — the same content available in both the source and target domain, like an architectural sketch and its corresponding photorealistic rendering — pix2pix frames translation as a supervised learning problem, training a conditional GAN where a generator produces the target-domain image from the source-domain input, and a discriminator learns to distinguish genuinely paired examples from generated ones:

sketch -> generator -> generated photo
discriminator sees (sketch, real photo) vs (sketch, generated photo) -> real or fake?

The generator is trained to fool the discriminator while also directly matching the ground-truth target image pixel-for-pixel, combining adversarial loss with a direct reconstruction loss.

Unpaired Translation with CycleGAN

Paired data is often unavailable or expensive to collect — there’s no ground-truth “same horse, but a zebra” photo to pair with a given horse photo. CycleGAN solves unpaired translation using cycle-consistency: it trains two generators, one translating domain A to B and another translating B back to A, with a loss that penalizes the reconstruction error when translating an image to the other domain and then back again.

horse image -> generator(A->B) -> zebra-styled image -> generator(B->A) -> reconstructed horse
cycle-consistency loss: reconstructed horse should closely match the original horse image

This cycle-consistency constraint prevents the generators from producing outputs that are stylistically plausible for the target domain but have lost the original image’s content and structure, since only a translation that preserves enough information to reconstruct the original can satisfy the cycle constraint.

Diffusion-Based Translation

Modern image-to-image translation is increasingly built on diffusion models, using techniques like image-conditioned denoising (starting the diffusion process from a noised version of the source image rather than pure noise) or ControlNet-style conditioning, generally producing higher-quality and more controllable translations than GAN-based approaches, particularly for complex or highly structured target domains.

Practical Guidance

Use pix2pix-style paired translation when matched training pairs are available, since direct supervision generally produces more faithful and controllable results than unpaired methods. Use CycleGAN or a diffusion-based unpaired approach when only unpaired domain examples exist, and validate that cycle-consistency (or the diffusion equivalent) is actually preserving the content you care about, since these methods can still find degenerate shortcuts that satisfy the training objective while distorting content in ways not penalized by the loss function.