/rschange

Change detection of remote sensing images

Primary LanguagePython

cap

πŸ“· Introduction

rschange is an open-source change detection toolbox, which is dedicated to reproducing and developing advanced methods for change detection of remote sensing images.

πŸ”₯ News

  • 2024/07/14: Class activation maps and some other popular methods (BIT, SNUNet, ChangeFormer, LGPNet, SARAS-Net) are now supported.

  • 2024/06/24: CDMask has been submitted to Arxiv, see here, and the official implementation of CDMask is available!

πŸ” Preparation

  • Environment preparation

    conda create -n rscd python=3.9
    conda activate rscd
    conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.7 -c pytorch -c nvidia
    pip install -r requirements.txt

    Note: same as rsseg. If you have already installed the environment of rsseg, use it directly.

  • Dataset preprocessing

    LEVIR-CD:The original images are sized at 1024x1024. Following its original division method, we crop these images into non-overlapping patches of 256x256.

    WHU-CD: It contains a pair of dual-time aerial images measuring 32507 Γ— 15354. These images are cropped into patches of 256 Γ— 256 size. The dataset is then randomly divided into three subsets: the training set, the validation set, and the test set, following a ratio of 8:1:1.

    DSIFN-CD & CLCD & SYSU-CD: They all follow the original image size and dataset division method.

    Note: We also provide the pre-processed data, which can be downloaded at this link

πŸ“’ Folder Structure

Prepare the following folders to organize this repo:

  rschangedetection
      β”œβ”€β”€ rscd (code)
      β”œβ”€β”€ work_dirs (save the model weights and training logs)
      β”‚   └─CLCD_BS4_epoch200 (dataset)
      β”‚       └─stnet (model)
      β”‚           └─version_0 (version)
      β”‚              β”‚  └─ckpts
      β”‚              β”‚      β”œβ”€test (the best ckpts in test set)
      β”‚              β”‚      └─val (the best ckpts in validation set)
      β”‚              β”œβ”€log (tensorboard logs)
      β”‚              β”œβ”€train_metrics.txt (train & val results per epoch)
      β”‚              β”œβ”€test_metrics_max.txt (the best test results)
      β”‚              └─test_metrics_rest.txt (other test results)
      └── data
          β”œβ”€β”€ LEVIR_CD
          β”‚   β”œβ”€β”€ train
          β”‚   β”‚   β”œβ”€β”€ A
          β”‚   β”‚   β”‚   └── images1.png
          β”‚   β”‚   β”œβ”€β”€ B
          β”‚   β”‚   β”‚   └── images2.png
          β”‚   β”‚   └── label
          β”‚   β”‚       └── label.png
          β”‚   β”œβ”€β”€ val (the same with train)
          β”‚   └── test(the same with train)
          β”œβ”€β”€ DSIFN
          β”‚   β”œβ”€β”€ train
          β”‚   β”‚   β”œβ”€β”€ t1
          β”‚   β”‚   β”‚   └── images1.jpg
          β”‚   β”‚   β”œβ”€β”€ t2
          β”‚   β”‚   β”‚   └── images2.jpg
          β”‚   β”‚   └── mask
          β”‚   β”‚       └── mask.png
          β”‚   β”œβ”€β”€ val (the same with train)
          β”‚   └── test
          β”‚       β”œβ”€β”€ t1
          β”‚       β”‚   └── images1.jpg
          β”‚       β”œβ”€β”€ t2
          β”‚       β”‚   └── images2.jpg
          β”‚       └── mask
          β”‚           └── mask.tif
          β”œβ”€β”€ WHU_CD
          β”‚   β”œβ”€β”€ train
          β”‚   β”‚   β”œβ”€β”€ image1
          β”‚   β”‚   β”‚   └── images1.png
          β”‚   β”‚   β”œβ”€β”€ image2
          β”‚   β”‚   β”‚   └── images2.png
          β”‚   β”‚   └── label
          β”‚   β”‚       └── label.png
          β”‚   β”œβ”€β”€ val (the same with train)
          β”‚   └── test(the same with train)
          β”œβ”€β”€ CLCD (the same with WHU_CD)
          └── SYSU_CD
              β”œβ”€β”€ train
              β”‚   β”œβ”€β”€ time1
              β”‚   β”‚   └── images1.png
              β”‚   β”œβ”€β”€ time2
              β”‚   β”‚   └── images2.png
              β”‚   └── label
              β”‚       └── label.png
              β”œβ”€β”€ val (the same with train)
              └── test(the same with train)

πŸ“š Use example

  • Training

    python train.py -c configs/STNet.py
  • Testing

    python test.py \
    -c configs/STNet.py \
    --ckpt work_dirs/CLCD_BS4_epoch200/stnet/version_0/ckpts/test/epoch=45.ckpt \
    --output_dir work_dirs/CLCD_BS4_epoch200/stnet/version_0/ckpts/test \
  • Count params and flops

    python tools/params_flops.py --size 256
  • Class activation maps

    python tools/grad_cam_CNN.py -c configs/cdmask.py

🌟 Citation

If you are interested in our work, please consider giving a 🌟 and citing our work below. We will update rschange regularly.

@inproceedings{stnet,
  title={STNet: Spatial and Temporal feature fusion network for change detection in remote sensing images},
  author={Ma, Xiaowen and Yang, Jiawei and Hong, Tingfeng and Ma, Mengting and Zhao, Ziyan and Feng, Tian and Zhang, Wei},
  booktitle={2023 IEEE International Conference on Multimedia and Expo (ICME)},
  pages={2195--2200},
  year={2023},
  organization={IEEE}
}

@article{ddlnet,
  title={DDLNet: Boosting Remote Sensing Change Detection with Dual-Domain Learning},
  author={Ma, Xiaowen and Yang, Jiawei and Che, Rui and Zhang, Huanting and Zhang, Wei},
  journal={arXiv preprint arXiv:2406.13606},
  year={2024}
}

@article{cdmask,
  title={Rethinking Remote Sensing Change Detection With A Mask View},
  author={Ma, Xiaowen and Wu, Zhenkai and Lian, Rongrong and Zhang, Wei and Song, Siyang},
  journal={arXiv preprint arXiv:2406.15320},
  year={2024}
}

πŸ’‘ Acknowledgement

Thanks to previous open-sourced repo:

Thanks to the main contributor Zhenkai Wu