TL;DR
Open-vocabulary segmentation (OVS) allows models to segment arbitrary objects using text prompts, but it heavily lags behind fully supervised models due to the coarse nature of vision-language models (VLMs). This paper introduces Retrieve and Segment (RNS), a few-shot test-time adaptation method that fuses textual prompts with a small, dynamically expandable set of pixel-annotated images. By learning a lightweight, per-image classifier at test time, RNS dramatically narrows the performance gap with supervised models while preserving its open-vocabulary capabilities.
What Problem Does This Paper Address?
While modern open-vocabulary segmentation models excel at identifying diverse objects using natural language prompts, they suffer from two fundamental flaws:
- The Supervision Mismatch: VLMs like CLIP are trained on image-level text pairs, making them inherently weak at the fine-grained, pixel-level localization required for high-quality segmentation.
- Semantic Ambiguity: Text prompts alone can be ambiguous (e.g., confusing a "rider" with a "motorcycle" or hallucinating background elements).
Fully supervised models produce sharp, accurate masks but are restricted to a fixed set of categories and are incredibly expensive to train. The authors bridge this "supervision gap" by asking a simple question: Can we augment text prompts with just a few annotated visual examples at test time to get the best of both worlds?
Methods
The authors propose Retrieve and Segment (RNS), a framework that introduces a few-shot learning paradigm to OVS. Instead of relying purely on text or performing rigid, hand-crafted late fusion of text and vision, RNS uses a learned, per-query fusion strategy.
The pipeline operates in three main phases:
- Support Feature Maintenance: RNS extracts patch-level features from a small "support set" of pixel-annotated images. It pools these into per-image visual class features. Crucially, it blends these visual features with textual class features using multiple mixing coefficients ($\lambda$) to create a robust fused support feature set.
- Test-Time Retrieval: When a new test image arrives, RNS doesn't look at the entire support database. Instead, it performs a $k$-nearest neighbor ($k\text{NN}$) search to retrieve only the visual support features most relevant to the patches or regions in the test image.
- Per-Image Adaptation: RNS trains a lightweight, linear classifier specifically for that single test image. The classifier is optimized using a combination of cross-entropy loss on the retrieved visual features and a pseudo-labeling Kullback-Leibler (KL) divergence loss for classes that lack visual examples (partial support).
RNS can operate directly on image patches or seamlessly integrate with region-proposal models like the Segment Anything Model (SAM) for cleaner boundaries.
Datasets
The method was comprehensively evaluated across six standard OVS benchmarks to test its generalization:
- PASCAL VOC & PASCAL Context (including Context-59)
- COCO Object & COCO-Stuff
- Cityscapes
- ADE20K
To evaluate fine-grained and personalized segmentation performance, the authors also tested on FoodSeg103 and CUB (Caltech-UCSD Birds).
Key Insights and Ideas
- Test-Time Adaptation Beats Offline Training: Training a classifier offline on the entire support set leads to severe overfitting in few-shot scenarios. RNS succeeds because it dynamically restricts its training data to retrieved features relevant to the specific test image.
- Learned Fusion Overcomes the Modality Gap: VLMs feature a notorious "modality gap" between text and image spaces. RNS bypasses this by creating multiple fused prototypes per class, allowing the model to balance textual priors and visual realities dynamically.
- Robust to Missing Data: The framework gracefully handles real-world imperfections. If a class lacks visual examples, it uses zero-shot VLM predictions as pseudo-labels. If it lacks a text label, it uses a neutral semantic prior.
- Personalization for Free: Because the support set is dynamically expandable without retraining the VLM backbone, users can inject a few images of a specific object (e.g., "my favorite skirt") to instantly transition the model into a personalized segmenter.
Key Results
RNS delivers substantial performance gains over zero-shot baselines and existing retrieval-based OVS methods:
- Massive Few-Shot Gains: With just a single support image per class ($B=1$), RNS improves the zero-shot baseline by +7.3% using an OpenCLIP backbone and a staggering +18.4% using a DINOv3 text-aligned backbone.
- Bridging the Supervised Gap: When scaled to 20 support images per class ($B=20$), RNS narrows the performance gap to fully supervised models to just 11.5 points on average. It outperforms the state-of-the-art OVS method, CAT-Seg, by 14.1 points while using a fraction of the pixel-level annotations.
- Fine-Grained Excellence: The performance leap is most pronounced on specialized datasets like CUB and FoodSeg103, proving that visual examples successfully compensate for text prompt limitations in niche domains.
Limitations and Future Work
Despite its strengths, RNS has a few limitations noted by the authors:
- Context and Color Confusion: The model occasionally missegments objects due to an over-reliance on color cues or insufficient contextual awareness (e.g., mistaking part of an orange towel for a swimsuit).
- Computational Overhead: Integrating region-proposal networks like SAM significantly boosts mask quality but increases inference latency, making it less ideal for real-time applications without further optimization.
Summary updated