X2SAM: Any Segmentation in Images and Videos

Hao Wang, Limeng Qiao, Chi Zhang, Lin Ma, Guanglu Wan, Xiangyuan Lan, Xiaodan LiangarXiv 2026

TL;DR

X2SAM is a unified segmentation Multimodal Large Language Model (MLLM) that bridges the gap between conversational text instructions, interactive visual prompts, and pixel-level mask generation across both static images and dynamic videos. By integrating a language-conditioned Mask Memory module, it natively supports 14 distinct segmentation tasks in a single interface while maintaining robust temporal consistency and general chat capabilities.

What Problem Does This Paper Address?

While Multimodal Large Language Models (MLLMs) excel at global visual understanding (like captioning or answering questions about an image), they typically struggle with fine-grained, pixel-level perception. Conversely, foundation segmentation models like the Segment Anything Model (SAM) generate high-quality masks but rely strictly on low-level visual prompts (points, boxes) and cannot comprehend complex, natural language reasoning.

Recent attempts to bridge this gap have resulted in a fragmented landscape. As shown in Figure 2, image-segmentation MLLMs (like LISA) handle text instructions but are restricted to static images and lack visual prompt support. Video-segmentation MLLMs (like VideoLISA) track text-to-mask generation over time but lack a unified architecture for static images and interactive visual prompts. X2SAM addresses this fragmentation by creating a single framework capable of processing interleaved text and visual prompts for any segmentation task across both images and videos.

Figure 2

Methods

X2SAM utilizes a dual-branch visual extraction architecture coupled with a large language model backbone (Qwen3-VL-4B), as illustrated in the architecture overview:

X2SAM Architecture Overview

Key components include:

  • Unified Prompt Formulation: To handle diverse inputs, X2SAM wraps target categories, expressions, or visual region placeholders in special tokens (<p> and </p>). The LLM auto-regressively generates a dedicated <SEG> token, which acts as a semantic bridge guiding the mask decoder.
  • Parameter-Free Region Sampler: This module point-samples high-resolution features from the mask encoder to inject localized visual prompts directly into the LLM.
  • Redesigned Mask Decoder: Inspired by X-SAM, the authors added Query-to-Image and Token-to-Image attention layers. Crucially, the Token-to-Image parameters use zero-initialization, ensuring stable integration of the LLM's semantic embeddings during early training phases.
  • Mask Memory Module: To prevent independent frame-by-frame decoding errors in video, this module acts as a temporal cache. As detailed in Figure 4, it uses a First-In-First-Out (FIFO) memory bank to store and attend to guided vision features from previous frames, ensuring temporal coherence.
  • Unified Joint Training: The model is trained in two stages: category-agnostic segmentor training on dense mask annotations, followed by unified joint training on heterogeneous image and video datasets using a dimension-shifting pipeline to balance varying temporal footprints.
Figure 4

Datasets

X2SAM is trained and evaluated on a massive corpus spanning 14 segmentation tasks:

  • Image Domain: SA-1B (for agnostic segmentor training), COCO, RefCOCO/+/g, ReasonSeg, GLaMM datasets, COCO-VGD, and LLaVA-1.5.
  • Video Domain: VIPSeg, VSPW, YT-VIS19, YT-RefVOS21, DAVIS17-RefVOS, ReVOS, VideoGLaMM, YT-VOS19, and VideoInstruct100K.
  • New Benchmark: The authors introduce the Video Visual Grounded (V-VGD) segmentation benchmark (derived from YT-VIS19 and VIPSeg). This benchmark specifically evaluates a model's ability to track and segment video object tracks starting from interactive visual prompts (points or boxes).

Key Insights and Ideas

  • The Power of Mask Guidance in Memory: The authors found that simply passing raw, single-scale memory features across video frames provides negligible improvements for complex reasoning tasks. True temporal alignment requires mask-level cues and class guidance within the memory module to maintain semantic discrimination over time.
  • Generalists Don't Have to Suffer a "Video Collapse": A common fear in multi-domain modeling is that extending an image model to video will degrade its static performance. X2SAM proves that a unified spatio-temporal formulation can actually boost certain image tasks (e.g., open-vocabulary image segmentation) while mastering video tracking.
  • Modality-Aware Batching Saves Compute: Training on mixed image and video data is notoriously difficult due to memory footprint disparities. By implementing modality-specific gradient accumulation and a temporal-aware sampler, the authors reduced training costs by 36.5% (from 5.2K to 3.3K GPU hours) compared to naive joint training.

Key Results

X2SAM achieves state-of-the-art or highly competitive performance across the board:

  • Video Reasoning & Referring: On the ReVOS benchmark, X2SAM hits 69.9 $\mathcal{J}\&\mathcal{F}$, outperforming HyperSeg by 14.2 points and surpassing video-specialist models like ReferFormer-B.
  • Grounded Conversation: On video grounded conversation generation (V-GCG), it beats VideoGLaMM by +21.5 mIoU (75.8 vs 54.3).
  • Image Open-Vocabulary: It significantly improves image open-vocabulary segmentation (I-OV) from 20.9 to 31.2 PQ compared to its predecessor, X-SAM.
  • Chat Preservation: Unlike many segmentation-focused models that lose their conversational edge, X2SAM retains excellent general understanding, scoring 74.4% on the VideoMME benchmark.

Limitations and Future Work

Despite its strengths, X2SAM has a few limitations noted by the authors:

  1. Memory Constraints in Long Videos: The fixed-size FIFO memory bank (optimized at 6 frames) can struggle with long-term occlusions, massive appearance changes, or objects that disappear and reappear much later in a video.
  2. Computational Cost: Joint training over highly heterogeneous image and video datasets remains resource-intensive.
  3. The Generalist Gap: While X2SAM dominates generalist benchmarks, it still slightly lags behind highly specialized, narrowly focused models optimized for single tasks (like pure Video Object Segmentation).

Future work will focus on exploring more efficient training mechanisms, lightweight backbones, and adaptive long-range memory architectures.

Summary updated

BibTeX
@misc{wang2026x,
  author = {Hao Wang and Limeng Qiao and Chi Zhang and Lin Ma and Guanglu Wan and Xiangyuan Lan and Xiaodan Liang},
  title = {{X2SAM: Any Segmentation in Images and Videos}},
  year = {2026},
  eprint = {2605.00891},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.00891},
}
Figure