No time to train! Training-Free Reference-Based Instance Segmentation

Miguel Espinosa, Chenhongyi Yang, Linus Ericsson, Steven McDonagh, Elliot J. Crowley · DOI

Introduction

Image segmentation—the task of identifying and outlining every object in an image—traditionally requires massive amounts of labeled data and expensive training. While foundation models like the Segment Anything Model (SAM) have revolutionized the field by providing "promptable" segmentation, they are fundamentally semantics-agnostic. SAM can identify where a generic object is, but it lacks the inherent knowledge to identify what it is (e.g., distinguishing a "dog" from a "cat") without external guidance such as a manual click or a bounding box.

Existing "reference-based" methods attempt to automate this by using a few example images to guide the model. However, most of these methods require fine-tuning on new classes, which often leads to overfitting, high computational costs, and poor performance when transitioning between different domains, such as moving from natural photographs to specialized microscopic or underwater imagery. This paper introduces a high-performance, training-free framework that addresses these challenges by combining the geometric precision of SAM with the semantic richness of DINOv2.

Methodology

The authors propose a three-stage, training-free pipeline designed to segment new objects immediately using only a few examples.

The three-stage training-free pipeline: (1) Memory bank construction using DINOv2, (2) Class representation processing via feature aggregation, and (3) Inference using SAM2 for candidate generation and semantic matching.
  1. Memory Bank Construction: The system processes a small set of reference images and their corresponding masks. A frozen DINOv2 encoder is used to extract dense semantic features from these specific regions.
  2. Two-Step Feature Aggregation: To avoid the noise associated with matching individual pixels, the method creates stable "prototypes." It first averages features within each reference mask (instance-level) and then averages those across all examples of a category (class-level). This process establishes a robust "semantic signature" for each object type.
  3. Inference & Semantic-Aware Soft Merging:
    • For a new target image, SAM2 generates a large set of candidate masks.
  4. DINOv2 extracts features for each candidate.
  5. The model calculates the cosine similarity between the candidate's features and the prototypes in the memory bank to assign a class label and a confidence score.
  6. Finally, a novel "soft merging" strategy is applied. Unlike standard techniques that simply delete overlapping boxes, this method adjusts scores based on both spatial overlap (Intersection-over-Self) and semantic similarity, allowing the model to better handle crowded scenes and occlusions.

Experimental Evaluation

The model was evaluated on several rigorous benchmarks to test its generalization and robustness:

  • COCO FSOD & PASCAL VOC Few-Shot: Standard benchmarks for identifying "novel" classes with limited examples.
  • Cross-Domain FSOD (CD-FSOD): A challenging suite of six diverse datasets including ArTaxOr (insects), Clipart1k (cartoons), DIOR (aerial), DeepFish (underwater), NEU-DET (microscopic textures), and UODD (underwater). This suite specifically tests the model's ability to generalize far beyond its original training data.

Key Insights

  • Synergy of Foundation Models: The core innovation lies in the effective integration of existing models. SAM provides the geometric "how to segment," while DINOv2 provides the semantic "what it is."
  • Prototypes over Patches: Matching against an aggregated "prototype" is significantly more effective than matching against raw image patches. Averaging features over a mask filters out background noise and focuses on the core characteristics of the object.
  • Generalization via Freezing: Because the model is never "trained" on specific categories, it avoids the "forgetting" or "domain shift" issues common in fine-tuned models. This allows it to perform remarkably well on specialized data using the same settings as for standard photos.

Results

The proposed method achieves state-of-the-art results on few-shot benchmarks without any costly fine-tuning or domain adaptation.

Qualitative results across diverse datasets in the Cross-Domain FSOD benchmark, demonstrating the model's ability to generalize to microscopic, underwater, aerial, and cartoon domains without training.
  • State-of-the-Art Performance: On the COCO FSOD benchmark, the method achieved 36.8% nAP, outperforming existing methods that utilize fine-tuning.
  • Cross-Domain Mastery: On the CD-FSOD benchmark, it achieved 22.4% nAP, significantly beating other training-free approaches and proving its robustness across wildly different visual domains.
  • Efficiency: The inference process is highly optimized, taking only 0.93 seconds per image on an NVIDIA A100 GPU—roughly 120x faster than some previous matching-based competitors.

Limitations and Future Work

Despite its strengths, the model faces certain challenges:

  • Semantic Confusion: It occasionally struggles to distinguish between very similar categories (e.g., misidentifying "bread" as a "hot dog").
  • Small Objects & Crowded Scenes: Very tiny objects can be missed during candidate generation, and extremely dense environments with complex occlusions may lead to under-detection.
  • Future Directions: Potential improvements include automated selection of optimal reference images and investigating lightweight methods for dynamic memory bank updates.

Summary updated

BibTeX
@misc{espinosa2025no,
  author = {Miguel Espinosa and Chenhongyi Yang and Linus Ericsson and Steven McDonagh and Elliot J. Crowley},
  title = {{No time to train! Training-Free Reference-Based Instance Segmentation}},
  year = {2025},
  eprint = {2507.02798},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.02798},
}
Figure