Contextual-based Image Inpainting: Infer, Match, and Translate

Yuhang Song, Chao Yang, Zhe Lin, Xiaofeng Liu, Qin Huang, Hao Li, C.‐c. Jay Kuo · DOI

Abstract

We study the task of image inpainting, which is to fill in the missing region of an incomplete image with plausible contents. To this end, we propose a learning-based approach to generate visually coherent completion given a high-resolution image with missing components. In order to overcome the difficulty to directly learn the distribution of high-dimensional image data, we divide the task into inference and translation as two separate steps and model each step with a deep neural network. We also use simple heuristics to guide the propagation of local textures from the boundary to the hole. We show that, by using such techniques, inpainting reduces to the problem of learning two image-feature translation functions in much smaller space and hence easier to train. We evaluate our method on several public datasets and show that we generate results of better visual quality than previous state-of-the-art methods.

Introduction

High-resolution image inpainting—the process of filling missing or masked regions—is a significant challenge in computer vision. The primary obstacle is the "dimensionality curse": learning the distribution of high-dimensional pixel data often leads to blurry artifacts or structural inconsistencies. While deep generative models like Generative Adversarial Networks (GANs) have improved results, they frequently struggle with high resolutions.

Existing approaches generally fall into two categories: learning-based methods (e.g., Context-Encoders), which are fast but produce blurry results for large missing regions, and optimization-based methods (e.g., style transfer), which yield high-quality textures but are computationally prohibitive. This research aims to bridge this gap by developing a system that maintains the speed of feed-forward neural networks while achieving the sharp, high-frequency textures of optimization techniques.

Methodology

The proposed framework decouples the inpainting task into a three-stage "Infer, Match, and Translate" pipeline. This separation allows the model to handle structure prediction and texture synthesis independently.

  1. Inference (Image2Feature): An encoder-decoder network ($G_1$) predicts a coarse, blurry version of the missing region. This output is processed through a pre-trained VGG-19 network to extract a high-level feature map ($F_1$), capturing the underlying semantic structure.
  2. Matching (Patch-Swap): To address the blurriness of the initial inference, a "patch-swap" layer searches the known image boundaries for similar neural patches. These sharp textures are then swapped into the hole region of the feature map, effectively "borrowing" contextually relevant details from the surrounding area.
  3. Translation (Feature2Image): A second U-Net style generator ($G_2$) translates the refined, "swapped" feature map back into a sharp, full-resolution image.

Training Strategy

A critical innovation is the training of the Feature2Image network. Rather than training on the noisy outputs of the first stage, the authors utilize features derived from ground truth images. This constrains the mapping space, enabling the model to learn sharp reconstruction more effectively. During inference, the model generalizes surprisingly well to the predicted features.

Experimental Setup

The models were trained and evaluated on two large-scale benchmarks:

  • COCO: 118,287 training images.
  • ImageNet CLS-LOC: Approximately 1.28 million training images.

Testing included both fixed-center masks and random holes of varying shapes and sizes to ensure robustness.

Key Results and Discussion

The proposed method demonstrates significant improvements in both quantitative metrics and qualitative visual quality.

Quantitative Performance

On ImageNet test sets, the approach achieved a Structural Similarity Index (SSIM) of 0.56 and an Inception Score of 11.36, outperforming state-of-the-art methods such as Global-Local (GL) inpainting and Neural Patch Synthesis (NPS).

Qualitative Comparison

As shown in the comparisons below, the method produces significantly fewer artifacts than GL inpainting and maintains better semantic coherence than Context-Encoders. The patch-swap operation, implemented via paralleled convolutions, allows for efficient processing (0.1s for a 64x64 feature map).

Qualitative comparison of inpainting results on roof and zebra images. (a, d) Input masked images; (b, e) results from baseline methods; (c, f) results from the proposed method.

Efficiency and User Preference

The entire feed-forward process takes approximately 400ms for a 512x512 image on an NVIDIA 1080Ti. In a blind user study of 400 images, the proposed method's results were ranked as the "best" in 75.9% of cases.

Conclusion and Future Work

By separating "what" should be in a hole (structure) from "how" it should look (texture), this research significantly reduces the complexity of high-resolution inpainting. While highly effective, the model can still struggle with unique, complex structures (e.g., specific faces) that the inference network cannot accurately predict. Future work may involve extending this multi-stage, multi-scale approach to general high-resolution image synthesis tasks beyond inpainting.

Summary updated

BibTeX
@inproceedings{song2018contextual,
  author = {Yuhang Song and Chao Yang and Zhe Lin and Xiaofeng Liu and Qin Huang and Hao Li and C.‐C. Jay Kuo},
  title = {{Contextual-based Image Inpainting: Infer, Match, and Translate}},
  booktitle = {European Conference on Computer Vision},
  year = {2018},
  doi = {10.1007/978-3-030-01216-8\_1},
}
Figure