SAM2-UNet

WZH0120Apache-2.0更新放缓

把 Segment Anything 2 当作强编码器接上 U-Net 解码器,做自然图像和医学图像分割,覆盖伪装目标、息肉、海洋动物等场景。

[VINT 2026] SAM2-UNet: Segment Anything 2 Makes Strong Encoder for Natural and Medical Image Segmentation

暂无版本528star64fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/WZH0120/SAM2-UNet.git
cd SAM2-UNet/
conda create -n sam2-unet python=3.10
conda activate sam2-unet
pip install -r requirements.txt
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求;训练需下载 SAM2 预训练权重 sam2_hiera_large.pt。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 SAM2 的 Hiera 编码器加 U 型解码器做图像分割,覆盖自然与医学场景

把 Segment Anything 2 当作强编码器接上 U-Net 解码器,做自然图像和医学图像分割,覆盖伪装目标、息肉、海洋动物等场景。

核心能力

  • 以 SAM2 的 Hiera backbone 作为 U-Net 编码器
  • 解码器采用经典 U 型设计
  • 在编码器中插入 adapter 实现参数高效微调
  • 提供训练、测试、评估脚本 train.sh/test.sh/eval.sh
  • 覆盖伪装目标、显著目标、海洋动物、镜像、息肉分割任务

容易踩的坑

训练前需自行从官方仓库下载 SAM2 预训练权重,且必须用 SAM2 而非 SAM2.1;项目不依赖安装 SAM2 包,但已配好 SAM2 环境可直接复用;预训练模型和预测图放在 Google Drive,需自行下载。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    SAM2-UNet: Segment Anything 2 Makes Strong Encoder for Natural and Medical Image Segmentation

    Xinyu Xiong, Zihuang Wu, Shuangyi Tan, Wenxue Li, Feilong Tang, Ying Chen, Siying Li, Jie Ma, Guanbin Li

    Introduction

    frameworkImage segmentation plays an important role in vision understanding. Recently, the emerging vision foundation models continuously achieved superior performance on various tasks. Following such success, in this paper, we prove that the Segment Anything Model 2 (SAM2) can be a strong encoder for U-shaped segmentation models. We propose a simple but effective framework, termed SAM2-UNet, for versatile image segmentation. Specifically, SAM2-UNet adopts the Hiera backbone of SAM2 as the encoder, while the decoder uses the classic U-shaped design. Additionally, adapters are inserted into the encoder to allow parameter-efficient fine-tuning. Preliminary experiments on various downstream tasks, such as camouflaged object detection, salient object detection, marine animal segmentation, mirror detection, and polyp segmentation, demonstrate that our SAM2-UNet can simply beat existing specialized state-of-the-art methods without bells and whistles.

    微信交流群 

    Clone Repository

    git clone https://github.com/WZH0120/SAM2-UNet.git
    cd SAM2-UNet/
    

    Prepare Datasets

    You can refer to the following repositories and their papers for the detailed configurations of the corresponding datasets.

    • Camouflaged Object Detection. Please refer to FEDER. [#issue #13, #44]
    • Salient Object Detection. Please refer to SALOD.
    • Marine Animal Segmentation. Please refer to MASNet.
    • Mirror Detection. Please refer to HetNet.
    • Polyp Segmentation. Please refer to PraNet.

    Requirements

    Our project does not depend on installing SAM2. If you have already configured an environment for SAM2, then directly using this environment should also be fine. You may also create a new conda environment:

    conda create -n sam2-unet python=3.10
    conda activate sam2-unet
    pip install -r requirements.txt
    

    Training

    If you want to train your own model, please download the pre-trained segment anything 2 (not SAM2.1, [#issue #18, #30]) from the official repository. You can also directly download sam2_hiera_large.pt from here. After the above preparations, you can run train.sh to start your training.

    Testing

    Our pre-trained models and prediction maps can be found on Google Drive. Also, you can run test.sh to obtain your own predictions.

    Evaluation

    After obtaining the prediction maps, you can run eval.sh to get most of the quantitative results. For the evaluation of mirror detection, please refer to eval.py in HetNet to obtain the results.

    Citation and Star

    Please cite the following paper and star this project if you use this repository in your research. Thank you!

    @article{xiong2026sam2,
      title={Sam2-unet: Segment anything 2 makes strong encoder for natural and medical image segmentation},
      author={Xiong, Xinyu and Wu, Zihuang and Tan, Shuangyi and Li, Wenxue and Tang, Feilong and Chen, Ying and Li, Siying and Ma, Jie and Li, Guanbin},
      journal={Visual Intelligence},
      volume={4},
      number={1},
      pages={2},
      year={2026},
      publisher={Springer}
    }
    

    Acknowledgement

    segment anything 2