Segment Anything Model (SAM) has attracted considerable attention for its strong zero-shot segmentation capability, but its deployment in real-world scenarios is hindered by slow inference and high memory consumption, largely due to the attention mechanism. Existing works mainly focus on compressing the encoder, while leaving the inefficiency of attention computation insufficiently addressed. We propose SAM-Lightening, a lightweight variant of SAM that integrates a re-engineered attention operator, Dilated FlashAttention, to improve parallelism and efficiency while remaining compatible with FlashAttention. In addition, we design a progressive distillation strategy to transfer knowledge from the original SAM without expensive retraining. Experiments on COCO and LVIS demonstrate that SAM-Lightening achieves state-of-the-art efficiency and accuracy. It processes \(1024 \times 1024\) images in 7 ms— \(30.1\times \) faster than vanilla SAM and \(2.1\times \) faster than the previous best—while requiring only 244 MB memory (3.5% of vanilla SAM). These results highlight its potential for practical deployment on resource-constrained platforms.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

SAM-Lightning: Segment Anything Model for Efficient Inference and Reduced Memory Footprint

  • Yanfei Song,
  • Hongxu Jiang,
  • Bangzheng Pu,
  • Peng Wang,
  • Dong Dong,
  • Yongxiang Cao,
  • Runhua Zhang,
  • Yiqing Shen

摘要

Segment Anything Model (SAM) has attracted considerable attention for its strong zero-shot segmentation capability, but its deployment in real-world scenarios is hindered by slow inference and high memory consumption, largely due to the attention mechanism. Existing works mainly focus on compressing the encoder, while leaving the inefficiency of attention computation insufficiently addressed. We propose SAM-Lightening, a lightweight variant of SAM that integrates a re-engineered attention operator, Dilated FlashAttention, to improve parallelism and efficiency while remaining compatible with FlashAttention. In addition, we design a progressive distillation strategy to transfer knowledge from the original SAM without expensive retraining. Experiments on COCO and LVIS demonstrate that SAM-Lightening achieves state-of-the-art efficiency and accuracy. It processes \(1024 \times 1024\) images in 7 ms— \(30.1\times \) faster than vanilla SAM and \(2.1\times \) faster than the previous best—while requiring only 244 MB memory (3.5% of vanilla SAM). These results highlight its potential for practical deployment on resource-constrained platforms.