NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Balancing Reconstruction and Editing Quality of GAN Inversion for Real Image Editing with StyleGAN Prior Latent Space

Kai Katsumata, Duc Minh Vo, Bei Liu, Hideki NakayamaarXiv 2023 · DOI

Abstract

GAN inversion is a critical step for real-world image editing, yet it faces a persistent trade-off between reconstruction fidelity and editing quality. High-capacity latent spaces like $\mathcal{W}^+$ often result in "out-of-distribution" latent codes that cause severe artifacts during semantic manipulation. This paper proposes a novel hybrid latent space, $\mathcal{F}/\mathcal{Z}^+$, which combines the bounded hyperspherical prior of the original StyleGAN $\mathcal{Z}$ space with intermediate feature maps $\mathcal{F}$. By enforcing a hyperspherical constraint during optimization, we ensure that latent codes remain within the generator's natural manifold. Experimental results on FFHQ and CelebA-HQ demonstrate that our method achieves high-fidelity reconstruction while significantly outperforming existing spaces in editing stability and identity preservation.

Introduction

The goal of GAN inversion is to map a real image into the latent space of a pre-trained generator, such as StyleGAN, to enable downstream editing tasks. However, researchers have long struggled with the "reconstruction-editing trade-off." To achieve pixel-perfect reconstruction, inversion methods often utilize high-dimensional, unbounded spaces like $\mathcal{W}^+$ or $\mathcal{S}$. While these spaces provide the necessary capacity to capture fine details, they allow the optimization process to find latent codes in low-density regions that the generator was never trained to handle. Consequently, when these codes are shifted for editing (e.g., changing age or expression), the resulting images often exhibit "waterdrop" artifacts or lose the subject's identity.

Proposed Method: The $\mathcal{F}/\mathcal{Z}^+$ Space

We propose the $\mathcal{F}/\mathcal{Z}^+$ space to bridge the gap between reconstruction and editability. Our approach is built on two key components:

  1. The $\mathcal{Z}^+$ Prior with Hyperspherical Constraint: Unlike $\mathcal{W}^+$, the original $\mathcal{Z}$ space is a bounded hypersphere. We extend this to $\mathcal{Z}^+$, providing layer-wise latent codes. During optimization, we implement a "retraction" step that projects latent codes back onto the surface of a hypersphere (radius $\sqrt{512}$). This ensures the codes stay within the generator's well-behaved prior.
  2. The $\mathcal{F}$ Feature Space: To fix the poor reconstruction quality of $\mathcal{Z}$, we supplement it with a feature map $\mathcal{F}$ from an intermediate layer of the generator. This map captures the complex geometric and spatial information of the real image, while the $\mathcal{Z}^+$ codes handle the semantic details.
Architecture comparison between the standard $\mathcal{F}/\mathcal{W}^+$ space and the proposed $\mathcal{F}/\mathcal{Z}^+$ space.

Results and Discussion

The proposed method was evaluated on standard face datasets (FFHQ, CelebA-HQ) and non-human domains (LSUN Cat).

Reconstruction Fidelity: Quantitative metrics show that $\mathcal{F}/\mathcal{Z}^+$ achieves MSE and SSIM scores nearly identical to the high-fidelity $\mathcal{F}/\mathcal{W}^+$ space, proving that the hyperspherical constraint does not hinder the ability to recreate the target image accurately.

Editing Quality and Identity Preservation: The primary advantage of our method is visible during semantic editing. As shown in Figure 3, editing in $\mathcal{W}^+$-based spaces often leads to distorted facial features and identity loss as the edit intensity increases. In contrast, $\mathcal{F}/\mathcal{Z}^+$ maintains high visual quality and preserves the subject's identity much more effectively. Quantitatively, the average identity similarity after editing was 0.373 for $\mathcal{F}/\mathcal{Z}^+$, significantly higher than the 0.327 achieved by $\mathcal{F}/\mathcal{W}^+$.

Qualitative comparison of semantic editing across different latent spaces. Note the artifacts and identity shifts in $\mathcal{W}^+$ vs. the stability of $\mathcal{Z}^+$.

Conclusion

By revisiting the bounded nature of StyleGAN's original $\mathcal{Z}$ space, we demonstrate that the "reconstruction-editing trade-off" can be mitigated. The $\mathcal{F}/\mathcal{Z}^+$ space provides a robust framework for real image editing that is both high-fidelity and semantically stable. Future work includes automating the selection of the intermediate feature layer $\mathcal{F}$ for diverse datasets.

Summary updated

BibTeX
@misc{katsumata2023balancing,
  author = {Kai Katsumata and Duc Minh Vo and Bei Liu and Hideki Nakayama},
  title = {{Balancing Reconstruction and Editing Quality of GAN Inversion for Real Image Editing with StyleGAN Prior Latent Space}},
  year = {2023},
  eprint = {2306.00241},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.00241},
}
Figure