Learning Pyramid-Context Encoder Network for High-Quality Image Inpainting.

Yanhong Zeng, Jianlong Fu, Hongyang Chao, Baining Guo

Abstract

High-quality image inpainting requires filling missing regions in a damaged image with plausible content. Existing works either fill the regions by copying high-resolution patches or generating semantically-coherent patches from region context, while neglecting the fact that both visual and semantic plausibility are highly-demanded. In this paper, we propose a Pyramid-context Encoder Network (denoted as PEN-Net) for image inpainting by deep generative models. The proposed PEN-Net is built upon a U-Net structure with three tailored components: a pyramid-context encoder, a multi-scale decoder, and an adversarial training loss. Extensive experiments on a broad range of datasets show the superior performance of the proposed network.

Introduction

Image inpainting—the process of restoring missing or damaged parts of an image—has traditionally struggled to balance two competing needs: visual plausibility (sharp, realistic textures) and semantic coherence (logical structure).

Traditional patch-based methods excel at texture reproduction but often fail to understand the global context, leading to structural errors. Conversely, deep generative models understand the "big picture" but often produce blurry results due to the loss of fine-grained detail in compressed latent spaces. PEN-Net addresses this by bridging the gap between high-level semantic understanding and low-level texture detail.

Methodology

PEN-Net utilizes a U-Net backbone enhanced by three critical innovations designed to ensure both logical consistency and sharp textures.

1. Attention Transfer Network (ATN)

The ATN is the core mechanism of PEN-Net. It calculates "region affinity" to determine which visible parts of an image are most similar to the missing region. Crucially, it learns this mapping at a high semantic level (low resolution) and then transfers that attention map to higher-resolution layers. This ensures that the textures chosen to fill a hole are guided by the overall logic of the scene.

2. Pyramid-Context Encoder

Rather than filling a hole in a single pass, the model employs a pyramid-filling strategy. It repeats the ATN process across multiple encoder layers, from deep to shallow. This allows the network to progressively refine the missing area using increasingly detailed information, ensuring the final result is both semantically sound and visually sharp.

3. Multi-scale Decoder and Adversarial Loss

The decoder is trained with deeply-supervised pyramid L1 losses, penalizing errors at every resolution scale. This is combined with a PatchGAN adversarial loss to ensure the final output is indistinguishable from real images to a discriminator network.

Key Results

PEN-Net was evaluated on four diverse datasets: Facade (architecture), DTD (textures), CELEBA-HQ (faces), and Places2 (natural/urban scenes).

Qualitative results of PEN-Net across four datasets: Facade, CelebA-HQ, DTD, and Places2. The model successfully restores complex structures and textures in large missing regions.

Quantitative Performance

On the challenging Places2 dataset, PEN-Net achieved a 78.09% MS-SSIM (Multi-Scale Structural Similarity) and an Inception Score (IS) of 50.51, significantly outperforming baseline models.

Qualitative and User Evaluation

Visual results demonstrate that PEN-Net avoids the blurriness typical of generative models and the structural distortions of patch-based methods. In a blind user study, volunteers chose PEN-Net as the most natural-looking result 82.10% of the time compared to other leading methods.

Conclusion

By using semantics to guide texture selection through the Attention Transfer Network, PEN-Net sets a new standard for high-quality image inpainting. While future work will focus on scaling the architecture for even higher resolutions and reducing computational costs, the current model proves highly effective at hallucinating complex structures like eyes on faces and windows on buildings with remarkable accuracy.

Summary updated

BibTeX
@inproceedings{zeng2019learning,
  author = {Yanhong Zeng and Jianlong Fu and Hongyang Chao and Baining Guo},
  title = {{Learning Pyramid-Context Encoder Network for High-Quality Image Inpainting.}},
  booktitle = {CVPR},
  year = {2019},
  url = {https://openreview.net/forum?id=Bji-T17g_TB},
}
Figure