Skip to content

Pytorch code of IGARSS2025 paper "MergeSAM: Unsupervised Change Detection of remote sensing Images Based on the Segment Anything Model"

Notifications You must be signed in to change notification settings

meiqihu/MergeSAM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⭐ Share us a star if you find this repo helpful!

Official PyTorch implementation of the IGARSS 2025 paper:
MergeSAM: Unsupervised Change Detection of Remote Sensing Images Based on the Segment Anything Model (SAM)


1) 项目简介(Overview)

Abstract
Recently, large foundation models trained on vast datasets have demonstrated exceptional capabilities in feature extraction and general feature representation. The ongoing advancements in deep learning-driven large models have shown great promise in accelerating unsupervised change detection methods, thereby enhancing the practical applicability of change detection technologies. Building on this progress, this paper introduces MergeSAM, an innovative unsupervised change detection method for high-resolution remote sensing imagery, based on the Segment Anything Model (SAM). Two novel strategies, MaskMatching and MaskSplitting, are designed to address real-world complexities such as object splitting, merging, and other intricate changes. The proposed method fully leverages SAM's object segmentation capabilities to construct multitemporal masks that capture complex changes, embedding the spatial structure of land cover into the change detection process.


2) 论文流程与结果(Figures from the Paper)

Algorithm Pipeline – MergeSAM
Fig. 1. MergeSAM pipeline with MaskMatching & MaskSplitting.
Experimental Results – MergeSAM
Fig. 2. Qualitative results on high-resolution change detection benchmarks.

3) How to Start

以下以 maincode.py 为例。

3.1 安装并引入 SAM 项目

  • !!!无需从SAM官方仓库下载segment anything项目,请使用我们上传的segment-anything项目,我们在automatic_mask_generator.py中进行了修改,增加了SamAutomaticMaskGenerator.generate_onlyMask_Embed函数。
  • maincode.py 第 7 行修改为你的本地路径(示例):
# line 7
SAM_PROJECT_PATH = "/absolute/path/to/segment-anything"
import sys; sys.path.append(SAM_PROJECT_PATH)

3.2 下载并设置 SAM 预训练权重

  • 下载权重文件(示例:sam_vit_h_4b8939.pthsam_vit_l_0b3195.pthsam_vit_b_01ec64.pth)。
  • maincode.py 第 27、29、31 行sam_checkpoint 替换为你的权重路径(示例):
# lines 27 / 29 / 31 (examples)
sam_checkpoint_h = "/absolute/path/to/sam_vit_h_4b8939.pth"
sam_checkpoint_l = "/absolute/path/to/sam_vit_l_0b3195.pth"
sam_checkpoint_b = "/absolute/path/to/sam_vit_b_01ec64.pth"

3.3 准备数据并设置路径

  • 下载 GZ_CD_data 或其它二值变化检测数据集并解压。
  • maincode.py 第 146 行设置数据根目录(示例):
# line 146
img_root = "/absolute/path/to/GZ_CD_data"

3.4 环境与运行(示例)

  • 推荐环境:Python ≥ 3.10
  • GPU: ≥ RTX2080
  • 运行:
python maincode.py

注意:若行号不一致,请根据注释语义定位变量(SAM_PROJECT_PATHsam_checkpointimg_root)。如需切换 SAM 变体(H/L/B),请确保权重文件与模型配置匹配。

Acknowledgement

Thanks to the following repository: AnyChange.

About

Pytorch code of IGARSS2025 paper "MergeSAM: Unsupervised Change Detection of remote sensing Images Based on the Segment Anything Model"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published