High-Fidelity GAN Inversion with Padding Space

Qingyan Bai, Yinghao Xu, Jiapeng Zhu, Weihao Xia, Yujiu Yang, Yujun Shen

Abstract

PadInv introduces a novel "padding space" to the GAN inversion process, allowing for the capture of fine-grained spatial details that traditional latent spaces often miss. By replacing static zero-padding in convolutional layers with instance-aware coefficients, the method achieves high-fidelity image reconstruction and enables precise editing tasks, including face blending and one-shot customized manipulations.

Introduction: The Challenge of GAN Inversion

Generative Adversarial Networks (GANs) like StyleGAN are masters of synthesis, but "inverting" them—finding the exact latent code that produces a specific real-world image—remains a significant challenge. Existing inversion methods typically search within latent spaces such as $W$ or $W+$. While these spaces capture global styles effectively, they often fail to reconstruct intricate spatial details or "out-of-distribution" objects, such as a specific hat, a hand near a face, or unique background textures.

The authors identify a hidden culprit in this failure: fixed padding. Most GANs use constant zero-padding in their convolutional layers, creating a rigid "inductive bias" where the network expects certain textures to be anchored to specific spatial coordinates (the "texture-sticking" problem). When a real image does not fit this bias, the inversion process fails to recover the necessary details.

The PadInv Method

The authors propose PadInv, which extends the inversion space by incorporating a learnable Padding Space ($\mathcal{P}$).

The PadInv architecture, featuring an FPN-based encoder that predicts both latent codes w and padding coefficients p.

Instead of using fixed zeros, the generator is modified to accept instance-aware padding coefficients. This effectively "reprograms" the generator for each specific image without altering the actual weights of the pre-trained model. The system utilizes a tailored encoder based on a Feature Pyramid Network (FPN) to predict two key components: the layer-wise latent codes ($w$) and a coefficient tensor ($p$) that replaces the standard padding in the generator's convolutional layers. The encoder is trained using a multi-part loss function incorporating reconstruction (MSE/LPIPS), identity, adversarial, and regularization losses to ensure the model remains editable while maintaining high fidelity.

Key Insights and Results

A striking insight of this work is that padding provides the network with a sense of absolute spatial location. By making this space learnable, the network gains a "spatial buffer" to store details that do not fit into the global latent code. This creates a natural division of labor: the latent space ($W+$) encodes style (color, lighting, texture), while the new padding space ($\mathcal{P}$) encodes structure (pose, face shape, spatial layout).

Qualitative results of PadInv across inversion, blending, and editing tasks compared to baselines.

PadInv significantly outperforms state-of-the-art baselines like pSp and e4e. Quantitatively, it achieves lower MSE and LPIPS scores across standard benchmarks like FFHQ, CelebA-HQ, and LSUN datasets. Qualitatively, it successfully reconstructs "difficult" items like earrings, hands, and complex architectural spires that other methods smudge.

Beyond reconstruction, the method enables advanced applications:

  • Face Blending: By combining the latent code (style) from one image and padding coefficients (structure) from another, the authors achieved seamless blending without external landmark detectors.
  • One-Shot Editing: The system can extract a "direction" in the padding or latent space from a single pair of edited images to apply specific manipulations (e.g., changing eye distance) to other images with high precision.

Conclusion

While a distribution gap can sometimes cause minor artifacts at image edges, PadInv offers a robust solution to the spatial limitations of traditional GAN inversion. By preserving the GAN's prior knowledge through fixed weights while introducing flexibility via the padding space, the method opens new doors for high-fidelity image manipulation and deepfake detection research.

Summary updated

BibTeX
@inproceedings{bai2022high,
  author = {Qingyan Bai and Yinghao Xu and Jiapeng Zhu and Weihao Xia and Yujiu Yang and Yujun Shen},
  title = {{High-Fidelity GAN Inversion with Padding Space}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19784-0\_3},
}
Figure