Abstract
GAN inversion often faces a fundamental trade-off between reconstruction fidelity and the ability to perform semantic edits. Standard models like StyleGAN2 struggle with "out-of-domain" (OOD) elements such as jewelry or complex backgrounds. This paper introduces a novel framework that decomposes images into in-domain face regions and OOD elements using a Spatial Alignment and Masking Module (SAMM). By employing optical flow to correct geometric misalignments, the method achieves high-fidelity reconstructions and seamless attribute editing. Quantitative results on the CelebAMask-HQ dataset show a significant improvement in PSNR (27.24 vs 25.24) over previous state-of-the-art methods.
Introduction
The goal of GAN inversion is to map a real image into a GAN’s latent space to enable downstream editing. However, pre-trained generators have a limited "vocabulary." When an image contains OOD elements—specific accessories, unique hair textures, or complex backgrounds—the inversion process typically results in either a loss of these details or a distorted latent space that prevents clean editing.
The authors identify geometrical misalignment as the primary obstacle. Even slight shifts between the GAN’s reconstruction and the original image create artifacts in the "invertibility masks" used to blend OOD pixels back. This paper proposes a solution that aligns features before masking, ensuring that OOD elements are isolated accurately without ghosting or blurriness.
Methodology
The core of the proposed framework is the Spatial Alignment and Masking Module (SAMM). The process involves four key steps:
- Feature Generation: An encoder maps the input to a latent vector $w$, which is processed by StyleGAN2 to create initial feature maps.
- Iterative Alignment: SAMM predicts the optical flow between the input image and the GAN's generated features. It warps the generated features to align geometrically with the input, minimizing reconstruction error in the "In-Domain" (ID) regions.
- Invertibility Decomposition: With the features aligned, the module predicts a precise binary mask ($m$) that identifies OOD regions.
- Seamless Blending: The final image is a composite: the face is generated/edited by the GAN, while OOD regions are blended back from the original image using the predicted mask.
Training is guided by standard reconstruction losses (MSE, LPIPS, ArcFace) and a specialized Mask Regularization loss that encourages the mask to be binary and parsimonious, maximizing the area available for GAN-based editing.
Experimental Results
The framework was evaluated primarily on the FFHQ and CelebAMask-HQ datasets.
Quantitative Evaluation
On the CelebAMask-HQ dataset, the method achieved a PSNR of 27.24, outperforming the previous state-of-the-art (FeatureStyle at 25.24). It also led in SSIM, LPIPS, and FID scores, indicating both higher pixel-level accuracy and better perceptual quality.
Qualitative Analysis and User Study
Visual results demonstrate the successful preservation of complex, fine-grained details like jewelry and microphone wires.
In a user study, the proposed method was ranked as the top choice for both inversion quality and attribute editing (e.g., adding a smile or changing age) compared to five major baselines.
Conclusion
This paper presents a robust solution to the fidelity-editability trade-off in GAN inversion by focusing on spatial alignment. By decoupling the reconstruction of OOD elements from the GAN's latent space, the method allows for photo-realistic face manipulation that preserves real-world details. While currently optimized for human faces, the underlying principle of invertibility decomposition via alignment holds promise for broader image editing domains.
Summary updated