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

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

Abstract

This work presents a novel approach for semi-supervised semantic segmentation. The key element of this approach is our contrastive learning module that enforces the segmentation network to yield similar pixel-level feature representations for same-class samples across the whole dataset. To achieve this, we maintain a memory bank continuously updated with relevant and high-quality feature vectors from labeled data. In an end-to-end training, the features from both labeled and unlabeled data are optimized to be similar to same-class samples from the memory bank. Our approach outperforms the current state-of-the-art for semi-supervised semantic segmentation and semi-supervised domain adaptation on well-known public benchmarks, with larger improvements on the most challenging scenarios, i.e., less available labeled data.

Introduction

Semantic segmentation is a critical task in computer vision, yet its progress is often hindered by the immense cost of generating dense, pixel-perfect labels. Semi-supervised learning (SSL) attempts to mitigate this by training models on a small set of labeled images alongside a much larger pool of unlabeled data.

Traditional SSL techniques typically rely on consistency regularization or entropy minimization. While effective, these methods often process images in isolation, failing to ensure that features for the same class (e.g., "sidewalk") remain consistent across the entire dataset. This lack of global feature structure can lead to poor discrimination between visually similar classes. This paper addresses this gap by introducing a framework that enforces global class-wise consistency through pixel-level contrastive learning.

Methodology

The proposed framework utilizes a Teacher-Student architecture enhanced by a novel Class-wise Memory Bank.

Overview of the proposed semi-supervised framework featuring a class-wise memory bank and contrastive learning module.

Architecture and Memory Bank

The system consists of two networks: a Student ($f_\theta$) that is updated via gradient descent, and a Teacher ($f_\xi$) whose weights are an Exponential Moving Average (EMA) of the student's. The core innovation is the Memory Bank, which stores a fixed set of high-quality feature vectors for every class in the dataset. To maintain the integrity of this bank, a Feature Quality Filter (FQF) ensures that only high-confidence ($>0.95$ probability) and correctly predicted features from the teacher are stored.

Contrastive Learning

The "secret sauce" of this approach is the contrastive loss ($L_{contr}$). The student extracts features from both labeled and unlabeled images, which are then pulled toward same-class "anchors" stored in the memory bank. Unlike standard contrastive learning methods that require complex negative pairs to prevent representation collapse, this method uses a positive-only approach. By using the teacher's stable representations as targets, the model achieves global consistency with high computational efficiency. Additionally, a Class-Specific Attention mechanism allows the model to dynamically weight the most relevant features in the memory bank during optimization.

Experimental Results

The authors evaluated the method on three major benchmarks: Cityscapes (urban driving), PASCAL VOC 2012 (natural images), and GTA5 (synthetic-to-real domain adaptation).

Performance in Data-Scarce Scenarios

The framework demonstrates exceptional performance when labeled data is extremely limited:

  • Cityscapes: With only 1/30 of the labels, the model achieved a Mean Intersection over Union (mIoU) of 59.4, outperforming the previous state-of-the-art (DMT) by 4.6 points.
  • PASCAL VOC: At a 1/50 labeling rate, it reached 68.2 mIoU, setting a new benchmark.
  • Domain Adaptation: In the GTA5 → Cityscapes pipeline (1/30 labels), the method reached 59.9 mIoU, significantly surpassing previous techniques that typically reached 54-55 mIoU.
Qualitative comparison of semantic segmentation results on the Cityscapes dataset, showing the proposed method's superior boundary definition and class consistency.

Conclusion

By moving beyond per-image consistency to a global, class-wise feature alignment strategy, this work sets a new standard for semi-supervised semantic segmentation. The memory bank acts as a stable anchor, particularly effective for aligning synthetic and real-world features in domain adaptation tasks. Importantly, because the memory bank and teacher are only utilized during training, the final model maintains the same inference speed as a standard segmentation network. Future work may explore more sophisticated memory management, such as using clustering to store class centroids, to scale the approach to datasets with hundreds of classes.

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\textbackslash\{\}n Learning from a Class-wise Memory Bank}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00811},
}
Figure