• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Python
  • Created almost 3 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images

Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images

Wele Gedara Chaminda Bandara, and Vishal M. Patel

PWC PWC PWC PWC

PWC PWC PWC PWC

📖 📖 📖 📖 View paper here.

🔖 🔖 🔖 View project page here.

This repocitory contains the official implementation of our paper: Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images.

💬 Requirements

This repo was tested with Ubuntu 18.04.3 LTS, Python 3.8, PyTorch 1.1.0, and CUDA 10.0. But it should be runnable with recent PyTorch versions >=1.1.0.

The required packages are pytorch and torchvision, together with PIL and opencv for data-preprocessing and tqdm for showing the training progress.

conda create -n SemiCD python=3.8

conda activate SemiCD

pip3 install -r requirements.txt

💬 Datasets

We use two publicly available, widely-used CD datasets for our experiments, namely LEVIR-CD and WHU-CD. Note that LEVIR-CD and WHU-CD are building CD datasets.

As we described in the paper, following previous works ChangeFormer and BIT-CD on supervised CD, we create non-overlapping patches of size 256x256 for the training. The dataset preparation codes are written in MATLAB and can be found in dataset_preperation folder. These scripts will also generate the supervised and unsupervised training scripts that we used to train the model under diffrent percentage of labeled data.

Instead, you can directely download the processed LEVIR-CD and WHU-CD through the following links. Save these datasets anywhere you want and change the data_dir to each dataset in the corresponding config file.

The processed LEVIR-CD dataset, and supervised-unsupervised splits can be downloaded here.

The processed WHU-CD dataset, and supervised-unsupervised splits can be downloaded here.

💬 Training

To train a model, first download processed dataset above and save them in any directory you want, then set data_dir to the dataset path in the config file in configs/config_LEVIR.json/configs/config_WHU.json and set the rest of the parameters, like experim_name, sup_percent, unsup_percent, supervised, semi, save_dir, log_dir ... etc., more details below.

👉 Training on LEVIR-CD dataset

Then simply run:

python train.py --config configs/config_LEVIR.json

The following table summarizes the required changes in config file to train a model supervised or unsupervised with different percentage of labeled data.

Setting Required changes in config_LEVIR.json file
Supervised - 5% labeled data Experiment name: SemiCD_(sup)_5, sup_percent= 5, model.supervised=True, model.semi=False
Supervised - 10% labeled data Experiment name: SemiCD_(sup)_10, sup_percent= 10, model.supervised=True, model.semi=False
Supervised - 20% labeled data Experiment name: SemiCD_(sup)_20, sup_percent= 20, model.supervised=True, model.semi=False
Supervised - 40% labeled data Experiment name: SemiCD_(sup)_40, sup_percent= 40, model.supervised=True, model.semi=False
Supervised - 100% labeled data (Oracle) Experiment name: SemiCD_(sup)_100, sup_percent= 100, model.supervised=True, model.semi=False
Semi-upervised - 5% labeled data Experiment name: SemiCD_(semi)_5, sup_percent= 5, model.supervised=Flase, model.semi=True
Semi-upervised - 10% labeled data Experiment name: SemiCD_(semi)_10, sup_percent= 10, model.supervised=Flase, model.semi=True
Semi-upervised - 20% labeled data Experiment name: SemiCD_(semi)_20, sup_percent= 20, model.supervised=Flase, model.semi=True
Semi-upervised - 40% labeled data Experiment name: SemiCD_(semi)_40, sup_percent= 40, model.supervised=Flase, model.semi=True

👉 Training on WHU-CD dataset

Please follow the same changes that we outlined above to WHU-CD dataset as well. Then simply run:

python train.py --config configs/config_WHU.json

👉 Training with cross-domain data (i.e., LEVIR as supervised and WHU as unsupervised datasets)

In this case we use LEVIR-CD as the supervised dataset and WHU-CD as the unsupervised dataset. Therefore, you need to update the train_supervised data_dir as the path to LEVIR-CD dataset, and train_unsupervised data_dir as the path to WHU-CD dataset in config_LEVIR-sup_WHU-unsup.json. Then change the sup_percent in the config file as you want and then simply run:

python train.py --config configs/config_LEVIR-sup_WHU-unsup.json

👉 Monitoring the training log via TensorBoard

The log files and the .pth checkpoints will be saved in saved\EXP_NAME, to monitor the training using tensorboard, please run:

tensorboard --logdir saved

To resume training using a saved .pth model:

python train.py --config configs/config_LEVIR.json --resume saved/SemiCD/checkpoint.pth

Results: The results will be saved in saved as an html file, containing the validation results, and the name it will take is experim_name specified in configs/config_LEVIR.json.

💬 Inference

For inference, we need a pretrained model, the pre-chage and pos-change imags that we wouldlike to dtet changes and the config used in training (to load the correct model and other parameters),

python inference.py --config config_LEVIR.json --model best_model.pth --images images_folder

Here are the flags available for inference:

--images       Folder containing the jpg images to segment.
--model        Path to the trained pth model.
--config       The config file used for training the model.

💬 Pre-trained models

Pre-trained models can be downloaded from the following links.

Pre-trained models on LEVIR-CD can be downloaded from here.

Pre-trained models on WHU-CD can be downloaded from here.

Pre-trained models for cross-dataset experiments can be downloaded from here.

💬 Citation

If you find this repo useful for your research, please consider citing the paper as follows:

@misc{bandara2022revisiting,
      title={Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images}, 
      author={Wele Gedara Chaminda Bandara and Vishal M. Patel},
      year={2022},
      eprint={2204.08454},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Acknowledgements

More Repositories

1

ChangeFormer

[IGARSS'22]: A Transformer-Based Siamese Network for Change Detection
Python
420
star
2

ddpm-cd

Remote Sensing Change Detection using Denoising Diffusion Probabilistic Models
Python
260
star
3

HyperTransformer

[CVPR'22] HyperTransformer: A Textural and Spectral Feature Fusion Transformer for Pansharpening
Python
124
star
4

SPIN_RoadMapper

Official implementation of our ICRA'22 paper: SPIN Road Mapper: Extracting Roads from Aerial Images via Spatial and Interaction Space Graph Reasoning for Autonomous Driving
Jupyter Notebook
79
star
5

adamae

[CVPR'23] AdaMAE: Adaptive Masking for Efficient Spatiotemporal Learning with Masked Autoencoders
Python
71
star
6

DIP-HyperKite

[IEEE TGRS] DIP-HyperKite: Hyperspectral Pansharpening Based on Improved Deep Image Prior and Residual Reconstruction
Python
56
star
7

Metric-CD

Official PyTorch implementation of Deep Metric Learning for Unsupervised Change Detection in Remote Sensing Images
Jupyter Notebook
15
star
8

mix-bt

Official PyTorch Implementation of Guarding Barlow Twins Against Overfitting with Mixed Samples
Python
13
star
9

apt

PyTorch Implementation of Attention Prompt Tuning: Parameter-Efficient Adaptation of Pre-Trained Models for Action Recognition
Python
13
star
10

CD-SOTA-methods

Remote sensing change detection: state of the art methods and datasets
6
star
11

Complete_State-Estimation_Algorithm

A Complete State Estimation Algorithm for a Three-Phase Four-Wire Low Voltage Distribution System with High Penetration of Solar PV
Jupyter Notebook
5
star
12

DiffuseDenoiseCount

Python
1
star