Context-aware Padding for Semantic Segmentation

Yu-Hui Huang, Marc Proesmans, Luc Van GoolarXiv 2021

Introduction

Zero padding is a ubiquitous technique in Convolutional Neural Networks (CNNs) used to maintain spatial dimensions across layers. However, in dense prediction tasks like semantic segmentation, zero padding introduces unnatural discontinuities at image borders. These "zero-filled" regions deviate significantly from the statistical distribution of natural images, forcing shared convolutional filters to adapt to artificial artifacts. This often leads to degraded performance, particularly at the edges of the prediction map.

This paper introduces Context-Aware (CA) padding, a lightweight neural network module designed to extrapolate image borders realistically. By predicting what pixels outside the frame should look like based on local context, CA-padding provides a more natural input for subsequent convolutional layers, leading to improved accuracy and faster model convergence.

Methodology

The authors treat padding as a local image extrapolation task. To ensure the module remains computationally efficient, they avoid generative approaches like GANs. Instead, the CA-padding module utilizes a displacement and warping mechanism.

Displacement and Warping

The core of the module is an encoder-decoder network that predicts a spatial displacement field. Rather than generating new RGB values, a warping layer uses this field to "stretch" existing pixels from the image boundary into the padded area. This ensures that the padded regions maintain the color and texture consistency of the original image.

Architecture of the Context-Aware (CA) padding module, illustrating the displacement field prediction and warping process for different image boundaries.

Directional Modeling

The system employs four independent models for the top, bottom, left, and right borders. This directional approach is crucial because image structures are often orientation-dependent (e.g., sky at the top, road at the bottom). While padding occurs throughout a CNN, the authors found that applying CA-padding only to the first convolutional layer is sufficient, as the realistic statistics generated at the input level propagate effectively through the network.

Experimental Results

The method was evaluated on the Cityscapes (urban street scenes) and DeepGlobe (satellite imagery) datasets.

Performance Gains

CA-padding consistently outperformed standard techniques, including zero, reflection, and replication padding. On Cityscapes, using a PSPNet with a ResNet50 backbone, CA-padding improved the mean Intersection-Over-Union (mIoU) from 76.4% to 77.3%. On the DeepGlobe dataset, the improvement was even more pronounced, with a +2.64% boost in mIoU using a ResNet18 backbone.

Mean IoU comparison across various crop sizes, demonstrating that CA-padding (ours) consistently outperforms zero padding and partial convolutions.

Efficiency and Convergence

Despite the addition of a neural module, the overhead is minimal. On a 4x V100 GPU setup, training time per epoch for Cityscapes only increased by approximately 4.3%. Furthermore, models using CA-padding reached target accuracy levels faster; for instance, a ResNet101 baseline required 148 epochs to reach 76% mIoU, whereas the CA-padding version achieved this in only 117 epochs.

Conclusion

Context-Aware padding addresses a fundamental flaw in standard CNN architectures by replacing artificial zero-borders with realistic extrapolations. By improving the quality of data at the boundaries, the network learns more robust representations across the entire spatial domain. While currently optimized for semantic segmentation, the lightweight nature of CA-padding makes it a promising candidate for other dense prediction tasks such as depth estimation and optical flow.

Summary updated

BibTeX
@misc{huang2021context,
  author = {Yu-Hui Huang and Marc Proesmans and Luc Van Gool},
  title = {{Context-aware Padding for Semantic Segmentation}},
  year = {2021},
  eprint = {2109.07854},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.07854},
}
Figure