Region Normalization for Image Inpainting

Tao Yu, Zongyu Guo, Xin Jin, Shilin Wu, Zhibo Chen, Weiping Li, Zhizheng Zhang, Sen Liu

TL;DR

Standard feature normalization methods (like Instance or Batch Norm) inadvertently hinder image inpainting by mixing the statistics of corrupted and uncorrupted regions. Region Normalization (RN) solves this by normalizing these regions separately, preventing harmful mean and variance shifts and significantly boosting the performance of existing inpainting architectures.

What Problem Does This Paper Address?

In deep learning, Feature Normalization (FN) is a staple for stabilizing training. However, the authors argue that standard FN methods are sub-optimal for image inpainting.

Why? Because inpainting inputs are inherently "bipolar": they contain valid, uncorrupted pixels and invalid, corrupted (masked) pixels. Standard normalization calculates a single mean and variance across the entire spatial dimension. As shown in Figure 2, when you normalize a feature map containing a large corrupted area (often filled with a constant value like 255), the mean of the valid pixels shifts significantly, and their variance increases.

Figure 2: (a) F1 is the original feature map. F2 with mask performs full-spatial normalization in all the regions. F3 per- forms separate normalization in the masked and unmasked regions. (b) The distribution of F2’s unmasked area has a shift to the nonlinear region, which easily causes the vanish- ing gradient problem. But F3 does not have this problem.

This "mean and variance shift" pushes the activations of valid pixels into the saturated regimes of non-linearities (like ReLU or Sigmoid), leading to vanishing gradients and forcing the network to waste training capacity just to correct these shifts.

Methods

The authors propose Region Normalization (RN), which divides spatial pixels into $K$ regions (for inpainting, $K=2$) and normalizes each independently.

Figure 1: Illustration of our Region Normalization (RN) with region number K = 2. Pixels in the same color (green or pink) are normalized by the same mean and variance. The corrupted and uncorrupted regions of the input image are normalized by different means and variances.

They introduce two specific variants to handle different stages of the network:

  1. Basic RN (RN-B): Used in the early encoder layers. It uses the original input mask to explicitly separate corrupted and uncorrupted regions for normalization. This prevents the initial "pollution" of valid feature statistics.
  2. Learnable RN (RN-L): Used in later layers (residual blocks and decoder). As features pass through convolutions, the boundary between "corrupted" and "valid" becomes blurred. RN-L automatically detects these regions by generating a spatial response map from the features themselves (using max/avg pooling and a small convolution). It then uses this map to generate a predicted mask for normalization and applies pixel-wise affine parameters ($\gamma, \beta$) to enhance the fusion of synthesized and original content.

The authors integrated these into a backbone based on the EdgeConnect architecture, replacing standard Instance Normalization (IN) with RN.

Datasets

The model was evaluated on two standard benchmarks:

  • Places2: A large-scale dataset of diverse scenes.
  • CelebA: A dataset of human faces.

Testing involved both regular masks (fixed squares) and irregular masks (randomly generated shapes covering 0-60% of the image).

Key Insights and Ideas

  • Normalization as a Bottleneck: The most significant insight is that standard normalization, usually a "help," becomes a "hindrance" in inpainting because it ignores the spatial validity of data.
  • Spatial Awareness: By making normalization spatially aware, the network preserves the integrity of uncorrupted features, allowing it to focus its learning capacity on synthesis rather than correction.
  • Soft Fusion: RN-L acts as a sophisticated fusion mechanism. By learning where the "holes" are in deeper layers, it can apply different transformations to synthesized vs. original regions, leading to more seamless results.
  • Plug-and-Play: RN isn't a new architecture; it's a new layer. This makes it highly generalizable to other models.

Key Results

RN consistently outperformed state-of-the-art (SOTA) methods like Partial Convolution (PC) and Gated Convolution (GC) both quantitatively and qualitatively.

  • Quantitative: On the Places2 dataset, the RN-based model improved PSNR by 0.73 dB and SSIM by 0.017 compared to a baseline using Instance Normalization.
  • Generalization: When plugged into other SOTA backbones, RN provided a significant boost. For example, adding RN to the Contextual Attention (CA) model increased its PSNR by a massive 2.52 dB.
  • Qualitative: The method produces fewer artifacts and better textures, especially in complex scenes, because it avoids the "blurry" statistics caused by mixing corrupted and valid pixels.

Limitations and Future Work

  • RN-L Thresholding: The thresholding used in RN-L to create a binary mask is only applied during inference; during training, the gradients do not pass through this operation, which might limit the optimality of the learned regions.
  • Interaction with Gated Conv: The authors noted that the performance gain on Gated Convolution (GC) was less impressive. They hypothesize that GC's inherent smoothing makes it harder for RN-L to accurately track and separate corrupted regions.
  • Broader Applications: While highly effective for inpainting, the authors suggest exploring RN for other supervised tasks like object detection or classification where spatial distributions might also impact normalization.

Summary updated

BibTeX
@inproceedings{yu2020region,
  author = {Tao Yu and Zongyu Guo and Xin Jin and Shilin Wu and Zhibo Chen and Weiping Li and Zhizheng Zhang and Sen Liu},
  title = {{Region Normalization for Image Inpainting}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.1609/aaai.v34i07.6967},
}
Figure