Masked Momentum Contrastive Learning for Zero-shot Semantic Understanding

Jiantao Wu, Shentong Mo, Muhammad Awais, Sara Atito, Zhenhua Feng, Josef KittlerarXiv 2023 · DOI

Abstract

Self-supervised learning has made significant strides in computer vision, yet achieving zero-shot semantic understanding remains a challenge. We present Masked Momentum Contrastive Learning (MMC), a novel pretraining method that enables Vision Transformers (ViTs) to perform zero-shot object segmentation through visual prompting. MMC harmonizes global semantic consistency with local structural awareness by combining Masked Image Modeling (MIM), global contrastive learning, and momentum-based self-distillation. Our approach achieves state-of-the-art performance on zero-shot segmentation benchmarks, including a 38.4% mIoU on COCO, demonstrating superior semantic discrimination compared to existing self-supervised models.

Introduction

In Natural Language Processing (NLP), large-scale models like GPT-4 have demonstrated remarkable "zero-shot" capabilities, performing complex tasks via simple prompting without task-specific fine-tuning. Conversely, Computer Vision (CV) has traditionally relied on expensive fine-tuning or linear probes to adapt pretrained models to downstream tasks. As vision models scale toward trillions of parameters, the computational cost of fine-tuning becomes prohibitive.

The central challenge in self-supervised CV is creating a model that understands objects well enough to recognize and segment them "out of the box." Current methods often face a trade-off: some capture global semantics but fail at pixel-level localization, while others excel at local reconstruction but lack the semantic coherence to distinguish between distinct objects. MMC addresses this by bridging the gap between global and local representations.

Methodology

MMC integrates three distinct learning strategies to produce a robust, semantically-aware visual representation:

  1. Masked Image Modeling (MIM): The model is tasked with reconstructing missing image patches, forcing it to learn internal object structures and local textures.
  2. Global Contrastive Learning: By matching different views of the same image while distancing them from different images, the model anchors high-level semantic meaning in the CLS token.
  3. Momentum-based Self-Distillation: This serves as the critical bridge, transferring high-level semantic knowledge from the global CLS token down to individual local patches, ensuring that local features are semantically consistent with the whole object.
The MMC architecture combines global contrastive learning, momentum distillation, and masked image modeling to align local patches with global semantics.

The Zero-Shot Protocol

To evaluate the model's semantic understanding without fine-tuning, we propose a "prompting patch" evaluation. In this protocol, a user selects a single patch (a visual "click") on a target object. The model then calculates the cosine similarity between the feature vector of that patch and all other patches in the image. By applying a simple threshold to the resulting similarity map, the model generates a zero-shot segmentation mask.

The zero-shot segmentation process: a single patch prompt (star) generates a similarity map that is thresholded to produce an object mask.

Experimental Results

MMC was pretrained on ImageNet-1K and evaluated across several benchmarks for zero-shot and linear performance.

  • Zero-shot Segmentation: On the COCO dataset, MMC achieved a 38.4% mIoU, significantly outperforming DINO (35.1%) and iBOT (36.2%).
  • Video Object Segmentation: On the DAVIS-2017 benchmark, MMC (ViT-B) reached 63.8% J&Fm, demonstrating superior temporal consistency and object tracking compared to standard supervised and self-supervised baselines.
  • Linear Probing: When evaluated via a linear layer for semantic segmentation, MMC outperformed iBOT by 2.3% on ADE20K and 1.9% on Cityscapes, indicating that its features are more linearly separable and task-ready.

Key Insights

The Discrimination Gap

Analysis of standard reconstruction-based models (like MAE) revealed a high "inter-object similarity," where models struggle to distinguish object patches from background patches. MMC mitigates this by "painting" semantic meaning onto local patches through momentum distillation, effectively reducing the discrimination gap.

Layer-wise Specialization

Visualization of the reconstruction process indicates that different layers of the ViT specialize in distinct tasks. For instance, Layer 10 typically handles coarse structure and filling large gaps, while Layers 11 and 12 focus on refining fine details and object boundaries.

Conclusion and Future Work

MMC demonstrates that combining global contrastive objectives with local reconstruction and distillation can unlock zero-shot capabilities in vision models. Currently, the model's resolution is limited by its 16x16 patch size, leading to occasionally "blocky" masks. Future research will explore hierarchical Vision Transformers to achieve finer, pixel-perfect segmentation and expand the prompting interface to include multi-point and bounding box inputs.

Summary updated

Abstract

Self-supervised pretraining (SSP) has emerged as a popular technique in machine learning, enabling the extraction of meaningful feature representations without labelled data. In the realm of computer vision, pretrained vision transformers (ViTs) have played a pivotal role in advancing transfer learning. Nonetheless, the escalating cost of finetuning these large models has posed a challenge due to the explosion of model size. This study endeavours to evaluate the effectiveness of pure self-supervised learning (SSL) techniques in computer vision tasks, obviating the need for finetuning, with the intention of emulating human-like capabilities in generalisation and recognition of unseen objects. To this end, we propose an evaluation protocol for zero-shot segmentation based on a prompting patch. Given a point on the target object as a prompt, the algorithm calculates the similarity map between the selected patch and other patches, upon that, a simple thresholding is applied to segment the target. Another evaluation is intra-object and inter-object similarity to gauge discriminatory ability of SSP ViTs. Insights from zero-shot segmentation from prompting and discriminatory abilities of SSP led to the design of a simple SSP approach, termed MMC. This approaches combines Masked image modelling for encouraging similarity of local features, Momentum based self-distillation for transferring semantics from global to local features, and global Contrast for promoting semantics of global features, to enhance discriminative representations of SSP ViTs. Consequently, our proposed method significantly reduces the overlap of intra-object and inter-object similarities, thereby facilitating effective object segmentation within an image. Our experiments reveal that MMC delivers top-tier results in zero-shot semantic segmentation across various datasets.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Intra-/inter-object similarity distributionsMMCOverlap area (O)0.55-0.01 vs baselineStatistics compare patch pairs from the same category (intra-object) with pairs from di…
Source quote
L296: O │ 0.66 │ 0.56 │ 0.63 │ 0.76 │ 0.58 │ 0.55
Intra-/inter-object similarity distributionsMMCMean intra-object similarity0.48Mean similarity for patch pairs belonging to the same category.
Source quote
L297: Intra │ 0.2 │ 0.19 │ 0.5 │ 0.29 │ 0.47 │ 0.48
Intra-/inter-object similarity distributionsMMCMean inter-object similarity0.38Mean similarity for patch pairs belonging to different categories.
Source quote
L298: Inter │ 0.12 │ 0.05 │ 0.46 │ 0.17 │ 0.35 │ 0.38
Reported baseline / comparator measurements (1)
BenchmarkMethodMetricScoreProtocol / Evidence
Intra-/inter-object similarity distributionsiBOT baselineOverlap area (O)0.56Statistics compare patch pairs from the same category (intra-object) with pairs from di…
Source quote
L296: O │ 0.66 │ 0.56 │ 0.63 │ 0.76 │ 0.58 │ 0.55
BibTeX
@misc{wu2023masked,
  author = {Jiantao Wu and Shentong Mo and Muhammad Awais and Sara Atito and Zhenhua Feng and Josef Kittler},
  title = {{Masked Momentum Contrastive Learning for Zero-shot Semantic Understanding}},
  year = {2023},
  eprint = {2308.11448},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.11448},
}
Figure