Segment and Recognize Anything at Any Granularity

Feng Li, Hao Zhang, Peize Sun, Xueyan Zou, Shilong Liu, Chunyuan Li, Jianwei Yang, Lei Zhang, Jianfeng GaoECCV 2024

Introduction

Semantic-SAM represents a significant evolution of the "Segment Anything" paradigm. While Meta’s original Segment Anything Model (SAM) revolutionized zero-shot segmentation, it remained class-agnostic and struggled with spatial ambiguity. For instance, a single click on a car's wheel might leave the model uncertain whether to segment a lug nut, the tire, or the entire vehicle. Semantic-SAM addresses these gaps by introducing semantic labels and controllable granularity, enabling a "universal" system that understands the hierarchical nature of images—from fine-grained parts to complete objects.

Methods

The architecture of Semantic-SAM is built upon the MaskDINO framework, enhanced with several novel components to support multi-level semantics.

The Semantic-SAM architecture integrates a shared text encoder and vision encoder with a multi-choice learning scheme and Hungarian matching to handle hierarchical segmentation.
  • Multi-Choice Learning: To resolve the "one click, many possible masks" ambiguity, the model duplicates each point prompt $K$ times (specifically $K=6$). Each duplicate is assigned a unique "level embedding," allowing the decoder to generate a set of masks spanning different granularities.
  • Many-to-Many Matching: Unlike SAM’s many-to-one approach, Semantic-SAM employs a Hungarian matching scheme to align its $K$ predictions with all available ground-truth masks at various levels for a given point.
  • Decoupled Classification: A shared text encoder processes category names, while decoupled heads handle object-level and part-level classification. This allows the model to share general concepts (like "head") while distinguishing between parts and wholes.
  • Unified Prompting: Points and boxes are converted into a unified anchor box format, streamlining the input for the transformer-based decoder.

Datasets

The researchers consolidated seven major datasets into a unified format for joint training, covering three distinct levels of granularity:

  1. Class-agnostic (Multi-granularity): The massive SA-1B dataset (11M images).
  2. Object-level: MSCOCO, Objects365, and ADE20k.
  3. Part-level: Pascal Part, PACO-LVIS, and PartImageNet.

This work marks the first successful joint training of a single model across the massive, unlabeled SA-1B dataset and specialized, labeled part-level datasets.

Key Insights

  • Embracing Ambiguity: Rather than guessing user intent, Semantic-SAM outputs multiple masks for a single click, providing a richer representation of the scene hierarchy.
  • Synergy in Joint Training: Training on SA-1B’s high-quality masks improves performance on labeled tasks like COCO panoptic segmentation, particularly for small objects.
  • Hierarchical "Glue": Part-level data bridges the gap between raw geometry and high-level semantics, teaching the model that objects are structured hierarchies rather than monolithic blocks.

Key Results

Semantic-SAM achieves state-of-the-art performance and demonstrates superior flexibility in interactive tasks.

Qualitative results showing (a) open-set segmentation, (b) multi-level semantics for various objects, and (c) multi-level editing capabilities.
  • State-of-the-Art: The model achieved a new SOTA on COCO panoptic segmentation with 60.2 PQ.
  • Interactive Precision: In 1-click Mean IoU (mIoU) tests on COCO, Semantic-SAM (57.0) outperformed the original SAM (55.7).
  • Granularity Depth: While SAM often outputs redundant levels, Semantic-SAM consistently produces six distinct, meaningful levels of granularity.
  • Visual Quality: The model produces cleaner masks with fewer artifacts (like "holes") compared to SAM, especially in complex regions.

Limitations and Future Work

Performance on COCO began to saturate after using approximately 15% of the SA-1B dataset, suggesting that simple data scaling has diminishing returns. Future work will focus on expanding open-vocabulary capabilities and integrating diverse prompt types such as scribbles or audio. Additionally, the researchers aim to explore how this multi-granularity understanding can benefit downstream tasks like robotic manipulation and advanced image editing.

Summary updated

BibTeX
@inproceedings{li2024segment,
  author = {Feng Li and Hao Zhang and Peize Sun and Xueyan Zou and Shilong Liu and Chunyuan Li and Jianwei Yang and Lei Zhang and Jianfeng Gao},
  title = {{Segment and Recognize Anything at Any Granularity}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73195-2\_27},
}
Figure