An online shopping platform wants to generate different product images by changing the background, style, or appearance of existing products. Explain how GAN-based image-to-image translation can be used, with a suitable example and architecture.
What's actually being asked
Explain the general mechanism of GAN-based image-to-image translation and apply it concretely to changing a product photo's background/style, naming a real architecture.
Answer
The core idea
Image-to-image translation treats this as learning a mapping G: domain A → domain B — e.g. "product on a plain studio background" → "same product, styled/lifestyle background" — trained adversarially rather than hand-engineered. This is a direct application of the conditional GAN (cGAN) formula from the course sheet: condition y is fed to both networks,
min_G max_D 𝔼[log D(x|y)] + 𝔼[log(1 − D(G(z|y)|y))].
Here the condition y is the input product photo itself (not a class label): G(z|y) produces the restyled image, and D(·|y) judges whether an output is a plausible restyling of that specific input, not just a plausible image in general.
Architecture: conditional image-to-image GAN (pix2pix-style)
- Generator: an encoder–decoder with skip connections (U-Net). The encoder downsamples the input product photo, extracting the product's structure/edges/shape; the decoder upsamples back to full resolution, synthesizing the new background/style/lighting while the skip connections preserve the product's exact silhouette so it doesn't get distorted.
- Discriminator: a PatchGAN — rather than classifying the whole image real/fake once, it classifies small overlapping patches of the pair
(input photo, output photo). Real pairs = (product photo, its genuine alternate-background version); fake pairs = (product photo,G's generated version). Judging locally pushesGtoward sharp, locally realistic texture rather than a globally plausible but blurry result. - Training loss: the adversarial cGAN loss above, plus an
L1reconstruction termλ·‖x − G(y)‖₁between the generated and target image where paired ground truth exists — the adversarial term handles realism/sharpness, theL1term keeps the product's actual shape and colour correct (prevents the generator from "hallucinating" a different product).
Worked example
Take a shoe photographed on a plain white studio background. The generator is trained (on pairs of studio-shot vs. lifestyle-shot product photos, or via unpaired domain transfer if exact pairs aren't available) to map it into a version staged outdoors with natural lighting and a blurred background, while keeping the shoe's exact shape, logo, and colour intact — letting the platform generate multiple "styled" catalogue images from a single studio shoot instead of re-photographing the product.
When paired examples aren't available
If the platform doesn't have exact "same product, two backgrounds" pairs, the pix2pix setup above (which needs paired data) isn't directly usable; CycleGAN is the standard alternative — two generators G: A→B, F: B→A and two discriminators, trained with adversarial losses plus a cycle-consistency loss ‖F(G(a)) − a‖ + ‖G(F(b)) − b‖ that forces the product's identity to survive the round trip even without paired supervision.
Exam tip
State explicitly what plays the role of the condition y in this scenario (the input product image, not a label) — that's the detail that distinguishes image-to-image cGANs from the class-conditional cGAN most students default to describing.