Git Product home page Git Product logo

open-cd's Introduction

Introduction

Open-CD is an open source change detection toolbox based on a series of open source general vision task tools.

News

  • 6/29/2024 - ChangeStar and FarSeg are supported.
  • 6/20/2024 - We launch the Open-CD Technical Report Plan, don't hesitate to join us!!! 💥💥💥
  • 6/17/2024 - CGNet is supported.
  • 2/10/2024 - Open-CD is upgraded to v1.1.0. BAN, TTP and LightCDNet is supported. The inference API is added.
  • 4/21/2023 - Open-CD v1.0.0 is released in 1.x branch, based on OpenMMLab 2.0 ! PyTorch 2.0 is also supported ! Enjoy it !
  • 3/14/2023 - Open-CD is upgraded to v0.0.3. Semantic Change Detection (SCD) is supported !
  • 11/17/2022 - Open-CD is upgraded to v0.0.2, requiring a higher version of the MMSegmentation dependency.
  • 9/28/2022 - The code, pre-trained models and logs of ChangerEx are available. 😋
  • 9/20/2022 - Our paper Changer: Feature Interaction is What You Need for Change Detection is available!
  • 7/30/2022 - Open-CD is publicly available!

Benchmark and model zoo

Supported toolboxes:

Supported change detection model: (The code of some models are borrowed directly from their official repositories.)

Supported datasets: | Descriptions

Usage

Docs

Please refer to get_started.md in mmseg.

A Colab tutorial is also provided. You may directly run on Colab. (thanks to @Agustin for this demo) Colab

Install

# Install OpenMMLab Toolkits as Python packages
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.0"
mim install "mmpretrain>=1.0.0rc7"
pip install "mmsegmentation>=1.2.2"
pip install "mmdet>=3.0.0"
git clone https://github.com/likyoo/open-cd.git
cd open-cd
pip install -v -e .

For more details, please see here.

Train

python tools/train.py configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir

Test

# get .png results
python tools/test.py configs/changer/changer_ex_r18_512x512_40k_levircd.py changer_r18_levir_workdir/latest.pth --show-dir tmp_infer
# get metrics
python tools/test.py configs/changer/changer_ex_r18_512x512_40k_levircd.py changer_r18_levir_workdir/latest.pth

Infer

Please refer inference doc.

Citation

If you find this project useful in your research, please consider cite:

@ARTICLE{10438490,
  author={Li, Kaiyu and Cao, Xiangyong and Meng, Deyu},
  journal={IEEE Transactions on Geoscience and Remote Sensing}, 
  title={A New Learning Paradigm for Foundation Model-based Remote Sensing Change Detection}, 
  year={2024},
  volume={},
  number={},
  pages={1-1},
  keywords={Adaptation models;Task analysis;Data models;Computational modeling;Feature extraction;Transformers;Tuning;Change detection;foundation model;visual tuning;remote sensing image processing;deep learning},
  doi={10.1109/TGRS.2024.3365825}}

@ARTICLE{10129139,
  author={Fang, Sheng and Li, Kaiyu and Li, Zhe},
  journal={IEEE Transactions on Geoscience and Remote Sensing}, 
  title={Changer: Feature Interaction is What You Need for Change Detection}, 
  year={2023},
  volume={61},
  number={},
  pages={1-11},
  doi={10.1109/TGRS.2023.3277496}}

License

Open-CD is released under the Apache 2.0 license.

open-cd's People

Contributors

greatv avatar likyoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

open-cd's Issues

Error running inference

I just followed the steps for Usage, but get this error when running this command. How to solve it?

python3 tools/test.py configs/changer/changer_ex_r18_512x512_40k_levircd.py changer_r18_levir_workdir/latest.pth --show-dir tmp_infer

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 122, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
  File "/mnt/d/Userdata/user/Downloads/open-cd/opencd/datasets/levir_cd.py", line 18, in __init__
    super().__init__(
  File "/mnt/d/Userdata/user/Downloads/open-cd/opencd/datasets/basecddataset.py", line 141, in __init__
    self.full_init()
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/dataset/base_dataset.py", line 296, in full_init
    self.data_list = self.load_data_list()
  File "/mnt/d/Userdata/user/Downloads/open-cd/opencd/datasets/basecddataset.py", line 269, in load_data_list
    assert sorted(list(file_list_from)) == sorted(list(file_list_to)), \
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/fileio/io.py", line 760, in list_dir_or_file
    yield from backend.list_dir_or_file(dir_path, list_dir, list_file, suffix,
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/fileio/backends/local_backend.py", line 527, in _list_dir_or_file
    for entry in os.scandir(dir_path):
FileNotFoundError: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 122, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/runner/loops.py", line 410, in __init__
    super().__init__(runner, dataloader)
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/runner/base_loop.py", line 26, in __init__
    self.dataloader = runner.build_dataloader(
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1351, in build_dataloader
    dataset = DATASETS.build(dataset_cfg)
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 144, in build_from_cfg
    raise type(e)(
FileNotFoundError: class `LEVIR_CD_Dataset` in opencd/datasets/levir_cd.py: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/d/Userdata/user/Downloads/open-cd/tools/test.py", line 114, in <module>
    main()
  File "/mnt/d/Userdata/user/Downloads/open-cd/tools/test.py", line 110, in main
    runner.test()
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1774, in test
    self._test_loop = self.build_test_loop(self._test_loop)  # type: ignore
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1577, in build_test_loop
    loop = LOOPS.build(
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/home/user/.local/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 144, in build_from_cfg
    raise type(e)(
FileNotFoundError: class `TestLoop` in mmengine/runner/loops.py: class `LEVIR_CD_Dataset` in opencd/datasets/levir_cd.py: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'

No module named 'mmcv'

Hey I'm getting this error on running infer command:

Traceback (most recent call last):
  File "tools/test.py", line 10, in <module>
    import mmcv
ModuleNotFoundError: No module named 'mmcv'

and when i'm install mmcv, i'm getting this error

Collecting mmcv
  Using cached mmcv-2.0.0.tar.gz (473 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/ff/1k6ltqsd42gb85qy9gx5jvyr0000gn/T/pip-install-z3afg0xg/mmcv_5de6ac3785ee44dd94dd614be11c4631/setup.py", line 10, in <module>
          import torch
        File "/Users/sushantmishra/miniconda3/envs/changeDetection/lib/python3.8/site-packages/torch/__init__.py", line 1146, in <module>
          _C._initExtension(manager_path())
        File "/Users/sushantmishra/miniconda3/envs/changeDetection/lib/python3.8/site-packages/torch/cuda/__init__.py", line 15, in <module>
          from . import profiler
        File "/Users/sushantmishra/miniconda3/envs/changeDetection/lib/python3.8/site-packages/torch/cuda/profiler.py", line 3, in <module>
          from . import cudart, check_error
      ImportError: cannot import name 'cudart' from partially initialized module 'torch.cuda' (most likely due to a circular import) (/Users/sushantmishra/miniconda3/envs/changeDetection/lib/python3.8/site-packages/torch/cuda/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

System : MacOS 13.3.1 (chip M1)

请问怎么利用cutmix和mixup

请问如何在模型的data_preprocessor利用cutmix或者mixup,对应参数应该如何填写?dict(type='Cutmix')这样写好像会报错
屏幕截图 2023-04-25 180118

Questions about api

Thanks for your work!

I am wondering are there any apis like mmseg.apis such as below

from mmseg.apis import inference_segmentor, init_segmentor
import mmcv

config_file = 'pspnet_r50-d8_512x1024_40k_cityscapes.py'
checkpoint_file = 'pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'

# build the model from a config file and a checkpoint file
model = init_segmentor(config_file, checkpoint_file, device='cuda:0')

# test a single image and show the results
img = 'test.jpg'  # or img = mmcv.imread(img), which will only load it once
result = inference_segmentor(model, img)
# visualize the results in a new window
model.show_result(img, result, show=True)
# or save the visualization results to image files
# you can change the opacity of the painted segmentation map in (0, 1].
model.show_result(img, result, out_file='result.jpg', opacity=0.5)

# test a video and show the results
video = mmcv.VideoReader('video.mp4')
for frame in video:
   result = inference_segmentor(model, frame)
   model.show_result(frame, result, wait_time=1)

so that I can use inference_detector to detector the change between two images?

It will be more convenient with both api and command line, I think.

作者您好,我在运行最新版本代码的训练命令时,代码出现如下报错,想请问作者解决方法?十分感谢

04/22 04:30:00 - mmengine - WARNING - Failed to import None.registry make sure the registry.py exists in None package.
04/22 04:30:00 - mmengine - WARNING - Failed to search registry with scope "opencd" in the "visualizer" registry tree. As a workaround, the current "visualizer" registry in "mmengine" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "opencd" is a correct scope, or whether the registry is initialized.
Traceback (most recent call last):
File "/remote-home/clwei/WCL/open-cd-1.x/tools/train.py", line 105, in
main()
File "/remote-home/clwei/WCL/open-cd-1.x/tools/train.py", line 94, in main
runner = Runner.from_cfg(cfg)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/runner.py", line 439, in from_cfg
runner = cls(
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/runner.py", line 393, in init
self.visualizer = self.build_visualizer(visualizer)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/runner.py", line 780, in build_visualizer
return VISUALIZERS.build(visualizer)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/registry/registry.py", line 545, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
raise KeyError(
KeyError: 'CDLocalVisualizer is not in the visualizer registry. Please check whether the value of CDLocalVisualizer is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

train问题

作者你好,请问你这个模型训练集和测试集是放在一起训练的吗,为什么我用你的代码跑出来的结果和你差距很大。
D9_))8TA51CY0C`N}L$L0M9

ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils'

Hello

I'm trying to do the training on a Colab notebook, the link is: this

On this notebook I am running the following commands:

!pip3 install -U openmim
!mim install mmengine
!mim install "mmcv>=2.0.0"
!mim install "mmpretrain>=1.0.0rc6"
!pip install "mmsegmentation>=1.0.0"
!pip install "mmdet>=3.0.0"

Followed by:

%cd /content/
!git clone https://github.com/likyoo/open-cd.git
%cd open-cd
!pip install -v -e .

Then:

!python tools/train.py configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir --gpu-id 0 --seed 307

And get this error:

Traceback (most recent call last):
  File "/content/open-cd/tools/train.py", line 13, in <module>
    from mmcv.cnn.utils import revert_sync_batchnorm
ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/usr/local/lib/python3.9/dist-packages/mmcv/cnn/utils/__init__.py)

I read the documentation, open and closed issues of mmsegmentation and mmcv and i couldn't find anything related to this error.

Should I open an issue in the mmcv repository? Or could you guide me where to look for the solution?

From already thank you very much!

Problems in training stage

Hello,
I'm trying to train the model, and I'm having some errors.
I listed each of the tests I ran, the commands that were run on each one, and the output from these.
I'm running each test in a clean environment, on a Google Colab notebook.

1:

> git clone https://github.com/likyoo/open-cd.git
> cd open-cd
> pip install -v -e .
> python3 tools/train.py configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir --gpu-id 0 --seed 307
Traceback (most recent call last):
File "/content/tools/train.py", line 10, in <module> import mmcv
ModuleNotFoundError: No module named 'mmcv'

2:

> git clone https://github.com/likyoo/open-cd.git
> cd open-cd
> pip install -v -e .
> cat /requirements/mminstall.txt
mmcls>=0.20.1
mmcv-full>=1.5.0,<=1.7.0

> pip install -r ./requirements/mminstall.txt
> python3 tools/train.py  configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir --gpu-id 0 --seed 307
AssertionError: MMCV==1.7.0 is used but incompatible. Please install mmcv>=2.0.0rc4.

3:

> git clone https://github.com/likyoo/open-cd.git
> cd open-cd
> pip install -v -e .
> pip install mmcv==2.0.0rc4
> python3 tools/train.py  configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir --gpu-id 0 --seed 307
Traceback (most recent call last):
File "/content/tools/train.py", line 13, in <module> from mmcv.cnn.utils import revert_sync_batchnorm
ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/usr/local/lib/python3.9/dist-packages/mmcv/cnn/utils/__init__.py)

4:

> git clone https://github.com/likyoo/open-cd.git
> cd open-cd
> pip install -v -e .
> pip install mmcv
> python3 tools/train.py  configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir --gpu-id 0 --seed 307
Traceback (most recent call last):
File "/content/tools/train.py", line 13, in <module> from mmcv.cnn.utils import revert_sync_batchnorm
ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/usr/local/lib/python3.9/dist-packages/mmcv/cnn/utils/__init__.py)

I would appreciate any help!

Greetings!

[Question] Is the metric calculated based on the validation set or on the test set?

Hi, Changer is an awesome work with a novel idea, and the experiments are elaborative. I found it really helpful to me.

Observed from the log, it seems that the F1-score of 92.33 reported here (and also in the paper) was calculated with the validation data. I wonder if it is the expected experimental setup and desired behavior, given that the F1-score calculated on the validation set is usually higher than that calculated on the test set, and most paper have reported the test set scores.

Update: I have computed the F1-score on the test set of this model using the tools/test.py script introduced in README. The F1-score of change class was about 1% lower than 92.33%.

Running Inference Using Trained Model

Hi all,

So I've trained a couple of models and I was wondering how I can run inference on a different data (that don't have labels) without using the tools/test.py script. An example would be really helpful.

Thank you.

Error using 4-band images

Hello!

I'm trying to train the models with a dataset that has 4 bands: Red, Green, Blue, Near-Infrared.

I've tried a .tiff file format and also a .png format. The training in both cases seems to work, the validation iterations return reasonable metrics. So I assume that the .pth file is completely valid, the error I get is when executing the test, it cannot draw the mask resulting from the prediction.

Tiff format training and testing notebook
Png format training and testing notebook

The error I get is

Traceback (most recent call last):
  File "/content/open-cd/tools/test.py", line 114, in <module>
    main()
  File "/content/open-cd/tools/test.py", line 110, in main
    runner.test()
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/runner.py", line 1791, in test
    metrics = self.test_loop.run()  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/loops.py", line 435, in run
    self.run_iter(idx, data_batch)
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/loops.py", line 456, in run_iter
    self.runner.call_hook(
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/runner.py", line 1807, in call_hook
    getattr(hook, fn_name)(self, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/hooks/hook.py", line 277, in after_test_iter
    self._after_iter(
  File "/content/open-cd/opencd/engine/hooks/visualization_hook.py", line 106, in _after_iter
    self._visualizer.add_datasample(
  File "/usr/local/lib/python3.10/dist-packages/mmengine/dist/utils.py", line 401, in wrapper
    return func(*args, **kwargs)
  File "/content/open-cd/opencd/visualization/cd_local_visualizer.py", line 112, in add_datasample
    pred_img_data = self._draw_sem_seg(pred_img_data,
  File "/usr/local/lib/python3.10/dist-packages/mmseg/visualization/local_visualizer.py", line 115, in _draw_sem_seg
    self.draw_binary_masks(
  File "/usr/local/lib/python3.10/dist-packages/mmengine/dist/utils.py", line 401, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/visualization/visualizer.py", line 894, in draw_binary_masks
    assert len(color) == 3
AssertionError

Thank you very much in advance

BIT Model, Stages of Pretrained Backbone

Hello! I'm trying to understand the paper of each of the models, and also how you implemented it with the configuration files. That's why I want to ask you a question

In the paper [1], In section III. EFFICIENT TRANSFORMER BASED CHANGE DETECTION MODEL, in D. Network Details.

It says: "The original ResNet18 has 5 stages, each with downsampling by 2. We replace the stride of the last two stages to 1 and add a point-wise convolution (...)"

In this line of the configuration file you define 'num_stages=3' and 'strides=(1, 2, 1)'.

Shouldn't you define 'num_stages=5' and 'strides=(1, 2, 1, 1, 1)' to do it according to the paper?

[1] Chen, H., Qi, Z., & Shi, Z. (2021). Remote sensing image change detection with transformers. IEEE Transactions on Geoscience and Remote Sensing, 60, 1-14.

Thanks!!

语义变化检测模型

大佬你好,二分类变化检测模型是否都可以改造为语义变化检测模型?

关于交换顺序的数据增强方式

请问您是否进行过交换双时相影像顺序的效果对比。此外对于论文复现实验中的各项超参数是按照原论文指定的吗,还是根据本论文的超参数统一配置(我注意到open-cd中Changeformer的初始学习率似乎不同)。

CDD dataset and resuming training

Hello, I am starting a research project related to change detection in Argentina.

I would appreciate if you answer these two questions.

Do you support CDD dataset?
Because I want to test the efficiency and effectiveness of OpenCD against this model: https://github.com/qaz670756/LSNet

Do you support resuming training from a checkpoint?
Because I want to carry out the training using google colab and it is a quite interrupted environment, for which I need to be able to resume the training through the persistence of partial states, epochs or checkpoints.

Thanks since now!

Welcome update to OpenMMLab 2.0

Welcome update to OpenMMLab 2.0

I am Vansin, the technical operator of OpenMMLab. In September of last year, we announced the release of OpenMMLab 2.0 at the World Artificial Intelligence Conference in Shanghai. We invite you to upgrade your algorithm library to OpenMMLab 2.0 using MMEngine, which can be used for both research and commercial purposes. If you have any questions, please feel free to join us on the OpenMMLab Discord at https://discord.gg/amFNsyUBvm or add me on WeChat (van-sin) and I will invite you to the OpenMMLab WeChat group.

Here are the OpenMMLab 2.0 repos branches:

OpenMMLab 1.0 branch OpenMMLab 2.0 branch
MMEngine 0.x
MMCV 1.x 2.x
MMDetection 0.x 、1.x、2.x 3.x
MMAction2 0.x 1.x
MMClassification 0.x 1.x
MMSegmentation 0.x 1.x
MMDetection3D 0.x 1.x
MMEditing 0.x 1.x
MMPose 0.x 1.x
MMDeploy 0.x 1.x
MMTracking 0.x 1.x
MMOCR 0.x 1.x
MMRazor 0.x 1.x
MMSelfSup 0.x 1.x
MMRotate 1.x 1.x
MMYOLO 0.x

Attention: please create a new virtual environment for OpenMMLab 2.0.

About patch_size in changer

hi, i found something interesting about Changer when i repeat the exp on another dataset.
In Changer, it seems that H and W of the feature map is very smaller than original image. (patch_sziepatch_patch -> 11) it's surprising that the model have the potential to segement very fine boundary in spatial. What's more, transformer itself makes spatial exchange in every layer so, may,it's no need to add Spatial Exchange layer.

by the way. A pure torch version (i mean code on pure torch) could be nice. i hate mm like codes which make things unclear. haha

Bug in TinyCD_V2 and GPU usage question

Hello!

I have a possible bug, and a question to ask.

Starting with the bug, I think tinycd_v2 is not working.
I am in a Google Colab environment, using OpenCD 1.x, the steps I am following are:

  • Install dependencies
  • Clone the repository
  • I download the LEVIR-CD dataset
  • I run the training
!python3 tools/train.py configs/tinycd_v2/tinycd_v2_s_256x256_40k_levircd.py --work-dir ./tinycd_v2_s_levir_workdir

or

!python3 tools/train.py configs/tinycd_v2/tinycd_v2_b_256x256_40k_levircd.py  --work-dir ./tinycd_v2_b_levir_workdir

or

!python3 tools/train.py configs/tinycd_v2/tinycd_v2_l_256x256_40k_levircd.py  --work-dir ./tinycd_v2_l_levir_workdir

And in all three cases I get the same errors:

KeyError: 'Cannot find None in registry under scope name opencd'
...
KeyError: "class `TinyNet` in opencd/models/backbones/tinynet.py: 'Cannot find None in registry under scope name opencd'"
...
KeyError: 'class `DIEncoderDecoder` in opencd/models/change_detectors/dual_input_encoder_decoder.py: "class `TinyNet` in opencd/models/backbones/tinynet.py: \'Cannot find None in registry under scope name opencd\'"'

Complete output files:
error_tinycd_v2_b_256x256_40k_levircd.txt
error_tinycd_v2_l_256x256_40k_levircd.txt
error_tinycd_v2_s_256x256_40k_levircd.txt

It should be noted that if I change the training line to any of the following configurations, which also use the LEVIR-CD dataset, it works perfectly, and the training begins:

!python3 tools/train.py configs/tinycd/tinycd_256x256_40k_levircd.py --work-dir ./tinycd_v1_levir_workdir
!python3 tools/train.py configs/bit/bit_r18_256x256_40k_levircd.py --work-dir ./bit_levir_workdir
!python tools/train.py configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir 
!python tools/train.py configs/snunet/snunet_c16_256x256_40k_levircd.py --work-dir ./snunet_c16_levir_workdir

And this gives me the opportunity to ask the question that I wanted to ask. During the training of these last configurations, they only use 5GB of the 15GB that I have available from the CPU in Colab. Is it possible to modify some parameter so that they take advantage of 100% of the board?

Thank you very much

assert pred.size() == target.size() and target.numel() > 0

When I used the data set LEVIR-CD to train the STANet network, the following error occurred---assert pred.size() == target.size() and target.numel() > 0. The preliminary analysis was caused by the inconsistency of the dimensions of pred and target. The debugging found that the dimension of pred is torch. Size ([8, 256, 256, 256]), while the dimension of target is torch. Size ([8, 256, 256]). How do I need to modify the code? Thank you for your guidance and look forward to your reply。。
image

无法复现文章精度

作者您好,我按照您的参数设置,尝试复现changer_ex_mit-b0_512x512_40k_levircd.py与changer_ex_r18_512x512_40k_levircd.py 的精度,距离文章精度相差0.50与0.7左右,请问我该从哪里来解决问题呢?

Roadmap of Open-CD

If you have any suggested methods or features, please leave a comment below.

Can't reproduce the results of configs/changer/changer_ex_mit-b0_512x512_40k_levircd.py 84.37VS85.29

My experiment of configs/changer/changer_ex_mit-b0_512x512_40k_levircd.py achieves val/test mIoU 84.83%/84.37%. which significantly below the reported test mIoU 85.29%.

cmds as below:
python tools/train.py configs/changer/changer_ex_mit-b0_512x512_40k_levircd.py --work-dir ./workdir/changer_ex_mit-b0_512x512_40k_levircd
python tools/test.py configs/changer/changer_ex_mit-b0_512x512_40k_levircd.py workdir/changer_mit-b0_levir_workdir/iter_40000.pth

What did I do less?

Can't get anything to work

I'm trying to run the infer script from the "simple usage" section of the documentation, but I keep getting the following error:
"FileNotFoundError: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'". (Full terminal log included below).

For refrence, I'm on an M1 mac and I believe have the correct versions of all of the dependencies installed. I've tried creating a directory named data in the "datasets" directory, and populating it with a copy of the LEVIR-CD dataset I downloaded online. No such luck, even though I can cd into the directory that my computer is convinced doesn't exist. I suspect there's an issue with the file_list_from and file_list_two variables, as printing them both directly gives pointers to the same memory address and trying to print as a list gives the same error. (Short snippet included below, everything else in the error message is the exact same):

File "/Users/cole/Desktop/work/rapid_change_detection/open-cd/opencd/datasets/basecddataset.py", line 269, in load_data_list
print(list(file_list_to)).

I can attach my virtual environment if relevant. Would be extraordinarily grateful for any help anyone could provide, whether a fix for the error or just if anyone has gotten this working on an m1 mac please contact me.

Terminal output attached below
(opencd) cole@MacBook-Pro-6 open-cd % python tools/test.py configs/changer/changer_ex_r18_512x512_40k_levircd.py changer_r18_levir_workdir/latest.pth --show-dir tmp_infer
06/18 21:36:48 - mmengine - INFO -

System environment:
sys.platform: darwin
Python: 3.10.11 | packaged by conda-forge | (main, May 10 2023, 19:01:19) [Clang 14.0.6 ]
CUDA available: False
numpy_random_seed: 1230368365
GCC: Apple clang version 14.0.3 (clang-1403.0.22.14.1)
PyTorch: 2.0.1
PyTorch compiling details: PyTorch built with:

  • GCC 4.2

  • C++ Version: 201703

  • clang 13.1.6

  • LAPACK is enabled (usually provided by MKL)

  • NNPACK is enabled

  • CPU capability usage: NO AVX

  • Build settings: BLAS_INFO=accelerate, BUILD_TYPE=Release, CXX_COMPILER=/Applications/Xcode_13.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_PYTORCH_METAL_EXPORT -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DUSE_COREML_DELEGATE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=braced-scalar-init -Werror=range-loop-construct -Werror=bool-operation -Winconsistent-missing-override -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wvla-extension -Wno-range-loop-analysis -Wno-pass-failed -Wsuggest-override -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wconstant-conversion -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-constexpr-not-const -Wno-missing-braces -Wunused-lambda-capture -Wunused-local-typedef -Qunused-arguments -fcolor-diagnostics -fdiagnostics-color=always -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -DUSE_MPS -fno-objc-arc -Wno-unguarded-availability-new -Wno-unused-private-field -Wno-missing-braces -Wno-constexpr-not-const, LAPACK_INFO=accelerate, TORCH_DISABLE_GPU_ASSERTS=OFF, TORCH_VERSION=2.0.1, USE_CUDA=OFF, USE_CUDNN=OFF, USE_EIGEN_FOR_BLAS=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=OFF, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=OFF, USE_ROCM=OFF,

    TorchVision: 0.15.2
    OpenCV: 4.7.0
    MMEngine: 0.7.4

Runtime environment:
cudnn_benchmark: True
mp_cfg: {'mp_start_method': 'fork', 'opencv_num_threads': 0}
dist_cfg: {'backend': 'nccl'}
seed: 1230368365
Distributed launcher: none
Distributed training: False
GPU number: 1

06/18 21:36:48 - mmengine - INFO - Config:
norm_cfg = dict(type='SyncBN', requires_grad=True)
data_preprocessor = dict(
type='DualInputSegDataPreProcessor',
mean=[123.675, 116.28, 103.53, 123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375, 58.395, 57.12, 57.375],
bgr_to_rgb=True,
size_divisor=32,
pad_val=0,
seg_pad_val=255,
test_cfg=dict(size_divisor=32))
model = dict(
type='DIEncoderDecoder',
data_preprocessor=dict(
type='DualInputSegDataPreProcessor',
mean=[123.675, 116.28, 103.53, 123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375, 58.395, 57.12, 57.375],
bgr_to_rgb=True,
size_divisor=32,
pad_val=0,
seg_pad_val=255,
test_cfg=dict(size_divisor=32)),
pretrained=None,
backbone=dict(
type='IA_ResNetV1c',
depth=18,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 1, 1),
strides=(1, 2, 2, 2),
norm_cfg=dict(type='SyncBN', requires_grad=True),
norm_eval=False,
style='pytorch',
contract_dilation=True,
interaction_cfg=(None, {
'type': 'SpatialExchange',
'p': 0.5
}, {
'type': 'ChannelExchange',
'p': 0.5
}, {
'type': 'ChannelExchange',
'p': 0.5
})),
decode_head=dict(
type='Changer',
in_channels=[64, 128, 256, 512],
in_index=[0, 1, 2, 3],
channels=128,
dropout_ratio=0.1,
num_classes=2,
norm_cfg=dict(type='SyncBN', requires_grad=True),
align_corners=False,
loss_decode=dict(
type='mmseg.CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
sampler=dict(
type='mmseg.OHEMPixelSampler', thresh=0.7, min_kept=100000)),
train_cfg=dict(),
test_cfg=dict(mode='whole'))
default_scope = 'opencd'
env_cfg = dict(
cudnn_benchmark=True,
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
dist_cfg=dict(backend='nccl'))
vis_backends = [dict(type='CDLocalVisBackend')]
visualizer = dict(
type='CDLocalVisualizer',
vis_backends=[dict(type='CDLocalVisBackend')],
name='visualizer',
alpha=1.0,
save_dir='tmp_infer')
log_processor = dict(by_epoch=False)
log_level = 'INFO'
load_from = 'changer_r18_levir_workdir/latest.pth'
resume = False
tta_model = dict(type='mmseg.SegTTAModel')
dataset_type = 'LEVIR_CD_Dataset'
data_root = 'data/LEVIR-CD'
crop_size = (512, 512)
train_pipeline = [
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgLoadAnnotations'),
dict(
type='MultiImgRandomRotFlip',
rotate_prob=0.5,
flip_prob=0.5,
degree=(-20, 20)),
dict(type='MultiImgRandomCrop', crop_size=(512, 512), cat_max_ratio=0.75),
dict(type='MultiImgExchangeTime', prob=0.5),
dict(
type='MultiImgPhotoMetricDistortion',
brightness_delta=10,
contrast_range=(0.8, 1.2),
saturation_range=(0.8, 1.2),
hue_delta=10),
dict(type='MultiImgPackSegInputs')
]
test_pipeline = [
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgResize', scale=(1024, 1024), keep_ratio=True),
dict(type='MultiImgLoadAnnotations'),
dict(type='MultiImgPackSegInputs')
]
img_ratios = [0.75, 1.0, 1.25]
tta_pipeline = [
dict(type='MultiImgLoadImageFromFile', backend_args=None),
dict(
type='TestTimeAug',
transforms=[[{
'type': 'MultiImgResize',
'scale_factor': 0.75,
'keep_ratio': True
}, {
'type': 'MultiImgResize',
'scale_factor': 1.0,
'keep_ratio': True
}, {
'type': 'MultiImgResize',
'scale_factor': 1.25,
'keep_ratio': True
}],
[{
'type': 'MultiImgRandomFlip',
'prob': 0.0,
'direction': 'horizontal'
}, {
'type': 'MultiImgRandomFlip',
'prob': 1.0,
'direction': 'horizontal'
}], [{
'type': 'MultiImgLoadAnnotations'
}], [{
'type': 'MultiImgPackSegInputs'
}]])
]
train_dataloader = dict(
batch_size=8,
num_workers=4,
persistent_workers=True,
sampler=dict(type='InfiniteSampler', shuffle=True),
dataset=dict(
type='LEVIR_CD_Dataset',
data_root='data/LEVIR-CD',
data_prefix=dict(
seg_map_path='train/label',
img_path_from='train/A',
img_path_to='train/B'),
pipeline=[
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgLoadAnnotations'),
dict(
type='MultiImgRandomRotFlip',
rotate_prob=0.5,
flip_prob=0.5,
degree=(-20, 20)),
dict(
type='MultiImgRandomCrop',
crop_size=(512, 512),
cat_max_ratio=0.75),
dict(type='MultiImgExchangeTime', prob=0.5),
dict(
type='MultiImgPhotoMetricDistortion',
brightness_delta=10,
contrast_range=(0.8, 1.2),
saturation_range=(0.8, 1.2),
hue_delta=10),
dict(type='MultiImgPackSegInputs')
]))
val_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='LEVIR_CD_Dataset',
data_root='data/LEVIR-CD',
data_prefix=dict(
seg_map_path='val/label',
img_path_from='val/A',
img_path_to='val/B'),
pipeline=[
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgResize', scale=(1024, 1024), keep_ratio=True),
dict(type='MultiImgLoadAnnotations'),
dict(type='MultiImgPackSegInputs')
]))
test_dataloader = dict(
batch_size=1,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='LEVIR_CD_Dataset',
data_root='data/LEVIR-CD',
data_prefix=dict(
seg_map_path='test/label',
img_path_from='test/A',
img_path_to='test/B'),
pipeline=[
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgResize', scale=(1024, 1024), keep_ratio=True),
dict(type='MultiImgLoadAnnotations'),
dict(type='MultiImgPackSegInputs')
]))
val_evaluator = dict(type='mmseg.IoUMetric', iou_metrics=['mFscore', 'mIoU'])
test_evaluator = dict(type='mmseg.IoUMetric', iou_metrics=['mFscore', 'mIoU'])
optimizer = dict(type='AdamW', lr=0.005, betas=(0.9, 0.999), weight_decay=0.05)
optim_wrapper = dict(
type='OptimWrapper',
optimizer=dict(
type='AdamW', lr=0.005, betas=(0.9, 0.999), weight_decay=0.05))
param_scheduler = [
dict(
type='LinearLR', start_factor=1e-06, by_epoch=False, begin=0,
end=1000),
dict(
type='PolyLR',
power=1.0,
begin=1000,
end=40000,
eta_min=0.0,
by_epoch=False)
]
train_cfg = dict(type='IterBasedTrainLoop', max_iters=40000, val_interval=4000)
val_cfg = dict(type='ValLoop')
test_cfg = dict(type='TestLoop')
default_hooks = dict(
timer=dict(type='IterTimerHook'),
logger=dict(type='LoggerHook', interval=50, log_metric_by_epoch=False),
param_scheduler=dict(type='ParamSchedulerHook'),
checkpoint=dict(
type='CheckpointHook', by_epoch=False, interval=4000,
save_best='mIoU'),
sampler_seed=dict(type='DistSamplerSeedHook'),
visualization=dict(
type='CDVisualizationHook',
interval=1,
img_shape=(1024, 1024, 3),
draw=True))
launcher = 'none'
work_dir = './work_dirs/changer_ex_r18_512x512_40k_levircd'

/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmseg/models/decode_heads/decode_head.py:120: UserWarning: For binary segmentation, we suggest usingout_channels = 1 to define the outputchannels of segmentor, and use thresholdto convert seg_logits into a predictionapplying a threshold
warnings.warn('For binary segmentation, we suggest using'
/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmseg/models/builder.py:36: UserWarning: build_loss would be deprecated soon, please use mmseg.registry.MODELS.build()
warnings.warn('build_loss would be deprecated soon, please use '
/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmseg/models/losses/cross_entropy_loss.py:235: UserWarning: Default avg_non_ignore is False, if you would like to ignore the certain label and average loss over non-ignore labels, which is the same with PyTorch official cross_entropy, set avg_non_ignore=True.
warnings.warn(
/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmseg/structures/sampler/builder.py:11: UserWarning: build_pixel_sampler would be deprecated soon, please use mmseg.registry.TASK_UTILS.build()
warnings.warn(
06/18 21:36:48 - mmengine - INFO - Distributed training is not used, all SyncBatchNorm (SyncBN) layers in the model will be automatically reverted to BatchNormXd layers if they are used.
06/18 21:36:48 - mmengine - INFO - Hooks will be executed in the following order:
before_run:
(VERY_HIGH ) RuntimeInfoHook
(BELOW_NORMAL) LoggerHook

before_train:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(VERY_LOW ) CheckpointHook

before_train_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(NORMAL ) DistSamplerSeedHook

before_train_iter:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook

after_train_iter:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(NORMAL ) CDVisualizationHook
(BELOW_NORMAL) LoggerHook
(LOW ) ParamSchedulerHook
(VERY_LOW ) CheckpointHook

after_train_epoch:
(NORMAL ) IterTimerHook
(LOW ) ParamSchedulerHook
(VERY_LOW ) CheckpointHook

before_val_epoch:
(NORMAL ) IterTimerHook

before_val_iter:
(NORMAL ) IterTimerHook

after_val_iter:
(NORMAL ) IterTimerHook
(NORMAL ) CDVisualizationHook
(BELOW_NORMAL) LoggerHook

after_val_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(BELOW_NORMAL) LoggerHook
(LOW ) ParamSchedulerHook
(VERY_LOW ) CheckpointHook

after_train:
(VERY_LOW ) CheckpointHook

before_test_epoch:
(NORMAL ) IterTimerHook

before_test_iter:
(NORMAL ) IterTimerHook

after_test_iter:
(NORMAL ) IterTimerHook
(NORMAL ) CDVisualizationHook
(BELOW_NORMAL) LoggerHook

after_test_epoch:
(VERY_HIGH ) RuntimeInfoHook
(NORMAL ) IterTimerHook
(BELOW_NORMAL) LoggerHook

after_run:
(BELOW_NORMAL) LoggerHook

Traceback (most recent call last):
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 122, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/Users/cole/Desktop/work/rapid_change_detection/open-cd/opencd/datasets/levir_cd.py", line 18, in init
super().init(
File "/Users/cole/Desktop/work/rapid_change_detection/open-cd/opencd/datasets/basecddataset.py", line 141, in init
self.full_init()
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/dataset/base_dataset.py", line 296, in full_init
self.data_list = self.load_data_list()
File "/Users/cole/Desktop/work/rapid_change_detection/open-cd/opencd/datasets/basecddataset.py", line 270, in load_data_list
assert sorted(list(file_list_from)) == sorted(list(file_list_to)),
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/fileio/io.py", line 760, in list_dir_or_file
yield from backend.list_dir_or_file(dir_path, list_dir, list_file, suffix,
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/fileio/backends/local_backend.py", line 527, in _list_dir_or_file
for entry in os.scandir(dir_path):
FileNotFoundError: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 122, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/runner/loops.py", line 410, in init
super().init(runner, dataloader)
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/runner/base_loop.py", line 26, in init
self.dataloader = runner.build_dataloader(
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1346, in build_dataloader
dataset = DATASETS.build(dataset_cfg)
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 144, in build_from_cfg
raise type(e)(
FileNotFoundError: class LEVIR_CD_Dataset in opencd/datasets/levir_cd.py: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/cole/Desktop/work/rapid_change_detection/open-cd/tools/test.py", line 114, in
main()
File "/Users/cole/Desktop/work/rapid_change_detection/open-cd/tools/test.py", line 110, in main
runner.test()
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1760, in test
self._test_loop = self.build_test_loop(self._test_loop) # type: ignore
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/runner/runner.py", line 1563, in build_test_loop
loop = LOOPS.build(
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/opt/homebrew/anaconda3/envs/opencd/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 144, in build_from_cfg
raise type(e)(
FileNotFoundError: class TestLoop in mmengine/runner/loops.py: class LEVIR_CD_Dataset in opencd/datasets/levir_cd.py: [Errno 2] No such file or directory: 'data/LEVIR-CD/test/A'

Changes on reimplementation of changeformer

Hi, thank you for your great work!

I am validating several change detection models with my data. However, when I experimented with the official code, the changeformer didn't learn properly, while the changeformer you provided did. I think there is a difference between learning rate and some augmentation, can you tell me what changed when you reimplemented it?

Thanks!

How to apply this model to large-sized images?

Thank you so much for your remarkable contributions to the field of change detection! I have successfully trained and inferred this model using the provided samples. However, I have a question regarding the inference of changes between two large-sized images, such as high-resolution satellite or aerial images. Could you please advise me on how to apply this model in such cases?

I have previously employed the sliding window strategy, which enabled me to successfully infer changes in a pair of high-resolution aerial images. However, in this particular scenario, all the configurations are written in files, and the training and testing processes are automated using Runner. I have carefully reviewed the mmengine documentation, but I am still a bit confused, especially regarding the adjustment of configurations. Could you kindly provide some guidance and insights? Your assistance is greatly appreciated. Thank you so much!

FC_EF

image
Hello, why is the result accuracy so low when I use the FC_EF network to run the levircd dataset? Do you still need any operation codes

Path not found

I created a new data file on disk D, which contains the data sets train, val and test. Why can't I find this path when running the train module

exhanger window

A worthwhile consideration is whether small exchange patch in spatial exchange would disrupt the original spatial structure. We therefore tried using different window sizes in spatial exchange, from 1 × 1 to 8 × 8, as listed in the Tab. 6. We find that the window size is a robust hyper-parameter and that a more complete original spatial structure does not result in a performance gain.

请问您这里的exhanger window是什么意思呢,代码似乎没这方面体现。

Dataset configuration files 'multiple values for keyword argument'

When trying to use the base configuration for testing the DSIFN dataset I get the following error msg:

TypeError: DSIFN_Dataset: opencd.datasets.custom.CDDataset.init() got multiple values for keyword argument 'seg_map_suffix'

This is due the DSIFN dataset having a .tiff extension on its test annotations instead of .png which would be the default. The configuration is the same as the one used for training, which works totally fine.

This behavior can be appreciated when trying to test with both changerex and changeformer architectures, so I understand the issue lays in the dataset.

Is there any way of going around this error?.

'LEVIR_CD_Dataset' is not in the dataset registry

When I run tools/test.py, there exists an error?

2023-04-18 16:34:01,005 - mmseg - INFO - Multi-processing start method is `None`
2023-04-18 16:34:01,005 - mmseg - INFO - OpenCV num_threads is `48
Traceback (most recent call last):
  File "/home/user/open-cd/tools/test.py", line 321, in <module>
    main()
  File "/home/user/open-cd/tools/test.py", line 193, in main
    dataset = build_dataset(cfg.data.test)
  File "/home/user/mmsegmentation/mmseg/datasets/builder.py", line 85, in build_dataset
    dataset = build_from_cfg(cfg, DATASETS, default_args)
  File "/home/user/miniconda3/envs/opencd/lib/python3.9/site-packages/mmcv/utils/registry.py", line 61, in build_from_cfg
    raise KeyError(
KeyError: 'LEVIR_CD_Dataset is not in the dataset registry'

I didn't change anything in opencd/datasets/levir_cd.py. How can I fix this error. 😭

Grad-CAM可视化问题

您好,可以向您请教一下有关网络的Grad-cam可视化的问题吗,文章中是如何实现可视化的吗,我找了您发的相关代码,好像里面没有涉及到该内容。

How to obtain the mmsegmentation-pretrained backbone checkpoint?

When add a new config for backbone not exists in current configs, e.g. mit-b2, I can't find the checkpoint url like (from changer_ex_mit-b1_512x512_40k_levircd.py) :
checkpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segformer/mit_b1_20220624-02e5a6a1.pth'

How to obtain the url of mmsegmentation-pretrained backbone checkpoint?

Second数据集

作者你好,我在其他地方下载的Second数据集缺少label,是否可以分享下你训练时的Second数据集。

IndexError: index 10995116278530 is out of bounds for dimension 0 with size 1024

cmd line:

python tools/train.py configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir --gpu-id 0 --seed 307

outputs:

/opt/ias/env/lib/python3.10/site-packages/mmcv/__init__.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
  warnings.warn(
2023-03-19 00:25:25,391 - mmseg - INFO - Multi-processing start method is `None`
2023-03-19 00:25:25,391 - mmseg - INFO - OpenCV num_threads is `16
2023-03-19 00:25:25,412 - mmseg - INFO - Environment info:
------------------------------------------------------------
sys.platform: linux
Python: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
CUDA available: True
GPU 0: NVIDIA GeForce GTX 1080 Ti
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.0, V12.0.76
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
PyTorch: 1.13.1+cu117
PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.7
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  - CuDNN 8.5
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

TorchVision: 0.14.1+cu117
OpenCV: 4.7.0
MMCV: 1.7.1
MMCV Compiler: GCC 9.3
MMCV CUDA Compiler: 11.7
MMSegmentation: 0.30.0+d2030d6
------------------------------------------------------------

...

2023-03-19 02:07:41,947 - mmseg - INFO - Saving checkpoint at 16000 iterations
2023-03-19 02:07:42,176 - mmseg - INFO - Exp name: changer_ex_r18_512x512_40k_levircd.py
2023-03-19 02:07:42,176 - mmseg - INFO - Iter [16000/40000]	lr: 3.000e-03, eta: 2:33:22, time: 0.391, data_time: 0.061, memory: 7901, decode.loss_ce: 0.0224, decode.acc_seg: 99.1084, loss: 0.0224
[                                                  ] 0/64, elapsed: 0s, ETA:
[                                  ] 1/64, 4.9 task/s, elapsed: 0s, ETA:    13s
[>                                 ] 2/64, 7.4 task/s, elapsed: 0s, ETA:     8s
[>                                 ] 3/64, 8.8 task/s, elapsed: 0s, ETA:     7s
[>>                                ] 4/64, 9.8 task/s, elapsed: 0s, ETA:     6s
[>>                               ] 5/64, 10.6 task/s, elapsed: 0s, ETA:     6s
[>>>                              ] 6/64, 11.0 task/s, elapsed: 1s, ETA:     5sTraceback (most recent call last):
  File "/mnt/data/jiang/ml/cd/open-cd/tools/train.py", line 243, in <module>
    main()
  File "/mnt/data/jiang/ml/cd/open-cd/tools/train.py", line 232, in main
    train_segmentor(
  File "/mnt/data/jiang/ml/mm/mmsegmentation/mmseg/apis/train.py", line 194, in train_segmentor
    runner.run(data_loaders, cfg.workflow)
  File "/opt/ias/env/lib/python3.10/site-packages/mmcv/runner/iter_based_runner.py", line 144, in run
    iter_runner(iter_loaders[i], **kwargs)
  File "/opt/ias/env/lib/python3.10/site-packages/mmcv/runner/iter_based_runner.py", line 70, in train
    self.call_hook('after_train_iter')
  File "/opt/ias/env/lib/python3.10/site-packages/mmcv/runner/base_runner.py", line 317, in call_hook
    getattr(hook, fn_name)(self)
  File "/opt/ias/env/lib/python3.10/site-packages/mmcv/runner/hooks/evaluation.py", line 266, in after_train_iter
    self._do_evaluate(runner)
  File "/mnt/data/jiang/ml/mm/mmsegmentation/mmseg/core/evaluation/eval_hooks.py", line 51, in _do_evaluate
    results = single_gpu_test(
  File "/mnt/data/jiang/ml/mm/mmsegmentation/mmseg/apis/test.py", line 128, in single_gpu_test
    result = dataset.pre_eval(result, indices=batch_indices)
  File "/mnt/data/jiang/ml/cd/open-cd/opencd/datasets/custom.py", line 336, in pre_eval
    intersect_and_union(
  File "/mnt/data/jiang/ml/mm/mmsegmentation/mmseg/core/evaluation/metrics.py", line 76, in intersect_and_union
    pred_label = pred_label[mask]
IndexError: index 10995116278530 is out of bounds for dimension 0 with size 1024

Input data set format

Hello

I am creating a deforestation dataset,

I have images in .tiff format with 7 bands, is there a way to use these images as network input?

I could cut some that are not essential, but I need to keep the Red, Green, Blue and Near Infrared bands.

Thanks since now

_pickle.UnpicklingError: invalid load key, '/'.

开发者你好,我在运行BIT的测试部分时(python tools/test.py configs/bit/bit_r18_256x256_40k_levircd.py changer_r18_levir_workdir/last_checkpoint --show-dir tmp_infer),遇到如下问题,希望开发者能帮助解决,谢谢:
Traceback (most recent call last):
File "/remote-home/clwei/WCL/CD/open-cd-1.x/tools/test.py", line 115, in
main()
File "/remote-home/clwei/WCL/CD/open-cd-1.x/tools/test.py", line 111, in main
runner.test()
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/runner.py", line 1750, in test
self.load_or_resume()
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/runner.py", line 1643, in load_or_resume
self.load_checkpoint(self._load_from)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/runner.py", line 2051, in load_checkpoint
checkpoint = _load_checkpoint(filename, map_location=map_location)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/checkpoint.py", line 518, in _load_checkpoint
return CheckpointLoader.load_checkpoint(filename, map_location, logger)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/checkpoint.py", line 300, in load_checkpoint
return checkpoint_loader(filename, map_location)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/mmengine/runner/checkpoint.py", line 317, in load_from_local
checkpoint = torch.load(filename, map_location=map_location)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 795, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/remote-home/clwei/anaconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1002, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '/'.

Run open-CD on a single image pair

Right now, when I run open-cd, it generates change maps on the whole test image pairs located in data\LEVIR-CD\test:

python3 tools/test.py configs/changer/changer_ex_r18_512x512_40k_levircd.py changer_r18_levir_workdir/ChangerEx_r18-512x512_40k_levircd_20221223_120511.pth --show-dir tmp_infer

How can I test in just on a single given image pair? Basically I want to compare 2 input images, i1 and i2.

evaluation metrics for s2looking

In your paper, there is no introduction to the content of evaluation metrics, and there are only two classification caculation in the code. May I ask if the s2looking's F1 score for three classifications is calculated using macro method?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.