File size: 4,368 Bytes
50754c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f83c59
 
 
 
 
50754c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19cdfd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de279d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
## πŸ› οΈ Requirements

### Environment
- **Linux system**, Windows is not tested, depending on whether and can be installed `causal-conv1d` and `mamba-ssm`
- **Python** 3.8+, recommended 3.10
- **PyTorch** 2.0 or higher, recommended 2.1.0
- **CUDA** 11.7 or higher, recommended 12.1

### Environment Installation

It is recommended to use Miniconda for installation. The following commands will create a virtual environment named `stnr` and install PyTorch. In the following installation steps, the default installed CUDA version is 12.1. If your CUDA version is not 12.1, please modify it according to the actual situation.

```bash
# Create conda environment
conda create -n stnr python=3.8 -y
conda activate stnr

# Install PyTorch
pip install torch==2.1.0 torchvision==0.14.0 torchaudio==0.13.0

# Install dependencies
pip install causal_conv1d mamba_ssm packaging
pip install timm==0.4.12
pip install pytest chardet yacs termcolor
pip install submitit tensorboardX
pip install triton==2.0.0

# Or simply run
pip install -r requirements.txt
```

## πŸ“ Dataset Preparation

We evaluate our method on five remote sensing change detection datasets: **WHU-CD**, **LEVIR-CD**, **LEVIR-CD+**, **SYSU-CD**, and **SVCD**.

| Dataset | Link |
|---------|------|
| WHU-CD | [Download](https://aistudio.baidu.com/datasetdetail/251669) |
| LEVIR-CD | [Download](https://opendatalab.org.cn/OpenDataLab/LEVIR-CD) |
| LEVIR-CD+ | [Download](https://www.cvmart.net/dataSets/detail/1385) |
| SYSU-CD | [Download](https://mail2sysueducn-my.sharepoint.com/personal/liumx23_mail2_sysu_edu_cn/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fliumx23%5Fmail2%5Fsysu%5Fedu%5Fcn%2FDocuments%2FSYSU%2DCD&ga=1) |
| SVCD | [Download](https://aistudio.baidu.com/datasetdetail/78676) |

Please organize the datasets as follows:

```
${DATASET_ROOT} # Dataset root directory, for example: /home/username/data/LEVIR-CD
β”œβ”€β”€ A
β”‚   β”œβ”€β”€ train_1_1.png
β”‚   β”œβ”€β”€ train_1_2.png
β”‚   β”œβ”€β”€...
β”‚   β”œβ”€β”€ val_1_1.png
β”‚   β”œβ”€β”€ val_1_2.png
β”‚   β”œβ”€β”€...
β”‚   β”œβ”€β”€ test_1_1.png
β”‚   β”œβ”€β”€ test_1_2.png
β”‚   └── ...
β”œβ”€β”€ B
β”‚   β”œβ”€β”€ train_1_1.png
β”‚   β”œβ”€β”€ train_1_2.png
β”‚   β”œβ”€β”€...
β”‚   β”œβ”€β”€ val_1_1.png
β”‚   β”œβ”€β”€ val_1_2.png
β”‚   β”œβ”€β”€...
β”‚   β”œβ”€β”€ test_1_1.png
β”‚   β”œβ”€β”€ test_1_2.png
β”‚   └── ...
β”œβ”€β”€ label
β”‚   β”œβ”€β”€ train_1_1.png
β”‚   β”œβ”€β”€ train_1_2.png
β”‚   β”œβ”€β”€...
β”‚   β”œβ”€β”€ val_1_1.png
β”‚   β”œβ”€β”€ val_1_2.png
β”‚   β”œβ”€β”€...
β”‚   β”œβ”€β”€ test_1_1.png
β”‚   β”œβ”€β”€ test_1_2.png
β”‚   └── ...
β”œβ”€β”€ list
β”‚   β”œβ”€β”€ train.txt
β”‚   β”œβ”€β”€ val.txt
β”‚   └── test.txt
```


## πŸ”§ Model Training and Testing

All configuration for model training and testing is stored in the local folder `config`. Below are the example commands to train and test the model on the **LEVIR-CD** dataset.

### Example of Training on LEVIR-CD Dataset

```bash
python train_cd.py --config/levir/levir.json
```

### Example of Training on LEVIR-CD Dataset

```bash
python test_cd.py --config/levir/levir_test.json
```

## πŸ“‚ Project Structure

```
STNR-Det/
β”œβ”€β”€ config/          # Configuration files for training/testing
β”‚ β”œβ”€β”€ levir_cd_mamba.json
β”‚ β”œβ”€β”€ levir_test_cd_mamba.json
β”‚ └── ...
β”œβ”€β”€ core/            # Core functionality (e.g., models, loss functions)
β”‚ └── ...
β”œβ”€β”€ data/            # Data loading and preprocessing scripts
β”‚ └── ...
β”œβ”€β”€ misc/            # Miscellaneous utility scripts
β”‚ └── ...
β”œβ”€β”€ models/          # Model architectures and components
β”‚ └── ...
β”œβ”€β”€ .gitattributes   # Git attributes for version control
β”œβ”€β”€ README.md        # Project README (this file)
β”œβ”€β”€ requirement.txt  # Python package dependencies
β”œβ”€β”€ test_cd.py       # Testing script for the model
└── train_cd.py      # Training script for the model
```

## πŸ™ Acknowledgement

We sincerely thank the following works for their contributions:

- [CDMamba](https://github.com/zmoka-zht/CDMamba) – A state-of-the-art method for remote sensing change detection that inspired and influenced parts of this work.
- [MambaDFuse](https://github.com/Lizhe1228/MambaDFuse) – A valuable method for feature fusion that informed our approach.