Segment and Caption Anything

Xiaoke Huang, Jianfeng Wang, Yansong Tang, Zheng Zhang, Han Hu, Jiwen Lu, Lijuan Wang, Zicheng Liu

Abstract

The Segment Anything Model (SAM) has revolutionized computer vision by providing high-quality zero-shot segmentation. However, SAM lacks semantic understanding, identifying where an object is without knowing what it is. This paper introduces Segment and Caption Anything (SCA), an efficient framework that augments SAM with regional captioning capabilities. By inserting a lightweight, trainable "feature mixer" between a frozen SAM encoder and a frozen Large Language Model (LLM), SCA generates detailed descriptions for any prompted region while training only a tiny fraction of the total parameters.

Introduction

While general image captioning is a well-established field, regional captioning—describing a specific bounding box or mask—presents unique challenges. First, there is a significant model gap: SAM excels at geometric precision but lacks a language interface, while LLMs possess linguistic power but cannot directly process raw pixels. Second, high-quality regional captioning data is scarce; datasets like Visual Genome contain roughly 100k images, a far cry from the 11 million images used to train SAM.

Existing approaches often rely on "crop-and-caption" methods, which lose global context and are computationally expensive. SCA addresses these issues by aligning SAM's visual features with the LLM's embedding space through a specialized architecture.

Methods and Architecture

The SCA architecture is designed for efficiency and modularity, keeping the heavy-duty components frozen to leverage their pretrained knowledge.

Comparison of the original SAM architecture and the proposed SCA framework.

The Hybrid Feature Mixer

The core innovation of SCA is the Hybrid Feature Mixer. This component acts as a bridge, taking visual features from the frozen SAM encoder and user-defined prompts (points, boxes, or masks) and transforming them into tokens that the language model can understand.

Detailed view of the Hybrid Feature Mixer architecture, showing the interaction between visual tokens and text generation.

As shown in the detailed architecture, the mixer uses a bidirectional transformer to align region-specific visual features with the LLM's word-embedding space. This allows the model to inherit the reasoning and linguistic capabilities of the LLM without requiring expensive full-model fine-tuning. Only the mixer (~20M parameters) is trained, making the system highly scalable.

Weak Supervision Pretraining

To overcome data scarcity, the authors employ a Weak Supervision Pretraining strategy. Before fine-tuning on full sentences, the mixer is pretrained on massive object detection datasets like Objects365 and COCO. In this phase, category labels (e.g., "dog") serve as one-word captions, allowing the model to learn a vast visual vocabulary before mastering complex sentence structures.

Key Results and Insights

SCA achieves state-of-the-art performance on the Visual Genome benchmark, reaching a 149.8 CIDEr-D score. This significantly outperforms previous models like GRiT (142.2) and various training-free baselines.

Key findings include:

  • Alignment over Fine-tuning: Training a small "translator" (the mixer) is sufficient to map visual features into the LLM's existing knowledge base.
  • Scaling Benefits: Upgrading the backbone from GPT2-large to LLaMA-3B resulted in clear improvements in semantic accuracy and descriptive quality.
  • Contextual Awareness: Unlike cropping methods, SCA's attention mechanism allows it to consider the relationship between an object and its surroundings, leading to more nuanced captions.

Limitations and Future Work

While SCA represents a major step forward, some limitations remain. The model occasionally struggles with fine-grained attributes, such as misidentifying specific colors or textures. Additionally, there are rare instances of mask-caption misalignment where the description focuses on the background rather than the segmented object. Future research may explore "self-training" techniques and the integration of even larger LLMs to further refine regional understanding.

Summary updated

BibTeX
@inproceedings{huang2023segment,
  author = {Xiaoke Huang and Jianfeng Wang and Yansong Tang and Zheng Zhang and Han Hu and Jiwen Lu and Lijuan Wang and Zicheng Liu},
  title = {{Segment and Caption Anything}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure