All Projects → justchenhao → Stanet

justchenhao / Stanet

Licence: bsd-2-clause
official implementation of the spatial-temporal attention neural network (STANet) for remote sensing image change detection

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Stanet

Awesome Remote Sensing Change Detection
List of datasets, codes, and contests related to remote sensing change detection
Stars: ✭ 414 (+279.82%)
Mutual labels:  dataset, remote-sensing
ChangeFormer
Official PyTorch implementation of our IGARSS'22 paper: A Transformer-Based Siamese Network for Change Detection
Stars: ✭ 220 (+101.83%)
Mutual labels:  remote-sensing, attention-mechanism
Universal Data Tool
Collaborate & label any type of data, images, text, or documents, in an easy web interface or desktop app.
Stars: ✭ 1,356 (+1144.04%)
Mutual labels:  dataset
Personalized Dialog
Code for the paper 'Personalization in Goal-oriented Dialog' (NeurIPS 2017 Conversational AI Workshop)
Stars: ✭ 109 (+0%)
Mutual labels:  dataset
Reformer Pytorch
Reformer, the efficient Transformer, in Pytorch
Stars: ✭ 1,644 (+1408.26%)
Mutual labels:  attention-mechanism
C3
Investigating Prior Knowledge for Challenging Chinese Machine Reading Comprehension
Stars: ✭ 101 (-7.34%)
Mutual labels:  dataset
Ua Gec
UA-GEC: Grammatical Error Correction and Fluency Corpus for the Ukrainian Language
Stars: ✭ 108 (-0.92%)
Mutual labels:  dataset
Dataset
Crop/Weed Field Image Dataset
Stars: ✭ 98 (-10.09%)
Mutual labels:  dataset
Pyrate
A Python tool for estimating velocity and time-series from Interferometric Synthetic Aperture Radar (InSAR) data.
Stars: ✭ 110 (+0.92%)
Mutual labels:  remote-sensing
Chatgirl
ChatGirl is an AI ChatBot based on TensorFlow Seq2Seq Model. ChatGirl 一个基于 TensorFlow Seq2Seq 模型的聊天机器人。(包含预处理过的 twitter 英文数据集,训练,运行,工具代码,来波 Star 。)QQ群:167122861
Stars: ✭ 105 (-3.67%)
Mutual labels:  dataset
Impy
Impy is a Python3 library with features that help you in your computer vision tasks.
Stars: ✭ 109 (+0%)
Mutual labels:  dataset
Faceaging By Cyclegan
Stars: ✭ 105 (-3.67%)
Mutual labels:  dataset
Iso 3166 Countries With Regional Codes
ISO 3166-1 country lists merged with their UN Geoscheme regional codes in ready-to-use JSON, XML, CSV data sets
Stars: ✭ 1,372 (+1158.72%)
Mutual labels:  dataset
Race ar baselines
Baselines of the RACE Reading Comprehension Dataset
Stars: ✭ 108 (-0.92%)
Mutual labels:  dataset
Scientificsummarizationdatasets
Datasets I have created for scientific summarization, and a trained BertSum model
Stars: ✭ 100 (-8.26%)
Mutual labels:  dataset
Ylg
[CVPR 2020] Official Implementation: "Your Local GAN: Designing Two Dimensional Local Attention Mechanisms for Generative Models".
Stars: ✭ 109 (+0%)
Mutual labels:  attention-mechanism
Objectron
Objectron is a dataset of short, object-centric video clips. In addition, the videos also contain AR session metadata including camera poses, sparse point-clouds and planes. In each video, the camera moves around and above the object and captures it from different views. Each object is annotated with a 3D bounding box. The 3D bounding box describes the object’s position, orientation, and dimensions. The dataset contains about 15K annotated video clips and 4M annotated images in the following categories: bikes, books, bottles, cameras, cereal boxes, chairs, cups, laptops, and shoes
Stars: ✭ 1,352 (+1140.37%)
Mutual labels:  dataset
Fma
FMA: A Dataset For Music Analysis
Stars: ✭ 1,391 (+1176.15%)
Mutual labels:  dataset
Lambda Networks
Implementation of LambdaNetworks, a new approach to image recognition that reaches SOTA with less compute
Stars: ✭ 1,497 (+1273.39%)
Mutual labels:  attention-mechanism
Graph Parser
GraphParser is a semantic parser which can convert natural language sentences to logical forms and graphs.
Stars: ✭ 110 (+0.92%)
Mutual labels:  dataset

STANet for remote sensing image change detection

It is the implementation of the paper: A Spatial-Temporal Attention-Based Method and a New Dataset for Remote Sensing Image Change Detection.

Here, we provide the pytorch implementation of the spatial-temporal attention neural network (STANet) for remote sensing image change detection.

image-20200601213320103

Change log

20210112:

20201105:

  • add a demo for quick start.
  • add more dataset loader modes.
  • enhance the image augmentation module (crop and rotation).

20200601:

  • first commit

Prerequisites

  • windows or Linux
  • Python 3.6+
  • CPU or NVIDIA GPU
  • CUDA 9.0+
  • PyTorch > 1.0
  • visdom

Installation

Clone this repo:

git clone https://github.com/justchenhao/STANet
cd STANet

Install PyTorch 1.0+ and other dependencies (e.g., torchvision, visdom and dominate)

Quick Start

You can run a demo to get started.

python demo.py

The input samples are in samples. After successfully run this script, you can find the predicted results in samples/output.

Prepare Datasets

download the change detection dataset

You could download the LEVIR-CD at https://justchenhao.github.io/LEVIR/;

The path list in the downloaded folder is as follows:

path to LEVIR-CD:
                ├─train
                │  ├─A
                │  ├─B
                │  ├─label
                ├─val
                │  ├─A
                │  ├─B
                │  ├─label
                ├─test
                │  ├─A
                │  ├─B
                │  ├─label

where A contains images of pre-phase, B contains images of post-phase, and label contains label maps.

cut bitemporal image pairs

The original image in LEVIR-CD has a size of 1024 * 1024, which will consume too much memory when training. Therefore, we can cut the origin images into smaller patches (e.g., 256 * 256, or 512 * 512). In our paper, we cut the original image into patches of 256 * 256 size without overlapping.

Make sure that the corresponding patch samples in the A, B, and label subfolders have the same name.

Train

Monitor training status

To view training results and loss plots, run this script and click the URL http://localhost:8097.

python -m visdom.server

train with our base method

Run the following script:

python ./train.py --save_epoch_freq 1 --angle 15 --dataroot path-to-LEVIR-CD-train --val_dataroot path-to-LEVIR-CD-val --name LEVIR-CDF0 --lr 0.001 --model CDF0 --batch_size 8 --load_size 256 --crop_size 256 --preprocess rotate_and_crop

Once finished, you could find the best model and the log files in the project folder.

train with Basic spatial-temporal Attention Module (BAM) method

python ./train.py --save_epoch_freq 1 --angle 15 --dataroot path-to-LEVIR-CD-train --val_dataroot path-to-LEVIR-CD-val --name LEVIR-CDFA0 --lr 0.001 --model CDFA --SA_mode BAM --batch_size 8 --load_size 256 --crop_size 256 --preprocess rotate_and_crop

train with Pyramid spatial-temporal Attention Module (PAM) method

python ./train.py --save_epoch_freq 1 --angle 15 --dataroot path-to-LEVIR-CD-train --val_dataroot path-to-LEVIR-CD-val --name LEVIR-CDFAp0 --lr 0.001 --model --SA_mode PAM CDFA --batch_size 8 --load_size 256 --crop_size 256 --preprocess rotate_and_crop

Test

You could edit the file val.py, for example:

if __name__ == '__main__':
    opt = TestOptions().parse()   # get training options
    opt = make_val_opt(opt)
    opt.phase = 'test'
    opt.dataroot = 'path-to-LEVIR-CD-test' # data root 
    opt.dataset_mode = 'changedetection'
    opt.n_class = 2
    opt.SA_mode = 'PAM' # BAM | PAM 
    opt.arch = 'mynet3'
    opt.model = 'CDFA' # model type
    opt.name = 'LEVIR-CDFAp0' # project name
    opt.results_dir = './results/' # save predicted images 
    opt.epoch = 'best-epoch-in-val' # which epoch to test
    opt.num_test = np.inf
    val(opt)

then run the script: python val.py. Once finished, you can find the prediction log file in the project directory and predicted image files in the result directory.

Using other dataset mode

List mode

list=train
lr=0.001
dataset_mode=list
dataroot=path-to-dataroot
name=project_name

python ./train.py --num_threads 4 --display_id 0 --dataroot ${dataroot} --val_dataroot ${dataroot} --save_epoch_freq 1 --niter 100 --angle 15 --niter_decay 100  --display_env FAp0 --SA_mode PAM --name $name --lr $lr --model CDFA --batch_size 4 --dataset_mode $dataset_mode --val_dataset_mode $dataset_mode --split $list --load_size 256 --crop_size 256 --preprocess resize_rotate_and_crop

In this case, the data structure should be the following:

"""
data structure
-dataroot
    ├─A
        ├─train1.png
        ...
    ├─B
        ├─train1.png
        ...
    ├─label
        ├─train1.png
        ...
    └─list
        ├─val.txt
        ├─test.txt
        └─train.txt

# In list/train.txt, each low writes the filename of each sample,
   # for example:
       list/train.txt
           train1.png
           train2.png
           ...
"""

Concat mode for loading multiple datasets (each default mode is List)

list=train
lr=0.001
dataset_type=CD_data1,CD_data2,...,
val_dataset_type=CD_data
dataset_mode=concat
name=project_name

python ./train.py --num_threads 4 --display_id 0 --dataset_type $dataset_type --val_dataset_type $val_dataset_type --save_epoch_freq 1 --niter 100 --angle 15 --niter_decay 100  --display_env FAp0 --SA_mode PAM --name $name --lr $lr --model CDFA --batch_size 4 --dataset_mode $dataset_mode --val_dataset_mode $dataset_mode --split $list --load_size 256 --crop_size 256 --preprocess resize_rotate_and_crop

Note, in this case, you should modify the get_dataset_info in data/data_config.py to add the corresponding dataset_name and dataroot in it.

if dataset_type == 'LEVIR_CD':
    root = 'path-to-LEVIR_CD-dataroot'
elif ...
# add more dataset ...

Other TIPS

For more Training/Testing guides, you could see the option files in the ./options/ folder.

Citation

If you use this code for your research, please cite our papers.

@Article{rs12101662,
AUTHOR = {Chen, Hao and Shi, Zhenwei},
TITLE = {A Spatial-Temporal Attention-Based Method and a New Dataset for Remote Sensing Image Change Detection},
JOURNAL = {Remote Sensing},
VOLUME = {12},
YEAR = {2020},
NUMBER = {10},
ARTICLE-NUMBER = {1662},
URL = {https://www.mdpi.com/2072-4292/12/10/1662},
ISSN = {2072-4292},
DOI = {10.3390/rs12101662}
}

Acknowledgments

Our code is inspired by pytorch-CycleGAN.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].