InterFaceGAN: Interpreting the Disentangled Face Representation Learned by GANs

Yujun Shen, Ceyuan Yang, Xiaoou Tang, Bolei Zhou

TL;DR

InterFaceGAN reveals that standard, unconditionally trained GANs naturally encode complex facial attributes (like age, gender, and pose) as simple linear directions in their latent space. By identifying these linear boundaries, researchers can precisely edit both generated and real faces—and even disentangle correlated attributes like age and eyeglasses—without needing to retrain the underlying GAN.

What Problem Does This Paper Address?

Generative Adversarial Networks (GANs) like StyleGAN and PGGAN can synthesize incredibly photorealistic faces from random noise vectors (latent codes). However, these models are traditionally "black boxes." If you sample a random vector, you get a random face, but you have no explicit control over the output. If you want to take a generated face and make it smile, or change its pose, how do you do it?

Previous approaches to semantic face editing usually required training entirely new conditional GANs from scratch, designing complex custom loss functions, or requiring massive labeled datasets. This paper asks a more fundamental question: does a standard, already-trained GAN spontaneously learn what a "smile" or "gender" is during its unsupervised training? And if so, how are these concepts organized in the latent space, and how can we hijack them for zero-shot image editing?

Methods

The authors propose InterFaceGAN, a simple but highly effective framework to interpret and control GAN latent spaces. The pipeline works as follows:

  1. Synthesize and Score: Generate 500,000 images using a pre-trained GAN (like PGGAN or StyleGAN) from randomly sampled latent codes. Pass these images through an off-the-shelf facial attribute classifier (a ResNet-50) to score them on attributes like pose, smile, age, gender, and eyeglasses.
  2. Find the Boundary: Take the latent codes that produced the highest-scoring (e.g., most smiling) and lowest-scoring (least smiling) images. Train a simple linear Support Vector Machine (SVM) on these latent codes to find a separating hyperplane.
  3. Single Attribute Manipulation: The normal vector to this hyperplane represents the "direction" of the attribute. To make a generated face smile, you simply take its latent code and add a scaled version of the "smile" vector to it.
  4. Conditional Manipulation (Disentanglement): Because training data has biases (e.g., older people are more likely to wear glasses), moving along the "age" vector might accidentally add glasses to a face. The authors fix this using subspace projection: they mathematically force the "age" vector to be orthogonal (perpendicular) to the "glasses" vector, allowing them to edit one attribute without affecting the other.
  5. Real Image Editing: To edit a real photograph, they use GAN inversion (either optimization-based or an encoder network) to find the latent code that best reconstructs the real photo, and then apply the vector math above.

Datasets

  • GAN Training Data: The paper analyzes GANs pre-trained on CelebA-HQ (for PGGAN) and FF-HQ (for StyleGAN).
  • Classifier Training Data: The auxiliary ResNet-50 attribute classifier was trained on the standard CelebA dataset, utilizing its attribute annotations and 5-point facial landmarks.

Key Insights and Ideas

  • Semantics are surprisingly linear: You might expect complex visual concepts like "gender" or "age" to be highly non-linear manifolds in the latent space. Surprisingly, they are almost perfectly linearly separable.
  • GANs learn dataset biases, but we can fix them: The entanglement of attributes in the latent space perfectly mirrors the correlation of those attributes in the real-world training data. InterFaceGAN's orthogonal projection trick successfully bypasses the GAN's learned biases.
  • StyleGAN's $\mathcal{W}$ space is superior: The paper proves quantitatively that StyleGAN's intermediate latent space ($\mathcal{W}$ space) is significantly more disentangled than standard Gaussian noise spaces ($\mathcal{Z}$ space).
  • Layer-wise semantic hierarchy: By applying the vector edits only to specific layers of StyleGAN, the authors found a strict hierarchy. Early layers (00-01) control pose, middle layers (02-07) control age and expressions, and late layers (08-17) control texture and color.
  • "Artifacts" are an attribute: The authors manually labeled generated faces that had weird visual artifacts and trained an SVM on them. They discovered that GANs encode "image quality" as a direction, meaning you can actually "fix" a broken GAN generation by pushing its latent code away from the artifact direction.

Key Results

  • High Accuracy Boundaries: The linear SVMs achieved over 95% accuracy on validation sets of latent codes, proving the linear subspace hypothesis.
  • Effective Manipulation: Re-scoring analysis confirmed that moving a latent code along an attribute's normal vector reliably and smoothly increases the classifier's score for that attribute on the resulting image.
  • Successful Disentanglement: Conditional manipulation successfully decorrelated heavily entangled attributes. For example, they could age a face without changing its gender, or add glasses without aging the face.
  • Real Image Editing: Using optimization-based GAN inversion takes about 3 minutes per image but preserves identity beautifully during edits. Encoder-based inversion takes less than 0.1 seconds but loses some fine detail.

Limitations and Future Work

  • The "Distance Effect": The linear assumption holds well near the boundary, but breaks down for long-distance manipulation. If you push a latent code too far along a vector, the face distorts into an extreme, unnatural caricature and loses its original identity.
  • Reliance on Classifiers: InterFaceGAN requires an off-the-shelf classifier to score the generated images. This means you can only discover and control attributes that are well-defined and for which you already have labeled data.
  • Future Work: The authors suggest exploring non-linear boundaries for extreme edits, developing unsupervised methods to discover semantics without pre-trained classifiers, and applying this framework to more complex generative tasks like full scene generation with spatial layouts.

Summary updated

BibTeX
@article{shen2022interfacegan,
  author = {Yujun Shen and Ceyuan Yang and Xiaoou Tang and Bolei Zhou},
  title = {{InterFaceGAN: Interpreting the Disentangled Face Representation Learned by GANs}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2022},
  url = {https://openreview.net/forum?id=ldz4_cK1wX},
}
Figure