Add SVCD configs

own
Bobholamovic 2 years ago
parent 5f353e6c51
commit 7858ac2a68
  1. 9
      examples/rs_research/README.md
  2. 2
      examples/rs_research/configs/levircd/bit.yaml
  3. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter2_gamma01.yaml
  4. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter2_gamma02.yaml
  5. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter2_gamma05.yaml
  6. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter3_gamma01.yaml
  7. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter3_gamma02.yaml
  8. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter3_gamma05.yaml
  9. 2
      examples/rs_research/configs/levircd/custom_model/iterative_bit_iter3_gamma10.yaml
  10. 6
      examples/rs_research/configs/levircd/fc_ef.yaml
  11. 6
      examples/rs_research/configs/levircd/fc_siam_conc.yaml
  12. 6
      examples/rs_research/configs/levircd/fc_siam_diff.yaml
  13. 10
      examples/rs_research/configs/levircd/levircd.yaml
  14. 6
      examples/rs_research/configs/levircd/stanet.yaml
  15. 6
      examples/rs_research/configs/svcd/bit.yaml
  16. 12
      examples/rs_research/configs/svcd/custom_model.yaml
  17. 6
      examples/rs_research/configs/svcd/fc_ef.yaml
  18. 6
      examples/rs_research/configs/svcd/fc_siam_conc.yaml
  19. 6
      examples/rs_research/configs/svcd/fc_siam_diff.yaml
  20. 6
      examples/rs_research/configs/svcd/stanet.yaml
  21. 74
      examples/rs_research/configs/svcd/svcd.yaml
  22. 2
      examples/rs_research/custom_model.py
  23. 4
      examples/rs_research/run_task.py
  24. 18
      examples/rs_research/scripts/run_benchmark.sh
  25. 16
      examples/rs_research/scripts/run_parameter_analysis.sh

@ -110,7 +110,7 @@ class IterativeBIT(nn.Layer):
2. 包含模型整体逻辑结构的最外层模块须用`@attach`装饰; 2. 包含模型整体逻辑结构的最外层模块须用`@attach`装饰;
3. 对于变化检测任务,`forward()`方法除`self`参数外还接受两个参数`t1`、`t2`,分别表示第一时相和第二时相影像。 3. 对于变化检测任务,`forward()`方法除`self`参数外还接受两个参数`t1`、`t2`,分别表示第一时相和第二时相影像。
关于模型定义的更多细节请参考[API文档]()。 关于模型定义的更多细节请参考[文档](https://github.com/PaddlePaddle/PaddleRS/blob/develop/docs/dev/dev_guide.md)。
#### 3.3.2 自定义训练器 #### 3.3.2 自定义训练器
@ -145,7 +145,9 @@ class IterativeBIT(BaseChangeDetector):
2. 与模型一样,训练器也须用`@attach`装饰; 2. 与模型一样,训练器也须用`@attach`装饰;
3. 训练器和模型可以同名。 3. 训练器和模型可以同名。
关于训练器定义的更多细节请参考[API文档]()。 在本案例中,仅仅重写了训练器的`__init__()`方法。在实际科研过程中,可以通过重写`train()`、`evaluate()`、`default_loss()`等方法定制更加复杂的训练、评估策略或更换默认损失函数。
关于训练器的更多细节请参考[API文档](https://github.com/PaddlePaddle/PaddleRS/blob/develop/docs/apis/train.md)。
### 3.4 进行参数分析与消融实验 ### 3.4 进行参数分析与消融实验
@ -187,7 +189,8 @@ PaddleRS提供了,只需要。`attach_tools.Attach`对象自动。
### 5.2 展望 ### 5.2 展望
耗时,模型大小,FLOPs - 本案例对所有参与比较的算法使用了相同的训练超参数,但由于模型之间存在差异,使用统一的超参训练往往难以保证所有模型都能取得较好的效果。在后续工作中,可以对每个对比算法进行调参,使其获得最优精度。
- 在评估算法效果时,仅仅对比了精度指标,而未对耗时、模型大小、FLOPs等指标进行考量。后续应当从精度和性能两个方面对算法进行综合评估。
## 参考文献 ## 参考文献

@ -1,6 +1,6 @@
_base_: ./levircd.yaml _base_: ./levircd.yaml
save_dir: ./exp/bit/ save_dir: ./exp/levircd/bit/
model: !Node model: !Node
type: BIT type: BIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter2_gamma01/ save_dir: ./exp/levircd/custom_model/iter2_gamma01/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter2_gamma02/ save_dir: ./exp/levircd/custom_model/iter2_gamma02/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter2_gamma05/ save_dir: ./exp/levircd/custom_model/iter2_gamma05/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter3_gamma01/ save_dir: ./exp/levircd/custom_model/iter3_gamma01/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter3_gamma02/ save_dir: ./exp/levircd/custom_model/iter3_gamma02/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter3_gamma05/ save_dir: ./exp/levircd/custom_model/iter3_gamma05/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -1,6 +1,6 @@
_base_: ../levircd.yaml _base_: ../levircd.yaml
save_dir: ./exp/custom_model/iter3_gamma10/ save_dir: ./exp/levircd/custom_model/iter3_gamma10/
model: !Node model: !Node
type: IterativeBIT type: IterativeBIT

@ -0,0 +1,6 @@
_base_: ./levircd.yaml
save_dir: ./exp/levircd/fc_ef/
model: !Node
type: FCEarlyFusion

@ -0,0 +1,6 @@
_base_: ./levircd.yaml
save_dir: ./exp/levircd/fc_siam_conc/
model: !Node
type: FCSiamConc

@ -0,0 +1,6 @@
_base_: ./levircd.yaml
save_dir: ./exp/levircd/fc_siam_diff/
model: !Node
type: FCSiamDiff

@ -52,7 +52,7 @@ transforms:
args: ['eval'] args: ['eval']
download_on: False download_on: False
num_epochs: 40 num_epochs: 50
train_batch_size: 8 train_batch_size: 8
optimizer: !Node optimizer: !Node
type: Adam type: Adam
@ -62,11 +62,11 @@ optimizer: !Node
module: paddle.optimizer.lr module: paddle.optimizer.lr
args: args:
learning_rate: 0.002 learning_rate: 0.002
step_size: 30 step_size: 35000
gamma: 0.2 gamma: 0.2
save_interval_epochs: 10 save_interval_epochs: 5
log_interval_steps: 500 log_interval_steps: 50
save_dir: ./exp/ save_dir: ./exp/levircd/
learning_rate: 0.002 learning_rate: 0.002
early_stop: False early_stop: False
early_stop_patience: 5 early_stop_patience: 5

@ -0,0 +1,6 @@
_base_: ./levircd.yaml
save_dir: ./exp/levircd/stanet/
model: !Node
type: STANet

@ -0,0 +1,6 @@
_base_: ./svcd.yaml
save_dir: ./exp/svcd/bit/
model: !Node
type: BIT

@ -0,0 +1,12 @@
_base_: ./svcd.yaml
save_dir: ./exp/svcd/custom_model/
model: !Node
type: IterativeBIT
args:
num_iters: 3
gamma: 0.5
num_classes: 2
bit_kwargs:
in_channels: 4

@ -0,0 +1,6 @@
_base_: ./svcd.yaml
save_dir: ./exp/svcd/fc_ef/
model: !Node
type: FCEarlyFusion

@ -0,0 +1,6 @@
_base_: ./svcd.yaml
save_dir: ./exp/svcd/fc_siam_conc/
model: !Node
type: FCSiamConc

@ -0,0 +1,6 @@
_base_: ./svcd.yaml
save_dir: ./exp/svcd/fc_siam_diff/
model: !Node
type: FCSiamDiff

@ -0,0 +1,6 @@
_base_: ./svcd.yaml
save_dir: ./exp/svcd/stanet/
model: !Node
type: STANet

@ -0,0 +1,74 @@
# Basic configurations of SVCD dataset
datasets:
train: !Node
type: CDDataset
args:
data_dir: ./data/svcd/
file_list: ./data/svcd/train.txt
label_list: null
num_workers: 2
shuffle: True
with_seg_labels: False
binarize_labels: True
eval: !Node
type: CDDataset
args:
data_dir: ./data/svcd/
file_list: ./data/svcd/val.txt
label_list: null
num_workers: 0
shuffle: False
with_seg_labels: False
binarize_labels: True
transforms:
train:
- !Node
type: DecodeImg
- !Node
type: RandomFlipOrRotate
args:
probs: [0.35, 0.35]
probsf: [0.5, 0.5, 0, 0, 0]
probsr: [0.33, 0.34, 0.33]
- !Node
type: Normalize
args:
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
- !Node
type: ArrangeChangeDetector
args: ['train']
eval:
- !Node
type: DecodeImg
- !Node
type: Normalize
args:
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
- !Node
type: ArrangeChangeDetector
args: ['eval']
download_on: False
num_epochs: 200
train_batch_size: 8
optimizer: !Node
type: Adam
args:
learning_rate: !Node
type: StepDecay
module: paddle.optimizer.lr
args:
learning_rate: 0.0004
step_size: 87500
gamma: 0.1
save_interval_epochs: 20
log_interval_steps: 50
save_dir: ./exp/
learning_rate: 0.0004
early_stop: False
early_stop_patience: 5
use_vdl: True
resume_checkpoint: ''

@ -45,7 +45,7 @@ class IterativeBIT(nn.Layer):
return logits_list return logits_list
def _constr_iter_input(self, im, rate_map): def _constr_iter_input(self, im, rate_map):
return paddle.concat([im.rate_map], axis=1) return paddle.concat([im, rate_map], axis=1)
def _init_rate_map(self, im_shape): def _init_rate_map(self, im_shape):
b, _, h, w = im_shape b, _, h, w = im_shape

@ -2,6 +2,10 @@
import os import os
# Import cv2 and sklearn before paddlers to solve the
# "ImportError: dlopen: cannot load any more object with static TLS" issue.
import cv2
import sklearn
import paddle import paddle
import paddlers import paddlers
from paddlers import transforms as T from paddlers import transforms as T

@ -0,0 +1,18 @@
#!/bin/bash
set -e
for dataset in levircd svcd; do
config_dir="configs/${dataset}"
log_dir="exp/logs/${dataset}"
mkdir -p "${log_dir}"
for config_file in $(ls ${config_dir}); do
printf '=%.0s' {1..100} && echo
echo -e "\033[33m ${config_file} \033[0m"
printf '=%.0s' {1..100} && echo
python run_task.py train cd --config "${config_dir}/${config_file}" 2>&1 | tee "${log_dir}/${config_file%.*}"
echo
done
done

@ -0,0 +1,16 @@
#!/bin/bash
set -e
CONFIG_DIR='configs/levircd/custom_model'
LOG_DIR='exp/logs/parameter_analysis'
mkdir -p "${LOG_DIR}"
for config_file in $(ls ${CONFIG_DIR}); do
printf '=%.0s' {1..100} && echo
echo -e "\033[33m ${config_file} \033[0m"
printf '=%.0s' {1..100} && echo
python run_task.py train cd --config "${CONFIG_DIR}/${config_file}" 2>&1 | tee "${LOG_DIR}/${config_file%.*}"
echo
done
Loading…
Cancel
Save