SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.21795 · NeurIPS · 2025

SANSA: Unleashing the Hidden Semantics in SAM2 for Few-Shot Segmentation

Gabriele Trivigno, Carlo Masone, Claudia Cuttano, Giuseppe Averta

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 2 functions out of this paper's own repositories and ran 2 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
ClaudiaCuttano/SANSA canonical 2 of 2
FunctionStatusWhere it lives
format_prompt Ran ClaudiaCuttano/SANSA/util/demo_sansa.py
code served (permissive licence) · get_code("9f2171cc1758c725")
generate_scribble Ran ClaudiaCuttano/SANSA/util/demo_sansa.py
code served (permissive licence) · get_code("b80dba415864bb6d")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Few-shot segmentation aims to segment unseen categories from just a handful of annotated examples. This requires mechanisms to identify semantically related objects across images and accurately produce masks. We note that Segment Anything 2 (SAM2), with its prompt-and-propagate mechanism, provides strong segmentation capabilities and a built-in feature matching process. However, we show that its representations are entangled with task-specific cues optimized for object tracking, which impairs its use for tasks requiring higher level semantic understanding. Our key insight is that, despite its class-agnostic pretraining, SAM2 already encodes rich semantic structure in its features. We propose SANSA (Semantically AligNed SegmentAnything 2), a framework that makes this latent structure explicit, and repurposes SAM2 for few-shot segmentation through minimal task-specific modifications. SANSA achieves state-of-the-art on few-shot segmentation benchmarks designed to assess generalization and outperforms generalist methods in the popular in-context setting. Additionally, it supports flexible promptable interaction via points, boxes, or scribbles, and remains significantly faster and more compact than prior approaches. Code at: https://github.com/ClaudiaCuttano/SANSA.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2505.21795")
get_code_for_paper("2505.21795")
have("2505.21795")

Connect an agent — have() is free.