AE-StyleGAN: Improved Training of Style-Based Auto-Encoders

Ligong Han, Sri Harsha Musunuri, Martin Renqiang Min, Ruijiang Gao, Yu Tian, Dimitris Metaxas

TL;DR

AE-StyleGAN introduces a novel framework for training style-based autoencoders end-to-end, rather than the traditional two-stage "train then invert" approach. By jointly optimizing the encoder and generator to reconstruct real images, the authors achieve superior image generation, more accurate reconstructions, and a more disentangled latent space compared to previous methods like ALAE.

What Problem Does This Paper Address?

StyleGANs are the gold standard for high-quality image synthesis, largely due to their "disentangled" latent space ($W$), where different visual attributes (like age or expression) are separated into different dimensions. However, using these models to edit real images requires "GAN inversion"—finding the specific latent code that perfectly reconstructs a given photo.

Traditionally, this is done in two stages: first, you train the GAN; then, you train a separate encoder to map images back to the latent space. This often leads to a "lag" where the encoder struggles to keep up with the generator's complexity. Existing end-to-end attempts, like Adversarial Latent Autoencoders (ALAE), often suffer from poor generation quality because they focus on reconstructing fake images rather than real ones, and they use discriminators in the latent space rather than the image space.

AE-StyleGAN asks: Can we train the encoder and generator simultaneously to reconstruct real data, and does this actually make the latent space better?

Methods

The authors propose two architectures, ultimately favoring the Joint AE-StyleGAN:

  1. Decoupled AE-StyleGAN: Uses two separate discriminators—one for standard GAN training and one for the inversion task. While it keeps the generator's original ability intact, the encoder often fails to "catch up" with the generator's learning curve, leading to noisy reconstructions.
  2. Joint AE-StyleGAN: This is the core contribution. The encoder ($E$) and generator ($G$) are trained together using a shared discriminator. The generator is forced to reconstruct real images during the training process. The authors treat these reconstructions as a form of "Negative Data Augmentation," essentially telling the discriminator that reconstructions are "fake" while the original images are "real."
  3. Adaptive Discriminator Weight: To prevent the reconstruction loss from over-powering the adversarial (generation) loss, they implement an adaptive weighting scheme (inspired by VQ-GAN). This dynamically balances the two forces based on the gradients of the last layer of the generator.

Datasets

The model was evaluated on four diverse, high-quality datasets, all resized to $128 \times 128$ for training:

  • FFHQ: 70,000 high-quality human faces.
  • AFHQ: 15,000 images of cats, dogs, and wildlife.
  • MetFaces: 1,336 images of human faces from Metropolitan Museum art pieces.
  • LSUN Church: 126,000 photographs of churches with varying architectural styles.

Key Insights and Ideas

  • The "Lagging" Problem: In decoupled training, the generator evolves faster than the encoder can learn to invert it. Joint training solves this by ensuring the generator remains "invertible" throughout its entire evolution.
  • Invertibility $\implies$ Disentanglement: The authors discovered a virtuous cycle: forcing a generator to be easy to invert actually leads to a more disentangled latent space. This makes sense intuitively—if the latent space is messy and entangled, the encoder will have a harder time finding a unique mapping for a real image.
  • Real vs. Fake Reconstruction: Unlike ALAE, which minimizes the distance between a sampled latent code and an encoded fake image, AE-StyleGAN focuses on the distance between a real image and its reconstruction. This "in-domain" focus is key to its superior performance on real-world editing tasks.

Key Results

AE-StyleGAN consistently outperformed the competitive baseline (ALAE) across multiple metrics:

  • Generation Quality: On the FFHQ dataset, AE-StyleGAN ($W+$) achieved an FID of 7.941, significantly better than ALAE’s 12.574.
  • Reconstruction Accuracy: The model reduced Mean Squared Error (MSE) in reconstructions by more than 50% compared to ALAE. Qualitative results show AE-StyleGAN preserves fine details like background, color, and specific facial expressions that ALAE loses.
  • Disentanglement: Using the Perceptual Path Length (PPL) metric, AE-StyleGAN showed 13% to 22% improvement over ALAE on complex datasets like LSUN Church and FFHQ, confirming a more organized latent space.

Limitations and Future Work

While the results are impressive, the paper notes a few areas for growth:

  • Resolution: The experiments were conducted at $128 \times 128$ resolution. Scaling this joint training to $1024 \times 1024$ (the native StyleGAN2 resolution) would be computationally intensive.
  • Disentanglement Techniques: The authors suggest that their framework could be further improved by incorporating explicit disentanglement techniques like those found in Factor-VAE.
  • Integration: There is potential to integrate this approach into other architectures, such as CR-GAN, to improve multi-view generation.

Summary updated

Abstract

StyleGANs have shown impressive results on data generation and manipulation in recent years, thanks to its disentangled style latent space. A lot of efforts have been made in inverting a pretrained generator, where an encoder is trained ad hoc after the generator is trained in a two-stage fashion. In this paper, we focus on style-based generators asking a scientific question: Does forcing such a generator to reconstruct real data lead to more disentangled latent space and make the inversion process from image to latent space easy? We describe a new methodology to train a style-based autoencoder where the encoder and generator are optimized end-to-end. We show that our proposed model consistently outperforms baselines in terms of image inversion and generation quality. Supplementary, code, and pretrained models are available on the project website.
BibTeX
@inproceedings{han2022ae,
  author = {Ligong Han and Sri Harsha Musunuri and Martin Renqiang Min and Ruijiang Gao and Yu Tian and Dimitris Metaxas},
  title = {{AE-StyleGAN: Improved Training of Style-Based Auto-Encoders}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2022},
  doi = {10.1109/wacv51458.2022.00103},
}
Figure