Introduction
Generative Adversarial Networks (GANs), particularly StyleGAN, have revolutionized high-fidelity image synthesis. However, applying these models to real-world images requires GAN Inversion—the process of mapping an image back into the generator's latent space. This task is plagued by a persistent "distortion-editability trade-off." High-fidelity reconstructions often result in latent codes located in out-of-distribution regions, making them difficult to edit without introducing artifacts. Conversely, mapping images to well-behaved latent regions often sacrifices fine-grained details like textures and background elements.
Existing "compensate" methods attempt to bridge this gap by adding distortion maps, but these often operate at the pixel level, leading to spatial inconsistencies and a loss of contextual coherence.
Methodology: The SDIC Framework
To address these challenges, we propose Spatial-Contextual Discrepancy Information Compensation (SDIC). Unlike previous methods that follow an "edit-then-compensate" approach, SDIC utilizes a "compensate-and-edit" paradigm. This ensures that missing details are integrated into the generation process before any manipulation occurs.
Discrepancy Information Prediction Network (DIPN)
The DIPN employs a two-branch "hourglass" architecture to compare the original input image with an initial reconstruction. Rather than simple pixel-wise subtraction, it extracts multi-level spatial-contextual information to predict a comprehensive discrepancy map. This map captures the geometric and contextual relationships of missing features, ensuring they respect the surrounding image structure.
Discrepancy Information Compensation Network (DICN)
The DICN utilizes the predicted discrepancy map to enhance the inversion process at two levels:
- Latent Code ($w$): A learned affine transformation is applied to the latent vector to refine global attributes.
- Generator Features: A Spatial Attention Fusion module injects fine-grained details directly into the early layers of the GAN generator, bypassing the capacity limitations of the low-dimensional latent space.
Experimental Evaluation
The SDIC model was evaluated on high-resolution benchmarks, including FFHQ, CelebA-HQ, and Stanford Cars.
Quantitative Results
SDIC demonstrates superior performance across all major metrics on the CelebA-HQ dataset:
- Reconstruction Fidelity: SDIC achieved an SSIM of 0.815 and a PSNR of 27.672, significantly outperforming both encoder-based (CLCAE: 0.725 / 25.665) and optimization-based methods (PTI: 0.703 / 24.355).
- Perceptual Quality: It recorded the lowest LPIPS (0.057), indicating higher visual similarity to the original images.
- Efficiency: With an inference time of 0.321 seconds per image, SDIC is orders of magnitude faster than optimization methods like PTI (~201 seconds), making it suitable for real-time deployment.
Qualitative Comparison
As shown in Figure 3, SDIC maintains high fidelity during complex attribute manipulations. While other methods like HFGI or CLCAE often introduce blurring or artifacts during aging or pose changes, SDIC preserves identity and fine details (e.g., hair texture, background) seamlessly.
Conclusion and Future Work
SDIC successfully mitigates the distortion-editability trade-off by leveraging spatial-contextual information and a novel "compensate-and-edit" paradigm. By injecting discrepancy information into both the latent code and generator feature maps, the model achieves state-of-the-art reconstruction and editing quality.
One remaining challenge is handling extreme geometric transformations, such as large head rotations, where the static discrepancy map may become misaligned. Future research will explore explicit feature alignment techniques to enhance robustness in these scenarios.
Summary updated