Feature-Style Encoder for Style-Based GAN Inversion

Xu Yao, Alasdair Newson, Yann Gousseau, Pierre HellierarXiv 2022

Abstract

We propose a novel architecture for GAN inversion, which we call Feature-Style encoder. The style encoder is key for the manipulation of the obtained latent codes, while the feature encoder is crucial for optimal image reconstruction. Our model achieves accurate inversion of real images from the latent space of a pre-trained style-based GAN model, obtaining better perceptual quality and lower reconstruction error than existing methods. Thanks to its encoder structure, the model allows fast and accurate image editing. Additionally, we demonstrate that the proposed encoder is especially well-suited for inversion and editing on videos. We conduct extensive experiments for several style-based generators pre-trained on different data domains. Our proposed method yields state-of-the-art results for style-based GAN inversion, significantly outperforming competing approaches.

Introduction

Generative Adversarial Networks (GANs), particularly StyleGAN, have revolutionized image synthesis by generating high-resolution, realistic images from latent codes. However, applying these generative powers to real-world images requires GAN Inversion: the process of mapping a real image back into the GAN's latent space. This task is plagued by a fundamental "distortion-editability" trade-off. High-fidelity reconstructions often result in latent codes that are "out-of-distribution," making them impossible to edit without introducing artifacts. Conversely, codes that are easy to edit often fail to capture the unique, fine-grained details of the original subject, resulting in a generic appearance.

Methodology

To bridge this gap, we introduce the Feature-Style Encoder, a dual-branch architecture that decouples global semantic attributes from local spatial details:

  • Style Branch: This branch predicts a standard latent code ($w \in W^+$), capturing global characteristics such as gender, lighting, and pose. This ensures the image remains within the editable domain of the GAN.
  • Feature Branch: To capture fine details, this branch predicts a spatial feature map ($F$) that is injected into a specific middle layer ($K=5$) of the StyleGAN generator. This "spatial anchoring" allows the model to retain specific features like wrinkles or unique eye shapes that a single vector cannot represent.
  • Training and Editing: The model is trained simultaneously on real and synthetic images. For editing, we employ a modified equation that updates both the style code and the feature map $F$, ensuring that spatial details move in harmony with semantic changes (e.g., ensuring a mole stays in the correct position when a face smiles).

Experimental Results

We evaluated the Feature-Style Encoder across diverse domains, including faces (FFHQ/CelebA-HQ), cars (Stanford Cars), and animals (AFHQ). Quantitatively, our method demonstrates a significant leap in performance, notably achieving a 50% improvement in LPIPS (Learned Perceptual Image Patch Similarity) compared to previous state-of-the-art encoders.

Comparison of GAN inversion methods on a real face image. Our Feature-Style Encoder achieves the best perceptual quality with an LPIPS score of 0.064, significantly lower than competing encoders like pSp (0.143) or HFGI (0.109).

Beyond perceptual metrics, our model maintains superior identity preservation (measured via ArcFace) and structural accuracy (SSIM/PSNR). A key advantage of our approach is its temporal stability in video inversion (tested on the RAVDESS dataset), where it avoids the flickering artifacts common in optimization-based methods.

Discussion and Limitations

The choice of injecting features at layer $K=5$ (16x16 resolution) was found to be the "sweet spot" for balancing reconstruction fidelity and editability. While the model excels at most tasks, complex occlusions—such as very long hair during a gender swap—can still pose challenges, as the feature map may "cling" too strongly to the original structure. Future work will explore the use of masks for more granular local editing and investigate channel-specific traits within the feature map for even finer control.

Summary updated

BibTeX
@misc{yao2022feature,
  author = {Xu Yao and Alasdair Newson and Yann Gousseau and Pierre Hellier},
  title = {{Feature-Style Encoder for Style-Based GAN Inversion}},
  year = {2022},
  eprint = {2202.02183},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2202.02183},
}
Figure