Region Normalization for Image Inpainting

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

Abstract

Feature Normalization (FN) is an important technique to help neural network training, which typically normalizes features across spatial dimensions. Most previous image inpainting methods apply FN in their networks without considering the impact of the corrupted regions of the input image on normalization, e.g. mean and variance shifts. In this work, we show that the mean and variance shifts caused by full-spatial FN limit the image inpainting network training and we propose a spatial region-wise normalization named Region Normalization (RN) to overcome the limitation. RN divides spatial pixels into different regions according to the input mask, and computes the mean and variance in each region for normalization. We develop two kinds of RN for our image inpainting network: (1) Basic RN (RN-B), which normalizes pixels from the corrupted and uncorrupted regions separately based on the original inpainting mask to solve the mean and variance shift problem; (2) Learnable RN (RN-L), which automatically detects potentially corrupted and uncorrupted regions for separate normalization, and performs global affine transformation to enhance their fusion. We apply RN-B in the early layers and RN-L in the latter layers of the network respectively. Experiments show that our method outperforms current state-of-the-art methods quantitatively and qualitatively. We further generalize RN to other inpainting networks and achieve consistent performance improvements.

The Challenge of Spatial Non-Stationarity

In image inpainting, a model must fill in missing or corrupted pixels (the "mask") in a way that is visually and semantically consistent with the rest of the image. To stabilize training, deep learning models rely on Feature Normalization (FN)—like Batch or Instance Normalization—which scales features to have zero mean and unit variance across spatial dimensions.

However, standard FN assumes spatial stationarity, meaning the statistics are the same everywhere in the image. Inpainting explicitly breaks this assumption. Corrupted regions, often initialized as zeros or noise, have vastly different statistical properties than valid regions. When these are averaged together in a single normalization step, it causes a "mean and variance shift."

Figure 6: Illustration of feature maps and their distributions after normalization. The shift in distributions (b) can push features into the saturated zones of activation functions like ReLU or Sigmoid, hindering training.

As shown in the figure above, this shift pushes the features of valid regions into the saturated zones of activation functions (like ReLU or Sigmoid), leading to vanishing gradients and blurry, artifact-heavy reconstructions. The authors found that in some cases, using no normalization performed better than standard Instance Normalization, highlighting the severity of this pollution.

Proposed Method: Region Normalization (RN)

To address this, the authors introduce Region Normalization (RN). Instead of a global spatial average, RN divides spatial pixels into different regions based on their corruption status and normalizes them independently. This restores "local" stationarity and prevents the "garbage" values in the holes from polluting the statistics of the valid pixels.

Figure 2: The concept of Region Normalization. The feature tensor is divided into regions (e.g., green for corrupted, red for uncorrupted) based on the spatial mask, and each is normalized independently.

The authors propose two specific implementations of this concept:

  1. Basic RN (RN-B): Applied in the early layers (encoder) of the network. It uses the original binary inpainting mask to split the feature map into two distinct regions: corrupted and uncorrupted. Each region receives its own mean and variance calculation.
  2. Learnable RN (RN-L): As data passes through convolutional layers, the boundaries of the mask become "blurry" as features blend. RN-L addresses this by automatically detecting potentially corrupted regions using max-pooling and average-pooling across channels to generate a spatial response map. This "soft" mask allows for region-wise statistics even in deeper layers and includes a pixel-wise affine transformation to help fuse the regions back together seamlessly.

Experimental Results and Generalization

The model was evaluated on standard benchmarks including Places2 and CelebA, using both regular square masks and irregular mask datasets to simulate real-world damage.

Quantitative and Qualitative Superiority

On the Places2 dataset, the RN-based model outperformed state-of-the-art methods like EdgeConnect and Gated Convolution. Specifically, it improved PSNR by 0.73 dB and SSIM by 0.017 over a baseline using standard normalization. Visually, the model produces fewer "checkerboard" artifacts and better preserves the textures of uncorrupted regions.

A Plug-and-Play Module

One of the most significant findings is that RN is architecture-agnostic. When the authors integrated RN into other popular frameworks, such as "Contextual Attention" (CA), they observed a massive 2.52 dB PSNR boost. This proves that RN is a general-purpose improvement for the field of image inpainting.

Conclusion

Region Normalization effectively solves the mean and variance shift problem inherent in standard normalization for inpainting tasks. By acknowledging the spatial heterogeneity of corrupted images, RN allows networks to maintain healthy gradient flow and produce cleaner, more realistic results. Future work may explore applying RN to other spatially non-homogeneous tasks like object detection or semantic segmentation.

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