SSLChange
November 17, 2024 ยท View on GitHub
This is a PyTorch implementation of the paper SSLChange: A Self-supervised Change Detection Framework Based on Domain Adaptation
๐ Citation
If you find our project useful in you own research, please consider cite our paper below.
@ARTICLE{zhap2024sslchange,
author={Zhao, Yitao and Celik, Turgay and Liu, Nanqing and Gao, Feng and Li, Heng-Chao},
journal={IEEE Transactions on Geoscience and Remote Sensing},
title={SSLChange: A Self-Supervised Change Detection Framework Based on Domain Adaptation},
year={2024},
volume={62},
number={},
pages={1-14},
doi={10.1109/TGRS.2024.3489615}}
- ๐ฉ 11/1/2024 Our manuscript has been accepted by IEEE TGRS.
๐ Architecture Overview
The overview of our proposed SSLChange pre-training framework for Remote Sensing Change Decetion tasks.
๐ Catalog
- Visualization Demo
- Dependencies
- Domain Adapter Training
- SSLChange Pre-training
- Downstream Finetuning
๐จ Visualization Demo
The visualization results of baselines w/o and w/ SSLChange on CDD-series dataset.
๐ผ Dependencies
- Linux (Recommended) or Windows
- Python 3.8+
- Pytorch 1.8.0 or higher
- CUDA 10.1 or higher
๐น Code Usage
1. Domain Adapter Training
- A Domain Adapter needs to be trained to serve as an auto-augmenter in the subsequent SSLChange Pre-training.
- The training target of Domain Adapter is to project the T1 samples into T2 domain style without change image content.
- The architecture could be ANY Image-to-Image Translation Algorithms.
- Here we take CycleGAN with stable performance as an example to train the Domain Adapter.
๐ Step 1. Dataset Preparation for DA Training.
Only the training set of CDD dataset is used for DA training, and no label images are involved in the training.
CDD
โโโ /train/
โ โโโ /A/
โ โ โโโ 00000.jpg
โ โ โโโ 00001.jpg
โ โ โโโ ......
โ โโโ /B/
โ โ โโโ 00000.jpg
โ โ โโโ 00001.jpg
โ โ โโโ ......
๐ฅ Step 2. Train the Domain Adapter. (train.py file in CycleGAN)
python train.py --dataroot datasets/CDD/train/ --name YOUR_PROJECT
๐ Step 3. SSLChange Pre-training Dataset Generation. (test.py file in CycleGAN)
python test.py --dataroot datasets/CDD/train/ --name YOUR_PROJECT --model cycle_gan --direction AtoB
โญ๏ธSome generated samples of GenCDD dataset:
Original T1 images:
Generated Pseudo T2 images in GenCDD dataset:
2. SSLChange Pre-training
Perform the SSLChange Pre-training with the Generated GenCDD dataset.
๐ Step 1. Dataset Preparation for SSLChange Pre-training.
Only the training set of GenCDD dataset is used for SSLChange Pre-training.
GenCDD
โโโ /train/
โ โโโ /A/
โ โ โโโ 00000.jpg
โ โ โโโ 00001.jpg
โ โ โโโ ......
โ โโโ /B/
โ โ โโโ 00000.jpg
โ โ โโโ 00001.jpg
โ โ โโโ ......
๐ฅ Step 2. Label-free Pre-training of SSLChange Framework.
Only the training set of GenCDD dataset is used for SSLChange Pre-training.
cd SSLChange
python train.py --dataroot ./datasets/GenCCD/train --name YOUR_PROJECT --model sslchange --gpu_ids 0 --simsiam_aug \
--batch_size 8 --contrastive_head sslchange_head
We release our pre-trained SSLChange weights on GenCDD dataset in Google Drive, and BaiduYunPan (code: scpt).
3. Downstream Finetuning
๐ Step 1. Dataset Preparation for SSLChange Pre-training.
The whole portion of CDD dataset is used for downstream supervised finetuning.
CDD
โโโ /train/
โ โโโ /A/
โ โโโ /B/
โ โโโ /OUT/
โโโ /test/
โ โโโ /A/
โ โโโ /B/
โ โโโ /OUT/
โโโ /val/
โ โโโ /A/
โ โโโ /B/
โ โโโ /OUT/
๐ฎ Step 2. Pre-trained Weight Transferring.
Create a new dir to store the pre-trained SSLChange weights file.
cd Transfer-Model
mkdir pretrained_models
mkdir pretrained_models/PRETRAINED_PROJECT
cp -r ../SSLChange/checkpoint/YOUR_PROJECT/ ../Transfer-Model/pretrained_models/PRETRAINED_PROJECT/
๐ฅ Step 3. Downstream Finetuning.
Take the finetuning for SNUNet-CD as an example.
python main_finetune.py --dataset_dir datasets/CDD --name YOUR_FTINETUNE_PROJECT \
--pretrained_model PRETRAINED_PROJECT/latest_net_SimSiam.pth \
--gpu_ids 0 --head_type sslchange_head --classifier_name SNUNet --batch_size 4
โ Step 4. Testing.
python eval.py --dataset_dir datasets/CDD --name YOUR_FTINETUNE_PROJECT --classifier_name SNUNet --gpu_ids 0
๐ก Acknowledgement
We are grateful to those who kindly share their codes, which we referenced in our implementation.