arXiv:2611.04084cs.CVNov 2026

Manuscript Offprint

arXiv:2611.04084

From Visual Matching to Textual Conditioning: Cross-Domain Few-Shot Segmentation via Reference Inversion

Jiahao Nie, Yun Xing, Wenbin An, Qixin Zhang, Yap-Peng Tan, Alex C. Kot, Shijian Lu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Cross-Domain Few-Shot Segmentation (CD-FSS) aims to segment objects from unseen domains using only a few annotated references. Recent Segment Anything Model (SAM)-based methods have advanced CD-FSS, yet their reference-target visual matching is highly sensitive to target appearance variations. SAM3 introduces text-conditioned segmentation, enabling natural-language descriptions to guide segmentation across target images, but directly using the category name as the condition still yield unstable performance under severe domain shifts. We propose Reference Inversion for SAM3 (RI-SAM3) that leverages SAM3's large-scale vision-language pre-training to learn suitable textual tokens for each target category. RI-SAM3 comprises three core designs: (i) Bi-level Reference Inversion that learns complementary tokens before and after the frozen text encoder; the former remain anchored in SAM3's text space while the latter represent the category more flexibly; (ii) Layer-adaptive Textual Conditioning combines these tokens differently as object queries evolve across decoder layers; and (iii) Presence-aware Confidence Supervision that jointly supervises query confidence and target presence for reliable predictions. With SAM3 frozen, RI-SAM3 optimizes around 12K parameters only per category and it efficiently segments each target in a single forward pass with reusable textual conditioning without per-sample reference-target visual matching. Extensive experiments over multiple widely adopted benchmarks show that RI-SAM3 achieves superior performance consistently in CD-FSS tasks, together with strong robustness, efficiency, and generalization.

Introduction

Recent advances in semantic segmentation (Cheng et al. 2022; Kirillov et al. 2023; Wang et al. 2024) have achieved remarkable performance, yet most existing methods still rely heavily on large-scale annotated data. Such annotations are costly or impractical to obtain in data-scarce domains, including medical (Codella et al. 2019), satellite (Demir et al. 2018), and underwater imagery (Islam et al. 2020). Cross-Domain Few-Shot Segmentation (CD-FSS) (Lei et al. 2022) alleviates this burden by segmenting target categories from previously unseen domains using only a few annotated reference exemplars of the same categories. Conventional CD-FSS methods (Su et al. 2024; Nie et al. 2026a; Fan et al. 2025; Tong et al. 2024) train a few-shot segmentation model on a large-scale source domain and then adapt it to each target domain. Although effective, this paradigm requires heavy source-domain training and target-domain adaptation, limiting its flexibility and efficiency.

To reduce this dependence, recent CD-FSS methods (Liu et al. 2024b; Zhang et al. 2024a; Xu et al. 2025; Nie et al. 2026b) match reference and target images using the transferable dense features of DINOv2 (Oquab et al. 2023), and convert the resulting correspondences into geometric prompts that guide SAM (Kirillov et al. 2023) to segment the target images. Although reducing training cost, this paradigm exhibits weak generalization across target images of the same category. As illustrated in Fig. 1 (Left), GF-SAM (Zhang et al. 2024a) exhibits substantial variations in prediction quality across target images, even when using the same reference image. This variation suggests that visual matching depends on the appearance similarity between each reference and target image, rather than representing the target category consistently across images. Moreover, the reference image remains necessary during inference, as visual matching must be conducted for every target image. These limitations motivate us to seek a category representation that can be reused across target images.

Natural language offers such a representation by describing categories without relying on visual references (Radford et al. 2021). SAM3 (Carion et al. 2026) further supports text-conditioned segmentation, allowing these language descriptions to guide target segmentation. A straightforward attempt is to use category names as SAM3's textual prompts. However, as shown in Fig. 1 (Left) 1^{1}, this strategy yields low average performance and substantial variations across targets of the same category. These results indicate that category-name prompts still yield poor generalization across targets under severe domain shifts. Nevertheless, SAM3's large-scale vision-language pre-training provides a text space aligned with visual categories, motivating us to seek reusable tokens that represent each target category within this text space.

Textual inversion for personalized visual generation (Gal

∗^{*}These authors contributed equally.

†^{\dagger}Corresponding author.

1^{1}For Chest X-Ray, we use “lung” as the text prompt. For DeepGlobe, we use “forest land” for the forest category. Additional quantitative comparisons among manually specified prompts and qualitative examples are provided in the appendix.

Figure

Figure 1: Motivation for Reference Inversion for SAM3 (RI-SAM3). Left: Using the same reference image, GF-SAM (Zhang et al. 2024a) exhibits substantial IoU variations across different target images, while manually specified text prompts produce low and unstable results under severe domain shifts. Our proposed RI-SAM3 instead inverts annotated references into a reusable textual condition for inference targets. Right: RI-SAM3 achieves higher mIoU (↑) and a lower standard deviation of per-image IoU (↓) than GF-SAM and the category-name prompt baseline, demonstrating improved accuracy and stability.

et al. 2023) offers a way to obtain such a representation by inverting new textual tokens from a few references. Motivated by its success, we propose Reference Inversion for SAM3 (RI-SAM3), which converts annotated references into reusable soft textual tokens. The references are used only during inversion and discarded during inference, replacing per-sample reference-target visual matching with reusable textual conditioning. To make the inversion effective under substantial domain shifts, RI-SAM3 incorporates three designs. First, Bi-level Reference Inversion learns complementary tokens before and after the frozen text encoder: the former remain anchored in SAM3's text space, while the latter represent the target category more flexibly. Second, as object queries evolve through the decoder, Layer-adaptive Textual Conditioning combines these tokens differently across layers. Third, Presence-aware Confidence Supervision jointly supervises query confidence and target presence to improve prediction reliability. With the SAM3 backbone frozen, RI-SAM3 optimizes only approximately 12K parameters per category. The inverted tokens then condition SAM3 to segment each target image in a single forward pass, without references or per-sample visual matching during inference. As shown in Fig. 1 (Right), RI-SAM3 achieves higher mIoU and lower standard deviation across target images than GF-SAM and the category-name baseline, demonstrating improved accuracy and stability. Extensive experiments across widely adopted benchmarks further demonstrate substantial improvements over existing CD-FSS methods, together with strong robustness, efficiency, and generalization.

The contributions of this work can be summarized in three aspects: First, we revisit reference-target visual matching in CD-FSS and identify its limited generalization across targets of the same category, as predictions are sensitive to variations in target appearance. Second, we propose RI-SAM3, a lightweight Reference Inversion framework that converts annotated references into reusable soft textual tokens through

three complementary designs. With SAM3 frozen, RI-SAM3 optimizes only approximately 12K parameters per category and conditions each target prediction in a single forward pass without references or visual matching. Third, extensive experiments show that RI-SAM3 achieves strong performance on CD-FSS benchmarks while exhibiting robustness to different reference images, high computational efficiency, and generalization to related few-shot tasks.

References (60)