[译]SAM 2: Segment Anything in Images and Videos

SAM 2 将 SAM 的可提示分割扩展到视频:流式记忆 Transformer 逐帧处理视频,记忆注意力关联历史帧预测;配合数据引擎收集的 SA-V 数据集(50.9K 视频、35.5M 掩码),视频分割仅需此前方法三分之一的交互次数,图像分割比 SAM 快 6 倍。
原文地址:SAM 2: Segment Anything in Images and Videos
官方实现:facebookresearch/sam2
摘要
We present Segment Anything Model 2 (SAM 2), a foundation model towards solving promptable visual segmentation in images and videos. We build a data engine, which improves model and data via user interaction, to collect the largest video segmentation dataset to date. Our model is a simple transformer architecture with streaming memory for real-time video processing. SAM 2 trained on our data provides strong performance across a wide range of tasks. In video segmentation, we observe better accuracy, using 3× fewer interactions than prior approaches. In image segmentation, our model is more accurate and 6× faster than the Segment Anything Model (SAM). We believe that our data, model, and insights will serve as a significant milestone for video segmentation and related perception tasks. We are releasing our main model, dataset, as well as code for model training and our demo.
我们提出 Segment Anything Model 2(SAM 2),一个致力于解决图像和视频中可提示视觉分割的基础模型。我们构建了一个数据引擎,通过用户交互同时改进模型和数据,以收集迄今规模最大的视频分割数据集。我们的模型是一个带流式记忆的简单 Transformer 架构,用于实时视频处理。在我们的数据上训练的 SAM 2 在广泛的任务中表现出强劲的性能。在视频分割中,我们观察到更高的精度,交互次数仅为先前方法的 1/3。在图像分割中,我们的模型比 Segment Anything Model(SAM)更准确且快 6 倍。我们相信,我们的数据、模型和见解将成为视频分割及相关感知任务的重要里程碑。我们将发布主要模型、数据集,以及模型训练代码和 demo。
引言
Segment Anything (SA) introduced a foundation model for promptable segmentation in images (Kirillov et al., 2023). However an image is only a static snapshot of the real world in which visual segments can exhibit complex motion, and with the rapid growth of multimedia content, a significant portion is now recorded with a temporal dimension, particularly in video data. Many important applications in AR/VR, robotics, autonomous vehicles, and video editing require temporal localization beyond image-level segmentation. We believe a universal visual segmentation system should be applicable to both images and videos.
Segment Anything(SA)提出了一个用于图像可提示分割的基础模型(Kirillov et al., 2023)。然而,图像只是真实世界的静态快照,其中的视觉片段可能表现出复杂的运动;随着多媒体内容的快速增长,很大一部分内容现在带有时间维度,尤其是视频数据。AR/VR、机器人、自动驾驶和视频编辑中的许多重要应用都需要超越图像级分割的时间定位。我们相信,一个通用的视觉分割系统应当同时适用于图像和视频。
Segmentation in video aims to determine the spatio-temporal extent of entities, which presents unique challenges beyond those in images. Entities can undergo significant changes in appearance due to motion, deformation, occlusion, lighting changes, and other factors. Videos often have lower quality than images due to camera motion, blur, and lower resolution. Further, efficient processing of a large number of frames is a key challenge. While SA successfully addresses segmentation in images, existing video segmentation models and datasets fall short in providing a comparable capability to “segment anything in videos”.
视频中的分割旨在确定实体的时空范围,这带来了图像分割之外的独特挑战。由于运动、形变、遮挡、光照变化等因素,实体的外观可能发生显著变化。由于相机运动、模糊和较低的分辨率,视频的质量往往低于图像。此外,高效处理大量帧是一个关键挑战。虽然 SA 成功解决了图像中的分割问题,但现有的视频分割模型和数据集尚不足以提供「分割视频中的一切」的同等能力。
We introduce the Segment Anything Model 2 (SAM 2), a unified model for video and image segmentation (we consider an image as a single-frame video). Our work includes a task, model, and dataset (see Fig. 1).
我们提出 Segment Anything Model 2(SAM 2),一个统一的视频和图像分割模型(我们将图像视为单帧视频)。我们的工作包括任务、模型和数据集(参见 Fig. 1)。
We focus on the Promptable Visual Segmentation (PVS) task that generalizes image segmentation to the video domain. The task takes as input points, boxes, or masks on any frame of the video to define a segment of interest for which the spatio-temporal mask (i.e., a ‘masklet’) is to be predicted. Once a masklet is predicted, it can be iteratively refined by providing prompts in additional frames.
我们专注于可提示视觉分割(PVS)任务,它将图像分割推广到视频领域。该任务以视频任意帧上的点、框或掩码作为输入,来定义感兴趣的目标片段,并为其预测时空掩码(即 masklet)。一旦预测出 masklet,就可以通过在更多帧上提供提示来迭代地细化它。
Our model (§4) produces segmentation masks of the object of interest, in single images and across video frames. SAM 2 is equipped with a memory that stores information about the object and previous interactions, which allows it to generate masklet predictions throughout the video, and also effectively correct these based on the stored memory context of the object from previously observed frames. Our streaming architecture is a natural generalization of SAM to the video domain, processing video frames one at a time, equipped with a memory attention module to attend to the previous memories of the target object. When applied to images, the memory is empty and the model behaves like SAM.
我们的模型(§4)在单张图像和跨视频帧上生成感兴趣物体的分割掩码。SAM 2 配备了一个记忆,存储物体和先前交互的信息,使其能够在整个视频中生成 masklet 预测,并根据先前观察到的帧中存储的物体记忆上下文有效地修正这些预测。我们的流式架构是 SAM 向视频领域的自然推广,一次处理一帧视频,并配备记忆注意力模块来关注目标物体先前的记忆。当应用于图像时,记忆为空,模型的行为与 SAM 相同。
We employ a data engine (§5) to generate training data by using our model in the loop with annotators to interactively annotate new and challenging data. Different from most existing video segmentation datasets, our data engine is not restricted to objects of specific categories, but instead targeted to provide training data for segmenting any object with a valid boundary, including parts and subparts. Compared to existing model-assisted approaches, our data engine with SAM 2 in the loop is 8.4× faster at comparable quality. Our final Segment Anything Video (SA-V) dataset (§5.2) consists of 35.5M masks across 50.9K videos, 53× more masks than any existing video segmentation dataset. SA-V is challenging with small objects and parts that get occluded and re-appear throughout the video. Our SA-V dataset is geographically diverse, and a fairness evaluation of SAM 2 indicates minimal performance discrepancy in video segmentation based on perceived gender, and little variance among the three perceived age groups we evaluated.
我们采用数据引擎(§5)生成训练数据:将模型置于循环中,与标注员一起交互式地标注新的、有挑战性的数据。与大多数现有的视频分割数据集不同,我们的数据引擎不局限于特定类别的物体,而是旨在为分割任何具有有效边界的物体提供训练数据,包括部件和子部件。与现有的模型辅助方法相比,我们的数据引擎配合在环的 SAM 2 速度快 8.4 倍,且质量相当。我们最终的 Segment Anything Video(SA-V)数据集(§5.2)包含 50.9K 视频上的 35.5M 个掩码,比任何现有视频分割数据集多 53 倍。SA-V 具有挑战性:小物体和部件在整个视频中被遮挡后重新出现。我们的 SA-V 数据集在地理上具有多样性,对 SAM 2 的公平性评估表明,基于感知性别的视频分割性能差异极小,在我们评估的三个感知年龄组之间也几乎没有差异。
Our experiments (§6) show that SAM 2 delivers a step-change in the video segmentation experience. SAM 2 can produce better segmentation accuracy while using 3× fewer interactions than prior approaches. Further, SAM 2 outperforms prior work in established video object segmentation benchmarks, under multiple evaluation settings, and delivers better performance compared to SAM on image segmentation benchmarks, while being 6× faster. SAM 2 is shown to be effective across a variety of video and image distributions as observed through numerous zero-shot benchmarks including 17 for video segmentation and 37 for single-image segmentation.
我们的实验(§6)表明,SAM 2 带来了视频分割体验的阶跃式改变。SAM 2 能产生更好的分割精度,同时交互次数比先前方法少 3 倍。此外,在多种评估设置下,SAM 2 在既有的视频目标分割基准上超越了先前工作,在图像分割基准上的表现也优于 SAM,且速度快 6 倍。通过大量零样本基准(包括 17 个视频分割基准和 37 个单图像分割基准)观察到,SAM 2 在多样的视频和图像分布上均有效。
We are releasing our work under permissive open licences, including the SA-V dataset (CC by 4.0), the SAM 2 model checkpoints¹, training code (Apache 2.0), and code for our interactive online demo (Apache 2.0).
我们在宽松的开源许可证下发布我们的工作,包括 SA-V 数据集(CC by 4.0)、SAM 2 模型检查点¹、训练代码(Apache 2.0),以及我们交互式在线 demo 的代码(Apache 2.0)。
¹All the results presented in this paper are based on a new version of SAM 2 (improved over our initial release; denoted as “SAM 2.1” in https://github.com/facebookresearch/sam2), which we will refer to as SAM 2 throughout for brevity.
¹本文中呈现的所有结果均基于新版 SAM 2(相比我们最初发布的版本有所改进;在 https://github.com/facebookresearch/sam2 中记为「SAM 2.1」),为简洁起见,全文统称为 SAM 2。
相关工作
图像分割
Segment Anything (Kirillov et al., 2023) introduces a promptable image segmentation task where the goal is to output a valid segmentation mask given an input prompt such as a bounding box or a point that refers to the object of interest. SAM trained on the SA-1B dataset allows for zero-shot segmentation which enabled its adoption to a wide range of applications. Recent work has extended SAM, e.g., by introducing a High-Quality output token to train on fine-grained masks (Ke et al., 2024), or improve SAM’s efficiency (Xiong et al., 2023; Zhang et al., 2023a; Zhao et al., 2023). More broadly, SAM is used in a wide range of applications, including medical imaging (Ma et al., 2024; Deng et al., 2023; Mazurowski et al., 2023; Wu et al., 2023a), remote sensing (Chen et al., 2024; Ren et al., 2024), motion segmentation (Xie et al., 2024), and camouflaged object detection (Tang et al., 2023).
Segment Anything(Kirillov et al., 2023)提出了可提示图像分割任务:给定指向感兴趣物体的输入提示(如边界框或点),输出一个有效的分割掩码。在 SA-1B 数据集上训练的 SAM 支持零样本分割,使其被广泛采用于大量应用中。近期工作对 SAM 进行了扩展,例如引入 High-Quality 输出 token 以在细粒度掩码上训练(Ke et al., 2024),或提升 SAM 的效率(Xiong et al., 2023; Zhang et al., 2023a; Zhao et al., 2023)。更广泛地,SAM 被用于大量应用,包括医学影像(Ma et al., 2024; Deng et al., 2023; Mazurowski et al., 2023; Wu et al., 2023a)、遥感(Chen et al., 2024; Ren et al., 2024)、运动分割(Xie et al., 2024)和伪装物体检测(Tang et al., 2023)。
交互式视频目标分割
Interactive video object segmentation has emerged as a crucial task to efficiently obtain object segmentations in videos (masklets) with user guidance, often in the form of scribbles, clicks, or bounding boxes. A few early approaches (Wang et al., 2005; Bai & Sapiro, 2007; Fan et al., 2015) deploy graph-based optimization to guide the segmentation annotation process. More recent approaches (Heo et al., 2020; Cheng et al., 2021b; Delatolas et al., 2024) often adopt a modular design, converting user inputs into a mask representation on a single frame and then propagating it to other frames. Click-based input is easier to collect (Homayounfar et al., 2021) for interactive video segmentation. Recent works have used a combination of SAM on images with video trackers based on masks (Cheng et al., 2023b; Yang et al., 2023; Cheng et al., 2023c) or points (Rajič et al., 2023). However, these approaches have limitations: the tracker may not work for all objects, SAM may not perform well on video frames, and there is no mechanism to interactively refine a model’s mistakes, other than re-annotating using SAM in each frame and restarting the tracking from there.
交互式视频目标分割已成为一项关键任务:在用户引导(通常是涂鸦、点击或边界框)下高效获取视频中的物体分割(masklet)。少数早期方法(Wang et al., 2005; Bai & Sapiro, 2007; Fan et al., 2015)采用基于图的优化来引导分割标注过程。更近期的方法(Heo et al., 2020; Cheng et al., 2021b; Delatolas et al., 2024)通常采用模块化设计:将用户输入转换为单帧上的掩码表示,然后将其传播到其他帧。对于交互式视频分割,基于点击的输入更容易收集(Homayounfar et al., 2021)。近期工作将图像上的 SAM 与基于掩码(Cheng et al., 2023b; Yang et al., 2023; Cheng et al., 2023c)或基于点(Rajič et al., 2023)的视频跟踪器结合使用。然而,这些方法存在局限:跟踪器可能无法适用于所有物体,SAM 在视频帧上可能表现不佳,而且除了在每一帧用 SAM 重新标注并从那重新开始跟踪之外,没有交互式修正模型错误的机制。
Our work shares a similar goal to these works to segment objects across videos interactively, and we build a strong unified model that directly takes prompts for interactive video segmentation, along with a large and diverse dataset in pursuit of solving this goal.
我们的工作与这些工作有着相似的目标——跨视频交互式地分割物体;为此我们构建了一个强大的统一模型,直接接收交互式视频分割的提示,并配合一个大规模且多样化的数据集。
视频目标分割
The VOS task begins with an object mask as input in the first frame, which must be accurately tracked throughout the video (Pont-Tuset et al., 2017). The task is referred to as “semi-supervised VOS” since the input mask can be seen as supervision signal of the object which is available only in the first frame. This task has drawn significant attention due to its relevance in applications, including video editing or robotics.
VOS 任务以第一帧中的物体掩码作为输入,必须在整个视频中准确地跟踪该物体(Pont-Tuset et al., 2017)。该任务被称为「半监督 VOS」,因为输入掩码可以看作物体的监督信号,且仅在第一帧可用。由于其在视频编辑、机器人等应用中的相关性,该任务受到了广泛关注。
Early deep learning based approaches have often used online fine-tuning on the first video frame (Caelles et al., 2016; Perazzi et al., 2016; Yoon et al., 2017; Maninis et al., 2017; Hu et al., 2018a; Bhat et al., 2020; Robinson et al., 2020) or on all frames (Voigtlaender & Leibe, 2017) to adapt the model to the target object. Faster inference has been achieved with offline-trained models, conditioned either only on the first frame (Hu et al., 2018b; Chen et al., 2018), or also integrating the previous frame (Oh et al., 2018; Yang et al., 2018, 2020). This multi-conditioning has been extended to all frames with RNNs (Xu et al., 2018a) and transformers (Oh et al., 2019; Cheng et al., 2021a; Li et al., 2022a; Yang et al., 2021b, 2024; Cheng & Schwing, 2022; Yang & Yang, 2022; Wang et al., 2022; Cheng et al., 2023a; Goyal et al., 2023; Zhang et al., 2023b; Wu et al., 2023b). Semi-supervised VOS can be seen as a special case of our Promptable Visual Segmentation (PVS) task, with only a mask prompt in the first video frame. Notably, annotating the required high-quality object mask in the first frame in VOS is practically challenging and time-consuming for inference.
早期的深度学习方法通常在第一帧(Caelles et al., 2016; Perazzi et al., 2016; Yoon et al., 2017; Maninis et al., 2017; Hu et al., 2018a; Bhat et al., 2020; Robinson et al., 2020)或所有帧(Voigtlaender & Leibe, 2017)上进行在线微调,使模型适配目标物体。离线训练的模型实现了更快的推理,其条件输入可以仅基于第一帧(Hu et al., 2018b; Chen et al., 2018),或同时整合前一帧(Oh et al., 2018; Yang et al., 2018, 2020)。这种多条件机制已通过 RNN(Xu et al., 2018a)和 Transformer(Oh et al., 2019; Cheng et al., 2021a; Li et al., 2022a; Yang et al., 2021b, 2024; Cheng & Schwing, 2022; Yang & Yang, 2022; Wang et al., 2022; Cheng et al., 2023a; Goyal et al., 2023; Zhang et al., 2023b; Wu et al., 2023b)扩展到所有帧。半监督 VOS 可以看作我们可提示视觉分割(PVS)任务的特例:仅在视频第一帧有一个掩码提示。值得注意的是,在 VOS 中标注第一帧所需的高质量物体掩码在推理时实际颇具挑战且耗时。
视频分割数据集
Many datasets have been proposed to support the VOS task. Early VOS datasets (Prest et al., 2012; Li et al., 2013; Ochs et al., 2014; Fan et al., 2015), such as DAVIS (Pont-Tuset et al., 2017; Caelles et al., 2019), include high-quality annotations but their size limits deep-learning based approaches. YouTube-VOS (Xu et al., 2018b) is the first large-scale dataset for VOS. As algorithms became better and benchmark performance started to saturate, researchers have looked at increasing the difficulty of the VOS task by specifically focusing on occlusions (Qi et al., 2022; Ding et al., 2023), long videos (Hong et al., 2023, 2024), extreme transformations (Tokmakov et al., 2022), object diversity (Wang et al., 2021b, 2023) or scene diversity (Athar et al., 2022).
许多数据集被提出来支持 VOS 任务。早期的 VOS 数据集(Prest et al., 2012; Li et al., 2013; Ochs et al., 2014; Fan et al., 2015),如 DAVIS(Pont-Tuset et al., 2017; Caelles et al., 2019),包含高质量标注,但其规模限制了基于深度学习的方法。YouTube-VOS(Xu et al., 2018b)是第一个大规模 VOS 数据集。随着算法不断改进、基准性能开始饱和,研究者们开始通过专门聚焦遮挡(Qi et al., 2022; Ding et al., 2023)、长视频(Hong et al., 2023, 2024)、极端变换(Tokmakov et al., 2022)、物体多样性(Wang et al., 2021b, 2023)或场景多样性(Athar et al., 2022)来提高 VOS 任务的难度。
We find that current video segmentation datasets lack sufficient coverage to achieve the capability of “segmenting anything in videos”. Their annotations typically cover entire objects (not parts) and datasets are often centered around specific object classes, such as people, vehicles, and animals. In comparison to these datasets, our released SA-V dataset not only focuses on whole objects but also extensively covers object parts and contains over an order of magnitude more masks.
我们发现,当前的视频分割数据集缺乏足够的覆盖,无法实现「分割视频中的一切」的能力。它们的标注通常覆盖整个物体(而非部件),数据集往往以特定物体类别为中心,如人、车辆和动物。与这些数据集相比,我们发布的 SA-V 数据集不仅关注整个物体,还广泛覆盖物体部件,且包含多出一个数量级以上的掩码。
任务:可提示视觉分割
Our PVS task allows providing prompts to the model on any frame of a video. Prompts can be positive/negative clicks, boxes, or masks, either to define an object to segment or to refine a model-predicted one. To provide an interactive experience, upon receiving a prompt on a specific frame, the model should immediately respond with a valid segmentation mask of the object on this frame. After receiving initial prompts (either on the same frame or different frames), the model should propagate these prompts to obtain the masklet of the object across the entire video, localizing the segmentation mask of the target on every video frame. Additional prompts can be provided to the model on any frame to refine the segment throughout the video (example in Fig. 2). For details on the task, see §B.
我们的 PVS 任务允许在视频的任意帧上向模型提供提示。提示可以是正/负点击、框或掩码,用来定义要分割的物体,或修正模型预测的结果。为了提供交互式体验,模型在特定帧上收到提示后,应立即在该帧上给出该物体的有效分割掩码。在收到初始提示(可以在同一帧或不同帧上)后,模型应传播这些提示,以获得物体在整个视频中的 masklet,在每一帧上定位目标的分割掩码。可以在任意帧上向模型提供额外的提示,以在整个视频中细化目标片段(示例见 Fig. 2)。任务详情见 §B。

SAM 2 (§4) is applied as a data collection tool to the PVS task for building our SA-V dataset (§5). We evaluate the model (§6) by simulating interactive video segmentation scenarios across multiple frames, in the conventional semi-supervised VOS setting where annotations are limited to the first frame, and for image segmentation on the SA benchmarks.
SAM 2(§4)作为数据收集工具应用于 PVS 任务,以构建我们的 SA-V 数据集(§5)。我们通过以下方式评估模型(§6):模拟跨多帧的交互式视频分割场景、标注仅限于第一帧的常规半监督 VOS 设置,以及在 SA 基准上的图像分割。
模型
SAM 2 (Fig. 3) can be seen as a generalization of SAM to the video (and image) domain, taking point, box, and mask prompts on individual frames to define the spatial extent of the object to be segmented spatio-temporally. Spatially, the model behaves similarly to SAM. A promptable and light-weight mask decoder takes an image embedding and prompts (if any) and outputs a segmentation mask for the frame. Prompts can be iteratively added on a frame in order to refine the masks.
SAM 2(Fig. 3)可以看作 SAM 向视频(和图像)领域的推广:在单个帧上接收点、框和掩码提示,以定义待分割物体在时空上的空间范围。在空间上,模型的行为与 SAM 类似。一个可提示的轻量掩码解码器接收图像嵌入和提示(如果有),输出该帧的分割掩码。可以在帧上迭代地添加提示以细化掩码。
The frame embedding used by the SAM 2 decoder is not directly from an image encoder and is instead conditioned on memories of past predictions and prompted frames. It is possible for prompted frames to also come “from the future” relative to the current frame. Memories of frames are created by the memory encoder based on the current prediction and placed in a memory bank for use in subsequent frames. The memory attention operation takes the per-frame embedding from the image encoder and conditions it on the memory bank, before the mask decoder ingests it to form a prediction.
SAM 2 解码器使用的帧嵌入并非直接来自图像编码器,而是以过去的预测和被提示帧的记忆为条件。被提示的帧也可能相对于当前帧「来自未来」。帧的记忆由记忆编码器基于当前预测创建,并放入记忆库中供后续帧使用。记忆注意力操作从图像编码器接收逐帧嵌入,并以记忆库为条件对其进行调制,然后掩码解码器将其消化以形成预测。
We describe individual components and training below and provide more details in Appendix D.
下面我们描述各个组件和训练过程,更多细节见 Appendix D。
图像编码器
For real-time processing of arbitrarily long videos, we take a streaming approach, consuming video frames as they become available. The image encoder is only run once for the entire interaction and its role is to provide unconditioned tokens (feature embeddings) representing each frame. We use an MAE (He et al., 2022) pre-trained Hiera (Ryali et al., 2023; Bolya et al., 2023) image encoder, which is hierarchical, allowing us to use multiscale features during decoding.
为了实时处理任意长度的视频,我们采用流式方法,在视频帧可用时即消费它们。图像编码器在整个交互过程中只运行一次,其作用是提供表示每一帧的无条件 token(特征嵌入)。我们使用 MAE(He et al., 2022)预训练的 Hiera(Ryali et al., 2023; Bolya et al., 2023)图像编码器,它是层次化的,使我们能够在解码期间使用多尺度特征。

记忆注意力
The role of memory attention is to condition the current frame features on the past frames features and predictions as well as on any new prompts. We stack L transformer blocks, the first one taking the image encoding from the current frame as input. Each block performs self-attention, followed by cross-attention to memories of (prompted/unprompted) frames and object pointers (see below), stored in a memory bank (see below), followed by an MLP. We use vanilla attention operations for self- and cross-attention, allowing us to benefit from recent developments in efficient attention kernels (Dao, 2023).
记忆注意力的作用是使当前帧特征以过去帧的特征和预测以及任何新提示为条件。我们堆叠 L 个 Transformer 块,第一个块以当前帧的图像编码作为输入。每个块执行自注意力,然后对记忆库(见下文)中存储的(被提示/未被提示)帧记忆和物体指针(见下文)执行交叉注意力,最后是一个 MLP。我们在自注意力和交叉注意力中使用 vanilla attention 操作,从而受益于高效注意力内核的近期进展(Dao, 2023)。
提示编码器和掩码解码器
Our prompt encoder is identical to SAM’s and can be prompted by clicks (positive or negative), boxes, or masks to define the extent of the object in a given frame. Sparse prompts are represented by positional encodings summed with learned embeddings for each prompt type, while masks are embedded using convolutions and summed with the frame embedding.
我们的提示编码器与 SAM 相同,可以通过点击(正或负)、框或掩码来提示,以定义给定帧中物体的范围。稀疏提示由位置编码与每种提示类型的学习嵌入相加表示,而掩码则通过卷积进行嵌入,并与帧嵌入相加。
Our decoder design largely follows SAM. We stack “two-way” transformer blocks that update prompt and frame embeddings. As in SAM, for ambiguous prompts (i.e., a single click) where there may be multiple compatible target masks, we predict multiple masks. This design is important to ensure that the model outputs valid masks. In video, where ambiguity can extend across video frames, the model predicts multiple masks on each frame. If no follow-up prompts resolve the ambiguity, the model only propagates the mask with the highest predicted IoU for the current frame.
我们的解码器设计大体沿用 SAM。我们堆叠「双向」Transformer 块来更新提示和帧嵌入。与 SAM 一样,对于可能存在多个兼容目标掩码的模糊提示(即单次点击),我们预测多个掩码。这一设计对于确保模型输出有效掩码非常重要。在视频中,模糊性可能跨视频帧延伸,因此模型在每一帧上预测多个掩码。如果没有后续提示消除模糊性,模型只传播当前帧预测 IoU 最高的掩码。
Unlike SAM where there is always a valid object to segment given a positive prompt, in the PVS task it is possible for no valid object to exist on some frames (e.g. due to occlusion). To support this new output mode, we add an additional head that predicts whether the object of interest is present on the current frame. Another novelty are skip connections from our hierarchical image encoder (bypassing the memory attention) to incorporate high-resolution embeddings for mask decoding (see §D).
与 SAM 在给定正提示时总是存在有效可分割物体不同,在 PVS 任务中,某些帧上可能不存在有效物体(例如由于遮挡)。为了支持这种新的输出模式,我们添加了一个额外的头,预测感兴趣物体是否出现在当前帧上。另一个新颖之处是来自层次化图像编码器的跳跃连接(绕过记忆注意力),用于引入高分辨率嵌入以进行掩码解码(见 §D)。
记忆编码器
The memory encoder generates a memory by downsampling the output mask using a convolutional module and summing it element-wise with the unconditioned frame embedding from the image-encoder (not shown in Fig. 3), followed by light-weight convolutional layers to fuse the information.
记忆编码器通过卷积模块对输出掩码进行下采样,并与来自图像编码器的无条件帧嵌入逐元素相加(Fig. 3 中未显示),随后通过轻量卷积层融合信息,从而生成记忆。
记忆库
The memory bank retains information about past predictions for the target object in the video by maintaining a FIFO queue of memories of up to N recent frames and stores information from prompts in a FIFO queue of up to M prompted frames. For instance, in the VOS task where the initial mask is the only prompt, the memory bank consistently retains the first frame’s memory along with memories of up to N recent (unprompted) frames. Both sets of memories are stored as spatial feature maps.
记忆库通过维护最多 N 个最近帧记忆的 FIFO 队列来保留视频中目标物体过去预测的信息,并在最多 M 个被提示帧的 FIFO 队列中存储来自提示的信息。例如,在初始掩码是唯一提示的 VOS 任务中,记忆库持续保留第一帧的记忆以及最多 N 个最近(未被提示)帧的记忆。两组记忆都存储为空间特征图。
In addition to the spatial memory, we store a list of object pointers as lightweight vectors for high-level semantic information of the object to segment, based on mask decoder output tokens of each frame. Our memory attention cross-attends to both spatial memory features and these object pointers.
除了空间记忆之外,我们还基于每帧掩码解码器的输出 token,将一组物体指针存储为轻量向量,用于提供待分割物体的高层语义信息。我们的记忆注意力同时对空间记忆特征和这些物体指针执行交叉注意力。
We embed temporal position information into the memories of N recent frames, allowing the model to represent short-term object motion, but not into those of prompted frames, because the training signal from prompted frames is sparser and it is more difficult to generalize to the inference setting where prompted frames may come from a very different temporal range than seen during training.
我们将时间位置信息嵌入 N 个最近帧的记忆中,使模型能够表示物体的短期运动;但不嵌入被提示帧的记忆,因为被提示帧的训练信号更稀疏,且更难泛化到推理设置——推理时被提示帧可能来自与训练期间所见截然不同的时间范围。
训练
The model is trained jointly on image and video data. Similar to previous work (Kirillov et al., 2023; Sofiiuk et al., 2022), we simulate interactive prompting of the model. We sample sequences of 8 frames and randomly select up to 2 frames to prompt and probabilistically receive corrective clicks which are sampled using the ground-truth masklet and model predictions during training. The training task is to sequentially (and “interactively”) predict the ground-truth masklet. Initial prompts to the model can be the ground-truth mask with probability 0.5, a positive click sampled from the ground-truth mask with probability 0.25, or a bounding box input with probability 0.25. See §D for more details.
模型在图像和视频数据上联合训练。与先前工作类似(Kirillov et al., 2023; Sofiiuk et al., 2022),我们模拟模型的交互式提示。我们采样 8 帧序列,随机选择最多 2 帧进行提示,并以一定概率接收修正点击,这些点击在训练期间使用真值 masklet 和模型预测采样。训练任务是按顺序(并「交互式地」)预测真值 masklet。给模型的初始提示可以是:真值掩码(概率 0.5)、从真值掩码中采样的正点击(概率 0.25),或边界框输入(概率 0.25)。更多细节见 §D。
数据
To develop the capability to “segment anything” in video, we built a data engine to collect a large and diverse video segmentation dataset. We employ an interactive model in the loop setup with human annotators. Similar to Kirillov et al. (2023), we do not impose semantic constraints on the annotated masklets, and focus on both whole objects (e.g., a person) and parts (e.g., a person’s hat). Our data engine went through three phases, each categorized based on the level of model assistance provided to annotators. Next, we describe each data engine phase and our SA-V dataset.
为了开发「分割视频中的一切」的能力,我们构建了一个数据引擎来收集大规模、多样化的视频分割数据集。我们采用模型在环的交互式设置,配合人工标注员。与 Kirillov et al. (2023) 类似,我们对标注的 masklet 不施加语义约束,同时关注整个物体(如一个人)和部件(如一个人的帽子)。我们的数据引擎经历了三个阶段,每个阶段根据提供给标注员的模型辅助程度划分。接下来,我们描述每个数据引擎阶段和我们的 SA-V 数据集。
数据引擎
Phase 1: SAM per frame. The initial phase used the image-based interactive SAM (Kirillov et al., 2023) to assist human annotation. Annotators are tasked with annotating the mask of a target object in every frame of the video at 6 frames per second (FPS) using SAM, and pixel-precise manual editing tools such as a “brush” and “eraser”. There is no tracking model involved to assist with the temporal propagation of masks to other frames. As this is a per-frame method, and all frames require mask annotation from scratch, the process is slow, with an average annotation time of 37.8 seconds per frame in our experiment. However, this yields high-quality spatial annotations per frame. In this phase, we collected 16K masklets across 1.4K videos. We further use this approach to annotate our SA-V val and test sets to mitigate potential biases of SAM 2 during evaluation.
阶段 1:逐帧 SAM。初始阶段使用基于图像的交互式 SAM(Kirillov et al., 2023)辅助人工标注。标注员的任务是使用 SAM 和像素级精确的手动编辑工具(如「画笔」和「橡皮擦」),以每秒 6 帧(FPS)的速度标注视频每一帧中目标物体的掩码。此阶段没有跟踪模型协助将掩码在时间上传播到其他帧。由于这是逐帧方法,且所有帧都需要从头标注掩码,过程缓慢,我们的实验中平均每帧标注时间为 37.8 秒。不过,这产生了每帧高质量的空间标注。在这一阶段,我们在 1.4K 视频上收集了 16K 个 masklet。我们进一步使用这种方法标注 SA-V val 和 test 集,以减轻评估期间 SAM 2 的潜在偏差。
Phase 2: SAM + SAM 2 Mask. The second phase added SAM 2 into the loop, where SAM 2 only accepted masks as prompts. We refer to this version as SAM 2 Mask. Annotators used SAM and other tools as in Phase 1 to generate spatial masks in the first frame, and then use SAM 2 Mask to temporally propagate the annotated mask to other frames to get the full spatio-temporal masklets. At any subsequent video frame, annotators can spatially modify the predictions made by SAM 2 Mask by annotating a mask from scratch with SAM, a “brush” and/or “eraser”, and re-propagate with SAM 2 Mask, repeating this process until the masklet is correct. SAM 2 Mask was initially trained on the Phase 1 data and publicly available datasets. During Phase 2, we re-trained and updated SAM 2 Mask in the annotation loop twice using the collected data. In Phase 2, we collected 63.5K masklets. The annotation time went down to 7.4 s/frame, a ∼5.1× speed up over Phase 1. Despite an improvement in annotation time, this approach requires annotating masks in intermediate frames from scratch without previous memory. We then advanced to develop the fully-featured SAM 2, capable of both interactive segmentation and mask propagation in a unified model.
阶段 2:SAM + SAM 2 掩码。第二阶段将 SAM 2 加入循环,此时 SAM 2 只接受掩码作为提示。我们将这个版本称为 SAM 2 Mask。标注员使用 SAM 和其他工具(同阶段 1)在第一帧生成空间掩码,然后使用 SAM 2 Mask 将标注的掩码在时间上传播到其他帧,以获得完整的时空 masklet。在任意后续视频帧上,标注员可以通过用 SAM、「画笔」和/或「橡皮擦」从头标注掩码来在空间上修改 SAM 2 Mask 的预测,并用 SAM 2 Mask 重新传播,重复这一过程直到 masklet 正确为止。SAM 2 Mask 最初在阶段 1 的数据和公开数据集上训练。在阶段 2 期间,我们在标注循环中使用收集到的数据对 SAM 2 Mask 重新训练并更新了两次。在阶段 2 中,我们收集了 63.5K 个 masklet。标注时间降至每帧 7.4 秒,比阶段 1 加速约 5.1 倍。尽管标注时间有所改善,但这种方法要求在没有先前记忆的情况下从头标注中间帧的掩码。随后我们进一步开发了功能完备的 SAM 2,能够在统一模型中同时进行交互式分割和掩码传播。
Phase 3: SAM 2. In the final phase, we utilize the fully-featured SAM 2, which accepts various types of prompts, including points and masks. SAM 2 benefits from memories of objects across the temporal dimension to generate mask predictions. This means annotators only need to provide occasional refinement clicks to SAM 2 to edit the predicted masklets in intermediate frames, as opposed to annotating from scratch with a spatial SAM which has no such memory context. During Phase 3, we re-trained and updated SAM 2 using the collected annotations five times. With SAM 2 in the loop, the annotation time per frame went down to 4.5 seconds, a ∼8.4× speed up over Phase 1. In Phase 3, we collected 197.0K masklets.
阶段 3:SAM 2。在最后阶段,我们使用功能完备的 SAM 2,它接受包括点和掩码在内的多种类型的提示。SAM 2 利用物体跨时间维度的记忆来生成掩码预测。这意味着标注员只需偶尔向 SAM 2 提供修正点击,即可编辑中间帧的预测 masklet,而无需像没有此类记忆上下文的空间 SAM 那样从头标注。在阶段 3 期间,我们使用收集到的标注对 SAM 2 重新训练并更新了五次。配合在环的 SAM 2,每帧标注时间降至 4.5 秒,比阶段 1 加速约 8.4 倍。在阶段 3 中,我们收集了 197.0K 个 masklet。
Quality verification. To uphold a high standard for annotation, we introduce a verification step. A separate set of annotators are tasked with verifying the quality of each annotated masklet as “satisfactory” (correctly and consistently tracking the target object across all frames) or “unsatisfactory” (target object is well defined with a clear boundary but the masklet is not correct or consistent). Unsatisfactory masklets were sent back to the annotation pipeline for refinement. Any masklets tracking not well defined objects were rejected entirely.
质量验证。为了保持高标注标准,我们引入了一个验证步骤。一组独立的标注员负责将每个已标注 masklet 的质量验证为「合格」(在所有帧上正确且一致地跟踪目标物体)或「不合格」(目标物体定义良好、边界清晰,但 masklet 不正确或不一致)。不合格的 masklet 被退回标注流程进行细化。任何跟踪定义不清物体的 masklet 都被完全拒绝。

Auto masklet generation. Ensuring diversity in annotation is important to enable the anything capability of our model. As human annotators might typically focus more on salient objects, we augment the annotations with automatically generated masklets (referred to as “Auto”). This serves a dual purpose of increasing the coverage of annotations and helping identify model failure cases. To generate auto masklets, we prompt SAM 2 with a regular grid of points in the first frame and generate candidate masklets. These are then sent to the masklet verification step for filtering. Automatic masklets tagged as “satisfactory” are added to the SA-V dataset. Masklets identified as “unsatisfactory” (i.e., model failure cases) are sampled and presented to annotators to refine with SAM 2 in the loop (Phase 3 of the data engine). These automatic masklets cover large salient central objects but also objects of varying sizes and positions in the background.
自动 masklet 生成。确保标注的多样性对于实现模型的「一切」能力非常重要。由于人工标注员通常更关注显著物体,我们用自动生成的 masklet(称为「Auto」)扩充标注。这起到双重作用:增加标注的覆盖范围,并帮助识别模型的失败案例。为了生成自动 masklet,我们在第一帧用规则网格的点提示 SAM 2,生成候选 masklet。这些候选随后被送到 masklet 验证步骤进行过滤。标记为「合格」的自动 masklet 被加入 SA-V 数据集。被识别为「不合格」的 masklet(即模型失败案例)被采样并交给标注员,配合在环的 SAM 2(数据引擎阶段 3)进行细化。这些自动 masklet 覆盖大型显著的中心物体,也覆盖背景中各种大小和位置的物体。
Analysis. Table 1 shows a comparison of the annotation protocol in each data engine phase through a controlled experiment (details in §E.2.2). We compare the average annotation time per frame, the average percentage of manually edited frames per masklet, and the average number of clicks per clicked frame. For quality evaluation, we define the Phase 1 Mask Alignment Score as the percentage of masks whose IoU compared to the corresponding masks in Phase 1 exceeds 0.75. Phase 1 data is chosen as a reference as it has per-frame high quality manual annotations. Phase 3 with SAM 2 in the loop leads to increased efficiency and comparable quality: it is 8.4× faster than Phase 1, has the lowest edited frame percentage and clicks per frame, and results in better alignment.
分析。Table 1 通过受控实验(细节见 §E.2.2)比较了每个数据引擎阶段的标注协议。我们比较每帧平均标注时间、每个 masklet 中手动编辑帧的平均百分比,以及每次点击帧的平均点击次数。对于质量评估,我们将阶段 1 掩码对齐分数定义为:与阶段 1 中相应掩码相比 IoU 超过 0.75 的掩码百分比。选择阶段 1 数据作为参考,因为它具有逐帧高质量的人工标注。配合在环 SAM 2 的阶段 3 带来了更高的效率和相当的质量:比阶段 1 快 8.4 倍,编辑帧百分比和每帧点击次数最低,并且对齐效果更好。

In Table 2, we show the performance comparison of SAM 2 trained on the available data at the end of each phase keeping the number of iterations fixed, therefore measuring solely the impact of the additional data. We evaluate on our own SA-V val set and also on 9 zero-shot benchmarks (see §F.1 for details) using the standard J &F accuracy metric (the higher the better) when prompting with 3-clicks on the first frame. We note a consistent improvement after iteratively including the data from each phase, not only on the in-domain SA-V val set, but also on the 9 zero-shot benchmarks.
在 Table 2 中,我们展示了在每个阶段结束时用可用数据训练 SAM 2(保持迭代次数固定)的性能比较,因此仅衡量新增数据的影响。我们在自己的 SA-V val 集以及 9 个零样本基准(细节见 §F.1)上评估,使用标准的 J &F 精度指标(越高越好),并在第一帧上用 3 次点击进行提示。我们注意到,在迭代地加入每个阶段的数据后,性能持续提升——不仅在域内的 SA-V val 集上,在 9 个零样本基准上也是如此。
SA-V 数据集
The SA-V dataset collected with our data engine comprises 50.9K videos with 642.6K masklets. In Table 3 we compare the SA-V composition to common VOS datasets across the number of videos, masklets, and masks. Notably, the number of annotated masks is 53× (15× without auto) larger than any existing VOS dataset, providing a substantial resource for future work. We are releasing SA-V under a permissive license.
我们用数据引擎收集的 SA-V 数据集包含 50.9K 视频和 642.6K 个 masklet。在 Table 3 中,我们按视频、masklet 和掩码的数量将 SA-V 的构成与常见 VOS 数据集进行比较。值得注意的是,标注掩码的数量比任何现有 VOS 数据集多 53 倍(不含 auto 为 15 倍),为未来工作提供了大量资源。我们在宽松的许可证下发布 SA-V。
Videos. We collected a new set of 50.9K videos captured by crowdworkers. Videos comprise 54% indoor and 46% outdoor scenes with an average duration of 14 seconds. Videos feature “in-the-wild” diverse environments, and cover various everyday scenarios.
视频。我们收集了由众包工人拍摄的一组新视频,共 50.9K 个。视频包含 54% 的室内场景和 46% 的室外场景,平均时长 14 秒。视频具有「in-the-wild」的多样环境,覆盖各种日常场景。
Masklets. The annotations comprise 190.9K manual masklet annotations and 451.7K automatic masklets collected using our data engine. Example videos with masklets overlaid (manual and automatic) are shown in Fig. 4. SA-V has 53× (15× without auto annotations) more masks than the largest VOS dataset. The disappearance rate (Ding et al., 2023) in SA-V Manual (the percentage of annotated masklets that disappear in at least one frame and then re-appear) is 42.5%, competitive among existing datasets.
Masklet。标注包括 190.9K 个人工标注的 masklet 和 451.7K 个用我们的数据引擎收集的自动 masklet。叠加了 masklet(人工和自动)的示例视频见 Fig. 4。SA-V 的掩码数量比最大的 VOS 数据集多 53 倍(不含自动标注为 15 倍)。SA-V Manual 中的消失率(Ding et al., 2023)(至少在一帧中消失然后重新出现的已标注 masklet 的百分比)为 42.5%,在现有数据集中处于较高水平。


SA-V training, validation and test splits. We split SA-V based on the video authors (and their geographic locations) to ensure minimal overlap of similar objects. To create SA-V val and SA-V test sets, we focus on challenging scenarios in selecting videos, and ask annotators to identify challenging targets that are fast-moving, have complex occlusions by other objects as well as disappearance/re-appearance patterns. These targets were annotated at 6 FPS using the data engine Phase 1 setup in §5.1. There are 293 masklets and 155 videos in the SA-V val split, and 278 masklets and 150 videos in the SA-V test split.
SA-V 训练、验证和测试划分。我们基于视频作者(及其地理位置)划分 SA-V,以确保相似物体的重叠最小。为了创建 SA-V val 和 SA-V test 集,我们在选择视频时聚焦具有挑战性的场景,并要求标注员识别具有挑战性的目标:快速移动、被其他物体复杂遮挡,以及消失/重现模式。这些目标使用 §5.1 中数据引擎阶段 1 的设置以 6 FPS 标注。SA-V val 划分包含 293 个 masklet 和 155 个视频,SA-V test 划分包含 278 个 masklet 和 150 个视频。
Internal dataset. We also used internally available licensed video data to further augment our training set. Our internal dataset is comprised of 62.9K videos and 69.6K masklets annotated in Phase 2 and Phase 3 (see §5.1) for training, and 96 videos and 189 masklets annotated using Phase 1 for testing (Internal-test). See Appendix E for more details on the data engine and SA-V dataset, including a fairness evaluation.
内部数据集。我们还使用内部可用的授权视频数据进一步扩充训练集。我们的内部数据集包含 62.9K 个视频和 69.6K 个在阶段 2 和阶段 3(见 §5.1)标注的用于训练的 masklet,以及 96 个视频和 189 个使用阶段 1 标注的用于测试的 masklet(Internal-test)。关于数据引擎和 SA-V 数据集的更多细节(包括公平性评估),见 Appendix E。
零样本实验
Here, we compare SAM 2 with previous work on zero-shot video and image tasks. We report the standard J &F metric (Pont-Tuset et al., 2017) for video and mIoU metric for image tasks. Unless otherwise mentioned, the results in this section follow our default setup using Hiera-B+ image encoder with a resolution of 1024 and trained on the full combination of datasets, i.e., SAM 2 (Hiera-B+) in Table 6 (see also §D.2 for details).
这里,我们在零样本视频和图像任务上将 SAM 2 与先前工作进行比较。视频任务报告标准 J &F 指标(Pont-Tuset et al., 2017),图像任务报告 mIoU 指标。除非另有说明,本节结果均遵循我们的默认设置:使用分辨率为 1024 的 Hiera-B+ 图像编码器,并在全量数据集组合上训练,即 Table 6 中的 SAM 2 (Hiera-B+)(细节另见 §D.2)。
可提示视频分割
We first evaluate promptable video segmentation, which involves simulating an interactive setting that resembles the user experience. We have two settings, offline evaluation, where multiple passes are made through a video to select frames to interact with based on the largest model error, and online evaluation, where the frames are annotated in a single forward pass through the video. These evaluations are conducted on 9 densely annotated zero-shot video datasets using Nclick = 3 clicks per frame (see §F.1 for details).
我们首先评估可提示视频分割,这涉及模拟类似于用户体验的交互式设置。我们有两种设置:离线评估——多次遍历视频,基于最大模型误差选择要交互的帧;在线评估——在单次前向遍历视频中完成帧的标注。这些评估在 9 个密集标注的零样本视频数据集上进行,每帧使用 Nclick = 3 次点击(细节见 §F.1)。
We create two strong baselines, SAM+XMem++ and SAM+Cutie, based on two state-of-the-art models for video object segmentation, XMem++ (Bekuzarov et al., 2023) and Cutie (Cheng et al., 2023a).
我们基于两个最先进的视频目标分割模型 XMem++(Bekuzarov et al., 2023)和 Cutie(Cheng et al., 2023a)创建了两个强基线:SAM+XMem++ 和 SAM+Cutie。

We use XMem++ to generate a video segmentation based on mask inputs on one or multiple frames. SAM is used to provide an initial mask or to refine an output (by feeding the current segmentation as a mask prompt to SAM). For the SAM+Cutie baseline, we modify Cutie to allow taking mask inputs on multiple frames.
我们使用 XMem++ 基于一帧或多帧上的掩码输入生成视频分割。SAM 用于提供初始掩码或细化输出(将当前分割作为掩码提示输入 SAM)。对于 SAM+Cutie 基线,我们修改了 Cutie,使其允许在多帧上接收掩码输入。
In Fig. 5, we report the average J &F accuracy over Nframe = 1, . . . , 8 interacted frames. SAM 2 outperforms SAM+XMem++ and SAM+Cutie for both offline and online evaluation settings. Across all 9 datasets (see per-dataset results in §F.1), SAM 2 dominates both methods, generating high-quality video segmentation from a few clicks while allowing continued refinement with prompts. Overall, SAM 2 can generate better segmentation accuracy, with >3× fewer interactions.
在 Fig. 5 中,我们报告了 Nframe = 1, …, 8 个交互帧上的平均 J &F 精度。在离线和在线评估设置下,SAM 2 均优于 SAM+XMem++ 和 SAM+Cutie。在所有 9 个数据集上(各数据集结果见 §F.1),SAM 2 全面优于这两种方法,仅凭少量点击即可生成高质量的视频分割,同时允许用提示持续细化。总体而言,SAM 2 能生成更好的分割精度,交互次数少 3 倍以上。
半监督视频目标分割
We evaluate the semi-supervised video object segmentation (VOS) setting (Pont-Tuset et al., 2017) with click, box, or mask prompts only on the first frame of the video. When using click prompts, we interactively sample either 1, 3 or 5 clicks on the first video frame.
我们评估半监督视频目标分割(VOS)设置(Pont-Tuset et al., 2017):仅在视频第一帧使用点击、框或掩码提示。使用点击提示时,我们在第一帧上交互式地采样 1、3 或 5 次点击。

Similar to the interactive setting in §6.1, we compare to XMem++ and Cutie, using SAM for click and box prompts, and in their default setting when using mask prompts. We report the standard J &F accuracy (Pont-Tuset et al., 2017), except for on VOST (Tokmakov et al., 2022), where we report the J metric following its protocol. The results are in Table 4. SAM 2 outperforms both methods on the 17 datasets. The results underline that SAM 2 also excels at the conventional, non-interactive VOS task with mask input, for which these other works are specifically designed. Details are in §F.1.3.
与 §6.1 中的交互式设置类似,我们与 XMem++ 和 Cutie 比较:点击和框提示时使用 SAM,掩码提示时使用它们的默认设置。我们报告标准 J &F 精度(Pont-Tuset et al., 2017),VOST(Tokmakov et al., 2022)除外——按其协议报告 J 指标。结果见 Table 4。SAM 2 在 17 个数据集上均优于这两种方法。这些结果凸显了 SAM 2 在使用掩码输入的常规非交互式 VOS 任务上同样出色,而其他工作正是为该任务专门设计的。细节见 §F.1.3。
图像分割
We evaluate SAM 2 on the Segment Anything task across 37 zero-shot datasets, including 23 datasets previously used by SAM for evaluation. 1-click and 5-click mIoUs are reported in Table 5 and we show the average mIoU by dataset domain and model speed in frames per second (FPS) on a single A100 GPU.
我们在 Segment Anything 任务上评估 SAM 2,覆盖 37 个零样本数据集,包括 SAM 先前用于评估的 23 个数据集。Table 5 报告了 1-click 和 5-click 的 mIoU,并展示了按数据集域划分的平均 mIoU,以及模型在单张 A100 GPU 上的速度(帧/秒,FPS)。

The first column (SA-23 All) shows accuracy on the 23 datasets from SAM. SAM 2 achieves higher accuracy (58.9 mIoU with 1 click) than SAM (58.1 mIoU with 1 click), without using any extra data and while being 6× faster. This can be mainly attributed to the smaller but more effective Hiera image encoder in SAM 2.
第一列(SA-23 All)展示了 SAM 使用的 23 个数据集上的精度。SAM 2 在不使用任何额外数据的情况下取得了比 SAM 更高的精度(SAM 2 为 1 click 58.9 mIoU,SAM 为 1 click 58.1 mIoU),且快 6 倍。这主要归功于 SAM 2 中更小但更高效的 Hiera 图像编码器。
The bottom row shows how training on our SA-1B and video data mix can further improve accuracy to 61.4% on average on the 23 datasets. We also see exceptional gains on the video benchmarks from SA-23 (video datasets are evaluated as images, identical to Kirillov et al. (2023)), and the 14 new video datasets we added. More detailed results including a breakdown by dataset are in §F.3.
最下面一行展示了在我们的 SA-1B 和视频数据混合上训练如何将 23 个数据集上的平均精度进一步提高到 61.4%。我们还在 SA-23 的视频基准(视频数据集按图像方式评估,与 Kirillov et al. (2023) 相同)以及我们新增的 14 个视频数据集上看到显著的提升。包括按数据集细分在内的更详细结果见 §F.3。
与半监督视频目标分割最先进方法的比较
Our primary focus is on the general, interactive PVS task, but we also address the specific semi-supervised VOS setting (where the prompt is a ground-truth mask on the first frame), as it is a historically common protocol. We evaluate two versions of SAM 2 with varying image encoder sizes (Hiera-B+/-L) with different speed-vs-accuracy tradeoffs. We measure frames per second (FPS) on a single A100 GPU using a batch-size of one. SAM 2 based on Hiera-B+ and Hiera-L runs at real-time speeds of 43.8 and 30.2 FPS, respectively.
我们的主要关注点是通用的交互式 PVS 任务,但我们也处理特定的半监督 VOS 设置(提示为第一帧上的真值掩码),因为这是一个历史悠久的通用协议。我们评估两个版本的 SAM 2,使用不同大小的图像编码器(Hiera-B+/-L),在速度与精度之间做出不同权衡。我们在单张 A100 GPU 上以 batch-size 为 1 测量帧率(FPS)。基于 Hiera-B+ 和 Hiera-L 的 SAM 2 分别以 43.8 和 30.2 FPS 的实时速度运行。

We present a comparison with existing state-of-the-art in Table 6, reporting accuracy using standard protocols. SAM 2 shows significant improvement over the best existing methods. We observe that using a larger image encoder brings significant accuracy gains across the board.
我们在 Table 6 中展示了与现有最先进方法的比较,使用标准协议报告精度。SAM 2 相比最好的现有方法有显著提升。我们观察到,使用更大的图像编码器在所有基准上带来了显著的精度提升。
We also evaluate existing work on the SA-V val and test sets which measure performance for open-world segments of “any” object class. When comparing on this benchmark, we see that most previous methods peak at around the same accuracy. The best performance on SA-V val and SA-V test for prior work is significantly lower demonstrating the gap to a “segment anything in videos” capability. Finally, we see that SAM 2 also brings notable gains in long-term video object segmentation as observed in the LVOS benchmark result. For data and model ablations, see §A.
我们还在 SA-V val 和 test 集上评估现有工作,这些集合衡量「任意」物体类别的开放世界分割性能。在该基准上比较时,我们看到大多数先前方法的精度峰值大致相同。先前工作在 SA-V val 和 SA-V test 上的最佳性能显著更低,表明其与「分割视频中的一切」能力之间的差距。最后,我们看到 SAM 2 在长期视频目标分割中也带来了显著提升,如 LVOS 基准结果所示。数据和模型消融见 §A。
结论
We present a natural evolution of Segment Anything into the video domain, based on three key aspects: (i) extending the promptable segmentation task to video, (ii) equipping the SAM architecture to use memory when applied to video, and (iii) the diverse SA-V dataset for training and benchmarking video segmentation. We believe SAM 2 marks a significant advancement in visual perception, positioning our contributions as milestones that will propel further research and applications.
我们呈现了 Segment Anything 向视频领域的自然演进,基于三个关键方面:(i) 将可提示分割任务扩展到视频;(ii) 为 SAM 架构配备记忆能力以应用于视频;(iii) 用于训练和基准测试视频分割的多样化 SA-V 数据集。我们相信 SAM 2 标志着视觉感知的重大进步,我们的贡献将成为推动进一步研究和应用的里程碑。