Multi-scale and Cross-scale Contrastive Learning for Semantic Segmentation

Theodoros Pissas, Claudio S. Ravasio, Lyndon Da Cruz, Christos BergelesECCV 2022

Abstract

Semantic segmentation traditionally relies on pixel-wise cross-entropy loss, which often fails to capture global context or ensure feature consistency across different scales. This paper proposes a supervised contrastive learning framework that regularizes features across multiple network scales. By enforcing consistency within individual layers (multi-scale) and across different resolutions (cross-scale), the method links local details to global context. Evaluated on Cityscapes, ADE20K, Pascal-Context, and CaDIS, the approach demonstrates significant performance gains across various architectures without requiring memory banks or heavy data augmentation.

Introduction

Assigning a class label to every pixel—semantic segmentation—is a fundamental computer vision task. While cross-entropy loss is the standard objective, it treats pixels independently, neglecting the structural relationships between features of the same class across different images or scales. Recent contrastive learning approaches attempt to address this by clustering similar features, but they often focus only on the final encoder layer and require computationally expensive memory banks. This work introduces a memory-less supervised contrastive approach that leverages the hierarchical nature of deep networks to improve segmentation performance.

Methodology

The proposed framework introduces two primary loss functions and a sampling strategy to improve feature representation:

  1. Multi-scale Contrastive Loss ($L_{cms}$): Applied at various stages of the encoder, this loss encourages the network to learn discriminative features at multiple resolutions, reducing the burden on the decoder to resolve ambiguities.
  2. Cross-scale Contrastive Loss ($L_{ccs}$): This novel component maps features from different scales into a shared space. It enforces that local patches (e.g., a car's wheel) are close to their global representations (the whole car), creating a powerful local-global constraint.
  3. Balanced Anchor Sampling: To maintain efficiency, the model samples a balanced set of anchors from each class in a batch. The sampling rate is dynamically adjusted based on the rarest class, ensuring representation for small or infrequent objects.
Overview of the multi-scale and cross-scale contrastive learning framework.

Experiments and Results

The method was validated across four diverse datasets: Cityscapes, ADE20K, Pascal-Context, and CaDIS (surgical scenes).

  • Performance Gains: On ADE20K, the framework improved OCRNet by 2.3% mIoU and UPerNet (Swin-T) by 1.4%. On Cityscapes, it provided a 1.1% boost for both HRNet and UPerNet.
  • Rare Class Accuracy: In the surgical domain (CaDIS), the model significantly improved the accuracy of rare classes by up to 5.5%, demonstrating robustness in specialized domains where data imbalance is common.
  • Architecture Agnostic: The improvements were consistent across both CNN-based (ResNet, HRNet) and Transformer-based (Swin) architectures, proving the framework's versatility.
  • Qualitative Analysis: t-SNE visualizations confirmed that the proposed loss produces tighter, more distinct class clusters in the feature space compared to standard cross-entropy, leading to cleaner segmentation boundaries.

Conclusion

By treating different network layers as internal "views" of the data, this multi-scale and cross-scale contrastive learning framework provides a powerful regularization signal for semantic segmentation. It achieves state-of-the-art results with minimal computational overhead, as the additional "projector" networks used during training are discarded at inference. Future work may extend this approach to semi-supervised learning scenarios where labeled data is scarce.

Summary updated

BibTeX
@inproceedings{pissas2022multi,
  author = {Theodoros Pissas and Claudio S. Ravasio and Lyndon Da Cruz and Christos Bergeles},
  title = {{Multi-scale and Cross-scale Contrastive Learning for Semantic Segmentation}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19818-2\_24},
}
Figure