Semi-Supervised Semantic Segmentation with Pixel-Level Contrastive Learning from a Class-wise Memory Bank

Iñigo Alonso, Alberto Sabater, David Ferstl, Luis Montesano, Ana C. Murillo

Abstract

Semantic segmentation is a data-intensive task, often requiring extensive manual pixel-level labeling. Semi-supervised learning (SSL) offers a solution by leveraging unlabeled data, yet many current methods fail to maintain global feature consistency across the dataset. This paper presents a novel SSL framework for semantic segmentation that utilizes pixel-level contrastive learning anchored by a class-wise memory bank. By storing and attending to high-quality features from labeled data, the model enforces global consistency and aligns feature distributions. Experimental results on Cityscapes and PASCAL VOC 2012 demonstrate that this approach significantly outperforms existing state-of-the-art methods, particularly when labeled data is extremely limited.

Introduction

Semantic segmentation—the task of assigning a category to every single pixel in an image—is notoriously "data-hungry." Manually labeling every pixel in a dataset like Cityscapes takes thousands of hours. Semi-supervised learning (SSL) aims to solve this by training models on a small set of labeled images and a much larger set of unlabeled ones.

While existing SSL methods use techniques like pseudo-labeling (generating labels for unlabeled pixels) or consistency regularization (ensuring model stability under perturbations), they often ignore the underlying structure of the features. Specifically, they do not explicitly ensure that a "car" pixel in one image shares a similar feature representation with a "car" pixel in another image across the entire dataset. This paper addresses this lack of global feature consistency through a novel contrastive learning approach.

Methodology

The proposed framework utilizes a teacher-student architecture incorporating four primary loss components: supervised loss, pseudo-label loss, entropy minimization, and a novel contrastive loss.

  1. Teacher-Student Scheme: A "Student" network is actively trained, while a "Teacher" network—maintained as an exponential moving average of the student's weights—provides stable targets and pseudo-labels.
  2. Class-wise Memory Bank: This component is central to the method. The teacher network identifies high-quality feature vectors from labeled data, which are then filtered by a Feature Quality Filter (FQF). This filter only retains features for which the model has high confidence. These features are stored in a First-In-First-Out (FIFO) queue for each class.
  3. Pixel-Level Contrastive Learning: During training, the student extracts features from both labeled and unlabeled images. A contrastive loss is applied to "pull" these features toward high-quality examples of the same class stored in the memory bank.
  4. Class-Specific Attention: To optimize the learning process, an attention module weights features in the memory bank based on their relevance, ensuring that contrastive learning focuses on the most informative samples.
Detailed architecture of the proposed pixel-level contrastive learning framework with a class-wise memory bank.

Key Insights and Ideas

  • Global vs. Local Consistency: Unlike methods that focus on local pixel relationships, this approach enforces a global feature "style" for each class across the entire dataset by using the memory bank as a universal reference.
  • Quality-Driven Learning: The Feature Quality Filter (FQF) ensures that the memory bank acts as a "gold standard," preventing noisy or incorrect features from degrading the student's learning process.
  • Positive-Only Contrastive Learning: By focusing on similarity maximization with positive samples rather than contrasting against negative pairs, the method is computationally efficient and avoids the complexities of negative sample selection in dense scenes.
  • Feature Alignment: The contrastive module naturally aligns the feature distributions of labeled and unlabeled data, making it particularly effective for domain adaptation tasks, such as transitioning from synthetic (GTA5) to real-world (Cityscapes) data.

Experimental Results

The researchers evaluated their approach on three major benchmarks: Cityscapes, PASCAL VOC 2012, and GTA5 (for domain adaptation). The method achieved significant performance gains, particularly in low-data regimes:

  • Cityscapes: With only 1/30th of the data labeled, the model achieved 59.4% mIoU, a +5.3% improvement over the previous best method, ClassMix.
  • PASCAL VOC: At a 1/50 labeling rate, it reached 67.9% mIoU, outperforming other state-of-the-art methods by several percentage points.
  • Domain Adaptation: In the GTA5 to Cityscapes task, the approach set a new state-of-the-art, demonstrating the effectiveness of the contrastive module in bridging the gap between synthetic and real-world features.
Qualitative comparison of segmentation results on the Cityscapes dataset, showing the superiority of the proposed method over ClassMix and DMT.

Conclusion

This work demonstrates that pixel-level contrastive learning, supported by a class-wise memory bank, is a powerful tool for semi-supervised semantic segmentation. By enforcing global feature consistency, the model significantly reduces the reliance on large labeled datasets. Future work may involve optimizing memory usage through feature clustering and extending this pixel-level approach to other dense prediction tasks like object detection and instance segmentation.

Summary updated

BibTeX
@inproceedings{alonso2021semi,
  author = {Iñigo Alonso and Alberto Sabater and David Ferstl and Luis Montesano and Ana C. Murillo},
  title = {{Semi-Supervised Semantic Segmentation with Pixel-Level Contrastive Learning from a Class-wise Memory Bank}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00811},
}
Figure