NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Supervised Spatially Contrastive Learning

Kodai Nakashima, Hirokatsu Kataoka, Kenji Iwata, Ryota Suzuki, Yutaka SatohJournal of the Japan Society for Precision Engineering 2022

Abstract

Networks pre-trained by supervised contrastive learning have shown high recognition performance in object detection and semantic segmentation. However, existing supervised contrast learning is pre-trained on tasks that capture global features, which may lead to performance bottlenecks due to the gap with downstream tasks where local features are important. Pre-training with unsupervised contrastive learning achieved to improve the accuracy of object detection and semantic segmentation by simply incorporating local features. Therefore, in this paper, we propose a supervised spatially contrastive learning (SSCL). Our proposed method is a modification of an existing supervised contrastive learning to incorporate local features. In our experiments, we compare the proposed method with existing supervised contrastive learning and supervised pre-training using local features in terms of object detection and semantic segmentation accuracy. As a result, in all settings, the network pre-trained by our proposed method outperforms the existing pre-training methods in both downstream tasks.

The Problem: The Global Feature Bottleneck

Most deep learning models are "pre-trained" on massive datasets like ImageNet before being fine-tuned for specific tasks. Standard supervised pre-training—including Supervised Contrastive Learning (SupCon)—focuses on global features, attempting to map an entire image to a single semantic label (e.g., "dog" or "car").

However, many critical downstream tasks, such as semantic segmentation (pixel-level labeling) and object detection (locating objects with bounding boxes), rely heavily on local features and spatial relationships. There is a fundamental gap between global pre-training and local execution. While unsupervised methods have recently started incorporating local spatial information, supervised contrastive learning has historically lagged behind, often treating the entire image as a single point in feature space and discarding spatial richness.

Methodology: Supervised Spatially Contrastive Learning (SSCL)

The authors propose Supervised Spatially Contrastive Learning (SSCL), which shifts the focus from image-level labels to local, spatial features. The architecture is modified in three key ways:

  1. Removing Global Pooling: Traditional models use a global average pooling layer to collapse a 2D feature map into a single vector. SSCL removes this, preserving the spatial grid of features.
  2. CNN Projection Head: Instead of the standard Multi-Layer Perceptron (MLP) used in contrastive learning, SSCL utilizes a Convolutional Neural Network (CNN) as the projection head. This allows the model to process local patches while maintaining their relative spatial positions.
  3. Spatially-Aware Loss Function: The contrastive loss function is adapted to operate on local feature maps. This encourages the network to pull together local features belonging to the same class (even from different images) and push apart features from different classes in the embedding space.
Comparison of standard cross-entropy, global supervised contrastive learning, and the proposed SSCL method.

Essentially, instead of learning that "these two images are both dogs," the model learns that "this patch of fur and that patch of fur are both 'dog,' but this patch of grass is not."

Datasets and Evaluation

To support local feature learning, the authors used COCO-Stuff for pre-training, which provides dense, pixel-level annotations for 172 categories. Downstream performance was evaluated across several benchmarks:

  • Semantic Segmentation: Tested on ADE20K (150 classes), PASCAL VOC, and Cityscapes (urban scenes).
  • Object Detection: Evaluated on COCO 2017 using a Faster R-CNN backbone.

Key Results

SSCL consistently outperformed standard SupCon and traditional Cross-Entropy pre-training across all benchmarks:

  • Semantic Segmentation: On the ADE20K dataset, SSCL achieved a 34.9 mIoU, significantly outperforming standard SupCon (26.5 mIoU). On Cityscapes, SSCL reached 81.2 mIoU, compared to SupCon's 79.3 mIoU.
  • Object Detection: When used as a backbone for Faster R-CNN on COCO 2017, SSCL improved the Mean Average Precision (mAP) to 31.6, a 4.4 point increase over standard SupCon (27.2).
  • Qualitative Superiority: SSCL demonstrates a better understanding of object "parts." While standard SupCon might mistake a boat's deck for a plane due to global context, SSCL correctly identifies components based on their local spatial characteristics.

Conclusion and Future Work

By keeping spatial dimensions intact during pre-training, SSCL retains a richer understanding of object boundaries and textures. While the method requires more expensive pixel-level labels for pre-training and has higher computational overhead due to processing spatial feature maps, the performance gains in dense prediction tasks are substantial. Future research may explore applying SSCL using weaker forms of supervision, such as bounding boxes, to improve scalability.

Summary updated

BibTeX
@article{nakashima2022supervised,
  author = {Kodai Nakashima and Hirokatsu Kataoka and Kenji Iwata and Ryota Suzuki and Yutaka Satoh},
  title = {{Supervised Spatially Contrastive Learning}},
  journal = {Journal of the Japan Society for Precision Engineering},
  year = {2022},
  doi = {10.2493/jjspe.88.66},
}
Figure