Abstract
Self-supervised representation learning (SSL) has achieved remarkable success in image classification by leveraging instance discrimination. However, these methods often fail to capture the fine-grained spatial details necessary for dense downstream tasks such as object detection and semantic segmentation. We introduce Dense Semantic Contrast (DSC), a novel framework designed to bridge this gap. DSC explicitly models semantic boundaries at the pixel level by grouping semantically similar pixels both within and across images. By integrating instance-level, pixel-level, and semantic-level contrastive objectives, DSC learns representations that are more sensitive to object boundaries and category-level consistency. Experimental results on PASCAL VOC, MS COCO, and Cityscapes demonstrate that DSC significantly outperforms existing state-of-the-art SSL methods in dense prediction tasks.
Introduction
The dominant paradigm in self-supervised learning (SSL) relies on instance discrimination, where each image is treated as a unique class. While effective for global feature extraction, this approach has two primary drawbacks for dense tasks. First, it ignores local spatial structures, focusing only on global image embeddings. Second, it suffers from the "push-apart" problem: pixel-level SSL variants often treat every pixel as a distinct entity, inadvertently forcing the model to discriminate between pixels that belong to the same semantic object (e.g., trying to distinguish a dog's ear from its tail).
To address these issues, we propose Dense Semantic Contrast (DSC). Our approach moves beyond simple pixel-to-pixel matching by identifying and grouping pixels with shared semantics. This allows the model to learn that a "dog" pixel in one image should be represented similarly to a "dog" pixel in another, regardless of their specific coordinates or image source.
Methodology
The DSC framework employs a multi-granularity contrastive learning strategy. It builds upon a standard encoder-projector architecture and adds specific heads for dense features to learn at three distinct levels:
- Instance and Pixel Discrimination: The model maintains standard instance-level contrast ($L_{ins}$) and pixel-level contrast ($L_{pix}$) to provide a stable foundation of global and local features.
- Dense Semantic Contrast ($L_{sem}$): This is the core innovation, consisting of two sub-strategies:
- Intra-image Neighbors Discovery: For each pixel, the model identifies its $N$ most similar neighbors within the same image. These neighbors are treated as positive samples, encouraging local semantic smoothness and consistency.
- Inter-image Clustering: To capture semantics across the dataset, we propose two modules. DSC-KM uses online K-means clustering on mini-batch pixels to find category centroids. DSC-PM (Prototype Mapping) utilizes learnable prototypes and a "swapped prediction" mechanism, where the cluster assignment of a pixel in one view is used as a target for its counterpart in another view.
Experiments and Results
We evaluated DSC on several standard computer vision benchmarks, including ImageNet-1K for pre-training and PASCAL VOC, MS COCO, and Cityscapes for downstream tasks.
Quantitative Performance
DSC consistently outperformed state-of-the-art methods like MoCo-v2 and DenseCL across all dense tasks. When pre-trained on MS COCO and evaluated on PASCAL VOC object detection, DSC-PM achieved 57.2% AP, a significant +5.1% improvement over the MoCo-v2 baseline. In semantic segmentation on PASCAL VOC, the improvement was even more pronounced, with DSC-PM reaching 57.9% mIoU, outperforming MoCo-v2 by 9.3%. On the challenging Cityscapes urban driving dataset, DSC-KM improved mIoU by 3.3% over the baseline.
Qualitative Analysis
Grad-CAM heatmaps reveal that DSC produces much sharper and more accurate object activations. Unlike previous methods that often focus on the center of an image or produce blurry regions, DSC accurately highlights object boundaries, reflecting its superior understanding of dense semantics.
Conclusion
Dense Semantic Contrast effectively addresses the limitations of instance-level SSL for dense prediction tasks. By explicitly modeling semantic relationships between pixels, DSC learns representations that are both spatially aware and category-consistent. While the clustering process introduces some computational overhead, the substantial gains in detection and segmentation performance justify its use. Future work will explore hierarchical semantic structures to further refine the model's understanding of object parts and wholes.
Summary updated