VRP-SAM: SAM with Visual Reference Prompt

Yanpeng Sun, Jiahui Chen, Shan Zhang, Xinyu Zhang, Qiang Chen, Gang Zhang, Errui Ding, Jingdong Wang, Zechao Li · DOI

Abstract

In this paper, we propose a novel Visual Reference Prompt (VRP) encoder that empowers the Segment Anything Model (SAM) to utilize annotated reference images as prompts for segmentation, creating the VRP-SAM model. VRP-SAM can utilize annotated reference images to comprehend specific objects and perform segmentation of those objects in target images. Notably, the VRP encoder supports a variety of annotation formats, including point, box, scribble, and mask. VRP-SAM achieves a breakthrough within the SAM framework by extending its versatility and applicability while preserving SAM's inherent strengths. To enhance generalization, the VRP encoder adopts a meta-learning strategy. Extensive empirical studies on the Pascal and COCO datasets demonstrate that VRP-SAM achieves state-of-the-art performance in visual reference segmentation with minimal learnable parameters. Furthermore, VRP-SAM demonstrates strong generalization capabilities, enabling segmentation of unseen objects and cross-domain applications.

Introduction

Meta’s Segment Anything Model (SAM) has significantly advanced the field of image segmentation. However, it suffers from a "usability bottleneck": it is highly dependent on per-image user prompts. To segment a specific object across a large dataset, a user traditionally must provide a prompt for every single image. This process is labor-intensive and requires prior knowledge of the object's location in every frame.

VRP-SAM addresses this by introducing a Visual Reference Prompt (VRP) encoder. Instead of manual prompts for every new image, users provide a single annotated reference image to guide SAM in segmenting similar objects across an entire dataset automatically.

Methodology

The VRP-SAM architecture integrates a lightweight VRP Encoder alongside SAM’s original components. While the heavy Image Encoder remains frozen to preserve SAM's foundational knowledge, the VRP modules (adding only ~1.6M parameters) are trained using a meta-learning strategy.

Comparison of the standard SAM architecture (a) with the proposed VRP-SAM (b), highlighting the addition of the Visual Reference Prompt Encoder.

The VRP Encoder consists of two primary modules:

  1. Feature Augmenter: This module extracts a "prototype" feature vector from the reference image and its annotation. It then enhances the features of both the reference and target images by injecting this prototype information, focusing the model on semantically relevant regions.
  2. Prompt Generator: Utilizing learnable queries and cross-attention, this module "learns" the object's appearance from the reference and "searches" for it in the target image. The resulting visual prompt embeddings are then processed by SAM’s standard Mask Decoder.

Experimental Results

VRP-SAM was evaluated on several benchmarks, including COCO-20i, Pascal-5i, and DAVIS 2017. It achieved state-of-the-art performance, with a mean Intersection over Union (mIoU) of 53.9% on COCO-20i and 71.9% on Pascal-5i, outperforming other adaptation methods like PerSAM and Matcher.

Multi-Format and Cross-Domain Versatility

One of the key strengths of VRP-SAM is its flexibility. It supports various reference formats, including points, boxes, masks, and scribbles. Scribbles are particularly efficient as they are faster for humans to provide than precise masks. Furthermore, the model demonstrates robust cross-domain generalization, successfully segmenting objects in artistic or "ink-style" images even when trained on standard datasets like COCO.

Qualitative results of VRP-SAM across various reference prompt types (point, scribble, box, mask) and diverse image domains, demonstrating its flexibility and generalization.

Key Insights

  • Superiority over Text: VRP-SAM significantly outperforms text-guided versions of SAM (e.g., CLIP-SAM), as visual references provide much richer, object-specific information than category names.
  • Efficiency: The "plug-and-play" nature of the VRP Encoder allows for significant capability enhancement without the need to retrain the massive SAM backbone.
  • Query Initialization: Ablation studies revealed that randomly initializing learnable queries performs better than using foreground prototypes, as it allows for broader feature exploration.

Conclusion and Future Work

VRP-SAM extends the versatility of the Segment Anything Model by enabling it to understand visual concepts from a single reference. While it excels in few-shot semantic segmentation, future work will focus on extending the framework to more complex video tasks, such as long-term object tracking and video instance segmentation, and improving performance in highly cluttered environments.

Summary updated

BibTeX
@inproceedings{sun2024vrp,
  author = {Yanpeng Sun and Jiahui Chen and Shan Zhang and Xinyu Zhang and Qiang Chen and Gang Zhang and Errui Ding and Jingdong Wang and Zechao Li},
  title = {{VRP-SAM: SAM with Visual Reference Prompt}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.02224},
}
Figure