Abstract
Scene segmentation relies heavily on contextual information to resolve local ambiguities. However, traditional context aggregation methods often suffer from "context pollution," where features from different semantic categories are mixed indiscriminately. We present the Context Prior Network (CPNet), which explicitly models intra-class and inter-class dependencies. By supervising a learned Context Prior map with a novel Affinity Loss, CPNet distinguishes between helpful and misleading context, achieving state-of-the-art results on ADE20K, PASCAL-Context, and Cityscapes.
Introduction
In semantic segmentation, understanding the relationship between a pixel and its surroundings is crucial for accurate classification. For instance, distinguishing between "sea" and "sky" often requires global scene context. Current approaches typically employ either pyramid-based pooling at multiple scales or attention-based mechanisms to weight pixel relationships.
Despite their success, these methods often aggregate context without considering category boundaries. This leads to "context pollution," where the feature representation of a pixel is corrupted by information from neighboring pixels of different classes. For example, a shadow on a beach might be misclassified as water if a pyramid method aggregates too much "blue-like" context from the nearby ocean. CPNet addresses this by introducing an explicit regularization term to help the network learn which context is beneficial (intra-class) and which is potentially confusing (inter-class).
Methodology
The core of CPNet is the Context Prior Layer, which utilizes three key components to refine feature representations:
1. Affinity Loss
The Affinity Loss is the primary driver for learning the Context Prior. It supervises the network to generate a Prior Map that approximates an "Ideal Affinity Map," where a value of 1 indicates two pixels belong to the same category and 0 indicates they do not. The loss function combines a unary term (binary cross-entropy) with a global term that optimizes for precision, recall, and specificity across the entire map, ensuring the network learns robust spatial relationships.
2. Context Prior Layer
This layer utilizes the learned Prior Map ($P$) to bifurcate context into two distinct branches:
- Intra-class context: Aggregates features from pixels predicted to belong to the same class ($Y = PX$).
- Inter-class context: Aggregates features from pixels predicted to belong to different classes ($\bar{Y} = (1-P)X$). By concatenating these branches with the original features, the model gains a comprehensive, "scene-aware" representation that explicitly accounts for class boundaries.
3. Aggregation Module
To maintain computational efficiency while capturing a large receptive field, the authors employ asymmetric fully separable convolutions. By factorizing a $k \times k$ convolution into $k \times 1$ and $1 \times k$ depth-wise operations, CPNet achieves an effective kernel size of $11 \times 11$, which ablation studies identified as the optimal balance for spatial reasoning.
Key Results
CPNet was evaluated on three major benchmarks: ADE20K (150 categories), PASCAL-Context (59 categories), and Cityscapes (19 urban categories). The model achieved top-tier performance at the time of publication:
- ADE20K: 46.3% mIoU, surpassing PSPNet and PSANet.
- PASCAL-Context: 53.9% mIoU, a significant gain over EncNet.
- Cityscapes: 81.3% mIoU on the test set using fine annotations.
Qualitatively, CPNet excels at resolving "hard examples" where objects share similar textures or colors. As shown in the comparison above, CPNet effectively removes the false positives in the beach shadow (where pyramid methods fail) and accurately delineates boundaries in complex indoor scenes like the bedroom.
Discussion and Insights
The success of CPNet highlights several important principles in scene understanding. First, explicit context modeling acts as a powerful regularizer compared to the implicit relationships learned by standard self-attention. Second, the inclusion of inter-class context proves that knowing what an object is not is just as valuable as knowing what it is for refining boundaries.
Limitations and Future Work
Despite its performance, CPNet's Prior Map has a quadratic complexity ($N \times N$, where $N$ is the number of pixels), which can be memory-intensive for high-resolution images. Additionally, the reliance on an Ideal Affinity Map means performance is sensitive to the quality of ground truth annotations. Future research could explore more memory-efficient prior representations or the application of Context Priors to related tasks like instance segmentation and object detection.
Summary updated