news 2026/2/16 5:57:34

论文精读:《SAM 2: Segment Anything in Images and Videos》

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
论文精读:《SAM 2: Segment Anything in Images and Videos》

更好阅读体验:
【我的博客原文】

概览

SAM2提出了PVS(Promptable Visual Segmentation)任务。在Section 3Appendix B中,文章给出了他的具体定义。在Section 3中,文章具体描述了这个任务为:

Our PVS taskallows providing prompts to the model on any frame of a video. Prompts can bepositive/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 modelshould **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), themodel 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).

简要来讲,他将Segment Anything的Task在“视频与交互”的领域做了延伸扩展。文章着重点出了propagate这一概念。具体来说,这意味着模型应该将帧间稀疏的标注传递到每一帧。

相较SAM,SAM2更聚焦于视频中物体的连续分割。在SAM2的实现中,它设计了一个Memory BankMemory Attention用以保留并propagate帧间的Mask结果与prompt。

与SAM类似,它也采用了和SAM一致的Image Encoder、一致的Prompt Encoder与结构类似的Mask Decoder。在工作进行过程中,SAM2也着重聚焦于Data Engine的构建——本质上,他也是一个数据工程

我认为贡献如下:

  • 定义了PVS这一任务
  • 设计了Memory BankMemory Attention的架构用于帧间prompts传递与帧间分割一致性
  • 设计了渐进式数据引擎
  • 发布了SA-V数据集

Related Work

  • Image segmentation:在本文中主要聚焦于SAM以及SAM的下游工作。
  • Interactive Video Object Segmentation (iVOS):对于视频,可交互的标注希望连续追踪的目标物体,模型及时的响应、分割。
  • Video Object Segmentation (VOS):对于视频,在第一帧标注出目标物体,模型应该自动在整个视频中标注出目标。
  • Video segmentation datasets:常见的VOS数据集如:Yotube-VOS、DAVIS

Task: promptable visual segmentation

对PVS的具体定义如下:

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).

Model & Appendix D

模型架构非常值得一读。简要来说,他在SAM的基础上,增加了Memory BankMemory Attention,用以实现在视频帧间进行propagate。架构如下:

  • Image encoder
  • Memory attention
  • Prompt encoder and mask decoder
  • Memory encoder
  • Memory bank

相较SAM,SAM2多了很多Memory的架构。

在这一章中有提到:

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.

这里说到”prompted frames to also come “from the future” relative to the current frame”。我对其理解是这样的:Memory Bank保存分两部分(见下文)——过去预测帧提示帧。在其中,过去预测帧都是 “from past” 的,而提示帧则可能来自当前图片后面。我想我之后需要深度挖掘一下代码来确定下。

Image Encoder

SAM2的Image Encoder采用了Hiera Image Encoder。Hiera Image Encoder是Meta提出的一个高性能Image Encoder,它主张通过强大的预训练任务(如 MAE)来替代分层视觉 Transformer 中专用模块(例如卷积)提供的空间偏差。

这是什么意思呢?原始的的ViT也没有“专用模块”啊?确实,原始的的ViT没有。

但是”分层视觉 Transformer”比如大名鼎鼎的Swin Transformer就有:

好,Hiera 确实没有繁杂的Patch merging操作,但是他却有“Q Pooling”,这又是什么?下图是MViT给出的Q Pooling/Pooling attention架构:

简单来说,原始的Attention是:

Q = X W Q , K = X W k , V = X W v Attn ( X ) = softmax ( Q K ⊤ d ) V Q=XW_Q,K = XW_k, V=XW_v\\ \text{Attn}(X)=\text{softmax}(\frac{QK^\top}{\sqrt{d}})VQ=XWQ

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/2/11 14:13:27

XUnity翻译:AI如何革新多语言游戏开发流程

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 开发一个基于XUnity框架的AI翻译插件,能够自动扫描游戏项目中的文本资源,调用多语言API进行高质量翻译,并保持原有文本格式和上下文语境。要求支…

作者头像 李华
网站建设 2026/2/15 1:10:04

Spacedesk在远程办公中的5个创新应用场景

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 创建一个展示Spacedesk应用场景的演示项目,包含以下案例:1. 设计师使用平板作为电脑绘图板;2. 教师在教室用手机控制讲台电脑;3. IT支…

作者头像 李华
网站建设 2026/2/11 21:11:35

利用大规模生物活性挖掘,计算识别针对癌基因驱动蛋白 EGFR、BRAF 与 CDK4 的高亲和力抑制剂

通过化学信息学方法,对靶向 BRAF V600E 和 EGFR 的新颖化学骨架进行体外筛选。 摘要 背景:精准癌症治疗需要小分子抑制剂与致瘤蛋白靶点之间的精确匹配。 方法:我们使用 Python 及 ChEMBL 数据库 API 开发了一套计算流程,系统性地筛选针对 EGFR、BRAF 与 CDK4 的高亲和力配…

作者头像 李华
网站建设 2026/2/9 20:13:57

Ubuntu服务器实战:从零搭建高可用Web服务集群

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 开发一个Ubuntu服务器集群管理工具,功能包括:1. 自动化部署LAMP/LEMP环境 2. 配置Nginx负载均衡 3. 设置MySQL主从复制 4. 监控各节点状态 5. 提供一键扩展/…

作者头像 李华
网站建设 2026/2/12 4:31:26

6、深入探索 Mac 终端:高级定制与文件系统

深入探索 Mac 终端:高级定制与文件系统 在使用 Mac 电脑时,终端是一个功能强大的工具,它能让你以命令行的方式与系统进行交互,实现比图形界面更强大的操作。本文将详细介绍终端高级定制、别名创建、处理无响应终端以及探索文件系统等相关内容。 1. 高级 Shell 定制 终端…

作者头像 李华
网站建设 2026/2/7 2:30:46

智能体开发在电商推荐系统中的应用

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 开发一个电商推荐系统的AI智能体,能够根据用户历史行为、实时浏览数据和偏好,动态生成个性化商品推荐。功能包括:1. 用户画像分析;2.…

作者头像 李华