High-Fidelity Image Inpainting with GAN Inversion

Yongsheng Yu, Libo Zhang, Heng Fan, Tiejian Luo

Introduction: The Challenge of Image Inpainting

Image inpainting—the process of restoring missing or corrupted regions in an image—remains a significant challenge in computer vision, particularly when dealing with large-scale masks. While standard convolutional architectures perform well on small defects, they often struggle to generate realistic textures for substantial "holes."

Recent advancements have leveraged GAN Inversion, using pre-trained generators (like StyleGAN) as powerful priors to synthesize missing content. However, these methods frequently suffer from a phenomenon the authors term "gapping." Because standard inversion focuses on finding a global latent code, it often fails to respect the "hard constraint" of the original, unmasked pixels. This results in visible seams, color mismatches, and semantic inconsistencies where the generated patch meets the original image.

A corrupted image from the MetFaces dataset featuring a large, irregular mask that obscures significant facial features.

The InvertFill Framework

To address these limitations, the authors introduce InvertFill, an encoder-based framework designed to bridge the gap between latent representation and pixel-level fidelity. The model introduces three core innovations:

  1. $F\&W^+$ Latent Space: Unlike traditional inversion that relies solely on latent vectors, InvertFill incorporates a direct skip-connection from the corrupted input image to the generator's RGB branch. This allows the generator to "see" the original pixels, ensuring the output is anchored to the existing content.
  2. Pre-modulation Module: A dedicated network within the encoder extracts multi-scale structural information. This data is used to modulate the style vectors, helping the model better perceive the uncorrupted context and guide the generation process.
  3. Soft-update Mean Latent (SML): To avoid the blurry, repetitive textures often produced by static mean latent codes, SML dynamically fluctuates the mean latent during training. This stochastic approach encourages the model to capture a broader distribution of patterns, resulting in sharper and more varied textures.

Experimental Results

InvertFill was evaluated across four diverse datasets: Places2 (real-world scenes), CelebA-HQ (high-resolution faces), MetFaces (artistic portraits), and Scenery (landscapes).

The model demonstrated superior performance both quantitatively and qualitatively. On the Places2 dataset with extreme masks (70%–90% corruption), InvertFill achieved an FID of 21.08, a massive improvement over the previous state-of-the-art, ProFill (46.44). In terms of perceptual quality on CelebA-HQ, it reached an LPIPS score of 0.089, indicating results that are significantly closer to human visual perception.

The inpainting result produced by InvertFill, demonstrating high-fidelity reconstruction and seamless blending even for out-of-domain artistic data.

Key Insights and Limitations

A primary takeaway is that GANs cannot rely on latent codes alone to maintain local consistency. By providing a direct path for input pixels into the generator, InvertFill effectively bridges the semantic and color gaps. Furthermore, the SML module proves that dynamic regularization is essential for maintaining high visual fidelity without sacrificing diversity.

However, the model is not without limitations. In cases where the corrupted region lacks sufficient surrounding context, the model may occasionally mislocate features (e.g., slightly misplacing an eye or mouth). Future work will likely focus on integrating better global scene understanding to prevent these structural misalignments while maintaining the high-fidelity texture generation demonstrated here.

Summary updated

BibTeX
@inproceedings{yu2022high,
  author = {Yongsheng Yu and Libo Zhang and Heng Fan and Tiejian Luo},
  title = {{High-Fidelity Image Inpainting with GAN Inversion}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19787-1\_14},
}
Figure