InvGAN: Invertible GANs

Partha Ghosh, Dominik Zietlow, Michael J. Black, Larry S. Davis, Xiaochen HuarXiv 2021

TL;DR

InvGAN introduces a general framework for training "invertible" GANs by jointly learning a generator and an inference module (encoder) from scratch. This allows for near-instantaneous mapping of real images into a GAN’s latent space, enabling high-quality semantic editing, inpainting, and data augmentation across diverse architectures and datasets.

What Problem Does This Paper Address?

Generative Adversarial Networks (GANs) are the gold standard for creating photo-realistic images, but they have a fundamental "one-way street" problem. While they are excellent at turning random noise (latent codes) into images, they lack a built-in mechanism to do the reverse: taking a real-world photo and finding the specific latent code that produced it.

Without this "inversion" capability, we can't easily use GANs to edit real photos. If you want to use a GAN to change the hair color in a real portrait, you first have to find where that portrait "lives" in the GAN’s latent space. Existing solutions usually fall into two camps:

  1. Optimization-based: These are slow, requiring hundreds of iterative steps to "find" the right code for a single image.
  2. Model-based: These train an encoder after the GAN is already finished, which often leads to poor reconstruction because the generator wasn't built to be inverted.

Furthermore, most existing methods are "brittle"—they only work for specific architectures (like StyleGAN) or specific datasets (like human faces). InvGAN aims to be a general, fast, and architecture-agnostic solution.

Methods

The core philosophy of InvGAN is joint training. Instead of treating inversion as an afterthought, the authors train the generator ($G$) and the inference module ($D$) simultaneously so they can adapt to one another.

Key Technical Components:

  • The Dual-Head Discriminator: The discriminator is modified to perform two tasks: its standard job (distinguishing real from fake) and a new job (predicting the latent code $w$ from an image).
  • Multi-Part Loss Function: To ensure high-quality inversion, the authors use a sophisticated objective function:
  • Latent Reconstruction Loss: Ensures that if you encode an image and then decode it, you get the same latent code back.
  • Pixel-Space Reconstruction Loss: Uses the discriminator itself as a feature extractor to ensure the reconstructed image looks like the original.
  • Maximum Mean Discrepancy (MMD): A loss term that forces the distribution of encoded real images to match the prior distribution (usually Gaussian) that the GAN expects.
  • Tiling Strategy: To handle high resolutions without massive memory requirements, the authors propose a tiling method where the model is trained on small patches and then "tiled" to reconstruct larger images.

Datasets

The authors evaluated InvGAN across a wide variety of benchmarks to prove its generality:

  • MNIST: Used for initial ablation studies.
  • CelebA & FFHQ: The standard benchmarks for high-resolution face generation and semantic editing.
  • ImageNet: Used to test the model on complex, diverse object categories using the BigGAN architecture.
  • UCF101: Used to demonstrate temporal interpolation in video sequences.

Key Insights and Ideas

  • Co-adaptation is King: By training the encoder and generator together, the generator learns to produce a latent space that is naturally easier to navigate and invert. This "handshake" between the two modules is what allows for one-shot inversion.
  • Discriminator as a Perceptual Metric: Instead of relying on external pre-trained models (like VGG) for reconstruction loss—which can be susceptible to adversarial noise—InvGAN uses its own discriminator. Since the discriminator is already learning the features of the dataset, it serves as a robust, specialized critic for reconstructions.
  • Agnosticism: Unlike previous state-of-the-art methods that rely on the specific "W+" space of StyleGAN, InvGAN works effectively on DCGAN and BigGAN, suggesting it is a fundamental improvement to the GAN training pipeline.

Key Results

  • Speed: InvGAN performs inversion in "one shot" (a single forward pass). This makes it orders of magnitude faster than optimization methods—roughly $10^{-3}$ seconds per image compared to ~100 seconds for iterative methods.
  • Semantic Consistency: The authors proved that the reconstructions aren't just visually similar; they are semantically identical. Classifiers trained solely on InvGAN-reconstructed images performed nearly as well as those trained on original images (e.g., 0.81 vs 0.81 Mean Average Precision on CelebA).
  • Versatility: The paper demonstrates successful applications in image inpainting (fixing holes in photos), style mixing, and even "de-blurring" by navigating the latent space.

Limitations and Future Work

  • Rare Feature Reconstruction: The authors noted that the model struggles with "outlier" features that appear rarely in the training set, such as specific hats or background objects. These features tend to be smoothed out during reconstruction.
  • Tiling Seams: While the tiling strategy allows for high-resolution outputs, it can occasionally produce visible "seams" between patches, as the model does not explicitly learn to coordinate neighboring tiles.
  • 3D Inductive Biases: The authors suggest that incorporating 3D geometry or lighting priors (like those in models like GIF or HoloGAN) could further improve the inference module's accuracy.

Summary updated

BibTeX
@misc{ghosh2021invgan,
  author = {Partha Ghosh and Dominik Zietlow and Michael J. Black and Larry S. Davis and Xiaochen Hu},
  title = {{InvGAN: Invertible GANs}},
  year = {2021},
  eprint = {2112.04598},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.04598},
}
Figure