Matcher: Segment Anything with One Shot Using All-Purpose Feature Matching

Yang Liu, Muzhi Zhu, Hengtao Li, Hao Chen, Xinlong Wang, Chunhua Shen

TL;DR

Matcher is a training-free perception framework that allows vision models to "segment anything" using just a single reference image (one-shot). By pairing the robust feature-matching capabilities of DINOv2 with the class-agnostic segmentation power of the Segment Anything Model (SAM), Matcher achieves state-of-the-art results in semantic, part, and video segmentation without any task-specific fine-tuning.

What Problem Does This Paper Address?

In the world of Natural Language Processing, Large Language Models (LLMs) like GPT-4 have mastered "in-context learning"—the ability to perform a new task simply by looking at a few examples in a prompt. Computer vision has historically struggled to replicate this flexibility.

While we have powerful Vision Foundation Models (VFMs), they are often specialized. For instance, DINOv2 is great at finding similar pixels across images, and the Segment Anything Model (SAM) is incredible at drawing boundaries around objects. However, SAM doesn't know what it is segmenting (it is class-agnostic), and DINOv2 doesn't naturally produce clean masks. Currently, adapting these models to specific tasks—like "segment only the cat's ears"—usually requires custom architectures and expensive fine-tuning. Matcher aims to bridge this gap, creating a general-purpose "perception paradigm" that works out of the box.

Methods

Matcher Framework Architecture

The Matcher framework operates through a three-step pipeline that integrates off-the-shelf models without changing their weights:

  1. Correspondence Matrix Extraction (CME): Using DINOv2, the system extracts patch-level features from a reference image (which has a known mask) and a target image. It computes a similarity matrix to find which parts of the target image "match" the reference.
  2. Prompts Generation (PG): To clean up the noise inherent in raw feature matching, the authors introduce Bidirectional Matching. It matches points from the reference to the target, then verifies them by matching back from the target to the reference. Only consistent points are kept. These points are then clustered (using k-means++) to generate various "prompts" (points and boxes) for SAM.
  3. Controllable Masks Generation (CMG): SAM produces many candidate masks based on the prompts. Matcher selects the best ones using Instance-Level Matching (ILM). It uses Optimal Transport (specifically Earth Mover’s Distance) to compare the semantic features of the candidate masks against the reference.
  4. The authors introduce two key metrics: Purity (to favor small, specific parts) and Coverage (to favor whole objects), allowing the user to control the granularity of the segmentation.

Datasets

The researchers evaluated Matcher across a wide array of challenging benchmarks:

  • Semantic Segmentation: COCO-20$^i$ and FSS-1000.
  • Object Part Segmentation: PASCAL-Part and PACO-Part.
  • Video Object Segmentation (VOS): DAVIS 2016 and 2017.
  • New Benchmark: The authors introduced LVIS-92$^i$, a more rigorous one-shot semantic segmentation benchmark derived from the LVIS dataset, designed to test generalization across a massive variety of categories.

Key Insights and Ideas

  • The "Synergy" Effect: The core "aha moment" is that DINOv2 and SAM are complementary. DINOv2 provides the "what" (semantic correspondence), while SAM provides the "where" (precise boundaries). Matcher acts as the glue.
  • Bidirectional Verification is Essential: Raw feature matching is noisy. By enforcing that a match must be valid in both directions (Reference $\leftrightarrow$ Target), the system drastically reduces "false positive" prompts that would otherwise confuse SAM.
  • Granularity Control: By adjusting the weights of "Purity" and "Coverage," Matcher can switch between segmenting a whole car or just its tires using the same underlying logic. This mimics the flexibility of human perception.

Key Results

Despite being entirely training-free, Matcher frequently outperforms "specialist" models that were explicitly trained for these tasks:

  • One-Shot Semantic Segmentation: On COCO-20$^i$, Matcher achieved 52.7% mIoU, beating the previous state-of-the-art specialist model by 1.6%.
  • Superior Generalization: On the new LVIS-92$^i$ benchmark, Matcher hit 33.0% mIoU, outperforming the generalist model SegGPT by a massive 14.4%.
  • Part Segmentation: Matcher outperformed the SAM-based PerSAM by roughly 10-13% on PASCAL-Part and PACO-Part, proving that SAM needs semantic guidance to handle fine-grained parts effectively.
  • Video: It achieved competitive results on DAVIS 2017 (79.5 J&F), rivaling models trained specifically on video data.

Limitations and Future Work

The authors note that Matcher's performance is heavily dependent on the quality of the initial image encoder (DINOv2). If the encoder cannot distinguish between two very similar-looking instances, the instance-level matching may struggle.

Additionally, while Matcher is excellent at semantic and part segmentation, its "instance" segmentation (e.g., distinguishing between two identical apples in a pile) is currently limited by the features inherited from the image encoder. The authors suggest that future work could involve integrating more sophisticated instance-level features to improve performance in crowded scenes.

Summary updated

BibTeX
@inproceedings{liu2024matcher,
  author = {Yang Liu and Muzhi Zhu and Hengtao Li and Hao Chen and Xinlong Wang and Chunhua Shen},
  title = {{Matcher: Segment Anything with One Shot Using All-Purpose Feature Matching}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=yzRXdhk2he},
}
Figure