Skip to content
tezvyn:
Menu

Unpaired image translation with CycleGAN

Source: interviewMediumHow cards are made

Summary

unpaired translation design.

Key points

CycleGAN uses two generators and two discriminators with a cycle-consistency loss that forces translating to the other domain and back to reconstruct the input, removing the need for paired data.

What's really being asked

Whether you know how to substitute a learned consistency constraint for the missing paired supervision in image-to-image translation.

The full answer

With no paired horse-zebra images, a conditional model like pix2pix is not applicable because it needs aligned input-output pairs. CycleGAN is the standard starting point. It trains two generators, one mapping horses to zebras and one mapping zebras to horses, plus two discriminators, one judging realistic zebras and one judging realistic horses. The adversarial losses alone only ensure outputs look like the target domain; they do not tie the output to the specific input, so the network could ignore content. The crucial cycle-consistency loss fixes this: take a horse, translate to zebra, then translate that zebra back, and the result should match the original horse, and symmetrically for the other direction. This forces the two mappings to be approximate inverses, preserving pose and structure while changing only the domain-specific appearance. An optional identity loss, feeding a zebra into the zebra generator and asking for no change, helps preserve color composition.

The mistakes people make

Proposing pix2pix or any paired model; dropping the cycle-consistency term and relying on adversarial loss alone, which permits the generator to disregard input content; using a single generator; assuming you must first synthesize pairs.

What usually comes next

Why does cycle consistency not guarantee a unique or semantically correct mapping? When does CycleGAN fail, for example on large geometric changes? How does it compare to diffusion-based unpaired translation? What artifacts arise and why might the model hide information to cheat the cycle loss?

A concrete example

Collect a folder of horse photos and a separate folder of zebra photos with no correspondence. After training, feed a horse image to the horse-to-zebra generator and it repaints the coat with stripes while keeping the animal's pose, background, and lighting. Passing that synthetic zebra through the reverse generator returns an image close to the original horse, which is exactly the cycle-consistency objective being satisfied.

Interview question

What lets CycleGAN learn translation without paired training images?

  • a.A single shared generator across both domains
  • b.A cycle-consistency loss requiring round-trip translation to reconstruct the inputCorrect
  • c.A pretrained classifier supplying labels
  • d.A pixel-wise loss against aligned target images
Why?

Cycle consistency forces translating to the other domain and back to recover the original, supplying supervision in place of pairs. A pixel-wise loss against aligned targets is exactly the paired-data requirement CycleGAN avoids.

Just read this? Test yourself on what you have been reading.

Read the original → junyanz.github.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles