Code Monkey home page Code Monkey logo

c-3po's Introduction

C-3PO

PWC PWC PWC

This is the official Pytorch implementation for How to Reduce Change Detection to Semantic Segmentation.

Overall, we present a new paradigm that reduces change detection to semantic segmentation which means tailoring an existing and powerful semantic segmentation network to solve change detection.

reduce

Our analysis suggests that there are three possible change types within the change detection task and they should be learned separately. Therefore, we propose a MTF (Merge Temporal Features ) module to learn these changes.

changes

We propose a simple but effective network, called C-3PO (Combine 3 POssible change types), detects changes in pixel-level, and can be considered as a new baseline network in this field.

C-3PO

MTF

MSF

Features

  • This project aims at providing a benchmark of change detection. We implement and include several previous methods in this project, such as FC-EF, FC-Siam-diff, FC-Siam-cone, DR-TANet, CSCDNet, etc. Please check src/model for more details.
  • We mainly use the models in torchvision, such as FCN, DeepLab, etc. This project does not use any other 3rd libraries, such as mmsegmentation. Hence, this project provides a guidance of how to utilize the torchvision models to efficiently solve other problems.

Requirements

  • Python3
  • PyTorch
  • Torchvision
  • pycocotools
  • timm

Python3, Pytorch and Torchvision are necessary. pycocotools is required for the COCO dataset. timm is required for the Swin Transformer backbone.

If you want to use CSCDNet in our project, please follow their instructions to install the correlation module.

If you do not want to use other models or install unnecessary packages, please checkout the mini branch, which only contains codes for our C-3PO model.

Prepare the dataset

There are three datasets needed in this projects:

  • COCO
  • PCD
  • VL-CMU-CD
  • ChangeSim

Please refer to src/dataset/path_config.py to understand the folder structure of each dataset. And edit data_path according to your system.

Please follow this site to download the PCD dataset. You may need to send e-mails to Takayuki Okatani.

For VL-CMU-CD, you can check this issue. Or you can download VL-CMU-CD-binary255 at here. Overall, I am not sure if I can release this dataset. If there is a policy problem, please contact me. And I will delete it.

Please follow this page to prepare the ChangeSim dataset.

Run

training

python3 -m torch.distributed.launch --nproc_per_node=4 --use_env src/train.py --train-dataset VL_CMU_CD --test-dataset VL_CMU_CD --input-size 512 --model resnet18_mtf_msf_fcn --mtf id --msf 4 --warmup --loss-weight

testing

python3 src/train.py --test-only --model resnet18_mtf_msf_fcn --mtf id --msf 4 --train-dataset VL_CMU_CD --test-dataset VL_CMU_CD --input-size 512 --resume [checkpoint.pth]

We provide all shells to reproduce the results in our paper. Please check files in the exp folder. You can use below commands to run experiments.

source exp/sota/resnet18_mtf_id_msf4_deeplabv3_cmu.sh
train

Pretrained Weights

Please download the weights by yourself. Check the test command in the shell, and modify --resume according to your download path. Then you can run the test command to evaluate the performance.

Shell Weights Model Dataset Performance
resnet18_mtf_id_msf4_deeplabv3_cmu resnet18_id_4_deeplabv3_VL_CMU_CD.pth resnet18_mtf_msf_deeplabv3 VL-CMU-CD 79
vgg16bn_mtf_id_msf4_deeplabv3_cmu vgg16bn_id_4_deeplabv3_VL_CMU_CD.pth vgg16bn_mtf_msf_deeplabv3 VL-CMU-CD 80
resnet18_mtf_iade_msf4_deeplabv3_pcd resnet18_iade_4_deeplabv3_PCD.pth resnet18_mtf_msf_deeplabv3 GSV/TSUNAMI set 0 80/88
vgg16bn_mtf_iade_msf4_deeplabv3_pcd vgg16bn_iade_4_deeplabv3_PCD.pth vgg16bn_mtf_msf_deeplabv3 GSV/TSUNAMI set 0 79/88
resnet18_mtf_iade_msf4_deeplabv3_changesim_binary resnet18_iade_4_deeplabv3_ChangeSim_Binary.pth resnet18_mtf_msf_deeplabv3 ChangeSim Binary 60
resnet18_mtf_iade_msf4_deeplabv3_changesim_multi resnet18_iade_4_deeplabv3_ChangeSim_Multi.pth resnet18_mtf_msf_deeplabv3 ChangeSim Multi 28

Note that the PCD dataset has 5 subsets, and we release our models for the first subset. Please train models on other subsets by yourself if you want to obtain them.

Results

As stated in our paper, VL-CMU-CD and PCD suffer from noisy labels. We present the last and the best performance for reference. Overall, it is easy to achieve the performance between these two scores.

VL-CMU-CD

PCD

ChangeSim

Visualization

CMU

Citation

If you find the work useful for your research, please cite:

@article{wang2022c3po,
  title={How to Reduce Change Detection to Semantic Segmentation},
  author={Wang, Guo-Hua and Gao, Bin-Bin and Wang, Chengjie},
  journal={Pattern Recognition},
  year={2023}
}

reference

c-3po's People

Contributors

doctorkey 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

Watchers

 avatar  avatar  avatar

c-3po's Issues

Device parameter

in the main train.py script you can pass the device param. but there is a lot of stuff cuda Is used for and can't use the CPU to do anything? is this meant to do stuff like cuda:4 or so?

Question about PCD dataset 5-fold cross validation

When loading the PCD dataset, select the Set by data-cv option to load the image from the pre-separated train/test folder.
Please explain the code or method for separating images into folders for the same performance comparison.

Using pretrained weights but getting poor metrics?

Hello, I use the pre-trained weight "resnet18_id_4_deeplabv3_VL_CMU_CD.pth" to run the shell command "resnet18_mtf_id_msf4_deeplabv3_cmu", but the result is very bad, the following is my running log and results, can you help me find the reason?

PS C:\Users\TEST\Desktop\C-3PO-main> c:; cd 'c:\Users\TEST\Desktop\C-3PO-main'; & 'C:\Users\TEST\anaconda3\envs\pc\python.exe' 'c:\Users\TEST.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '52990' '--' 'C:\Users\TEST\Desktop\C-3PO-main/src/train.py' '--test-only' '--save-imgs' '--model' 'vgg16bn_mtf_msf_deeplabv3' '--mtf' 'id' '--msf' '4' '--train-dataset' 'VL_CMU_CD' '--test-dataset' 'VL_CMU_CD' '--input-size' '512' '--resume' 'C:\Users\TEST\Downloads\vgg16bn_id_4_deeplabv3_VL_CMU_CD.pth'
Not using distributed mode
Namespace(train_dataset='VL_CMU_CD', test_dataset='VL_CMU_CD', test_dataset2='', input_size=512, randomflip=0.5, randomrotate=False, randomcrop=False, data_cv=0, model='vgg16bn_mtf_msf_deeplabv3', mtf='id', msf=4, device='cuda', batch_size=4, epochs=100, workers=16, loss='bi', loss_weight=False, opt='adam', lr_scheduler='cosine', lr=0.0001, warmup=False, momentum=0.9, weight_decay=0, print_freq=50, resume='C:\Users\TEST\Downloads\vgg16bn_id_4_deeplabv3_VL_CMU_CD.pth', pretrained='', start_epoch=0, eval_every=1, test_only=True, save_imgs=True, save_local=False, world_size=1, dist_url='env://', output_dir='C:/Users/TEST/Desktop/output\vgg16bn_mtf_msf_deeplabv3_VL_CMU_CD_0/2023-03-13_19-29-23', distributed=False)
Train Aug:
DATA AUG: resize (512, 512)
DATA AUG: random flip 0.5
VL_CMU_CD train: 1008
Test Aug:
DATA AUG: resize (512, 512)
VL_CMU_CD test: 354
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torch\utils\data\dataloader.py:554: UserWarning: This DataLoader will create 16 worker processes in total. Our suggested max number of worker in current system is 8 (cpuset is not taken into account), which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
warnings.warn(_create_warning_msg(
MSF: [128, 256, 512, 512]
MTF: mode: id kernel_size: 3
MTF: mode: id kernel_size: 3
MTF: mode: id kernel_size: 3
MTF: mode: id kernel_size: 3
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\models_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed
in the future, please use 'weights' instead.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\models_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=VGG16_BN_Weights.IMAGENET1K_V1. You can also use weights=VGG16_BN_Weights.DEFAULT to get the most up-to-date weights.
warnings.warn(msg)
Loss: bi
LR Scheduler: cosine
load from: C:\Users\TEST\Downloads\vgg16bn_id_4_deeplabv3_VL_CMU_CD.pth
load ret:
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torch\utils\data\dataloader.py:554: UserWarning: This DataLoader will create 16 worker processes in total. Our suggested max number of worker in current system is 8 (cpuset is not taken into account), which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
warnings.warn(_create_warning_msg(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
C:\Users\TEST\anaconda3\envs\pc\lib\site-packages\torchvision\transforms\functional.py:442: UserWarning: Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
warnings.warn(
Test: [ 0/354] eta: 5:26:46 Prec: 0.999 (0.999) Rec: 0.034 (0.034) Acc: 0.092 (0.092) F1score: 0.0656 (0.0656) time: 55.3849 data: 53.1827 max mem: 717
Test: [100/354] eta: 0:03:54 Prec: 1.000 (0.994) Rec: 0.188 (0.113) Acc: 0.269 (0.250) F1score: 0.3163 (0.1955) time: 0.3864 data: 0.0014 max mem: 721
Test: [200/354] eta: 0:01:39 Prec: 0.995 (0.996) Rec: 0.115 (0.111) Acc: 0.157 (0.236) F1score: 0.2069 (0.1886) time: 0.3468 data: 0.0016 max mem: 721
Test: [300/354] eta: 0:00:30 Prec: 0.994 (0.981) Rec: 0.127 (0.104) Acc: 0.169 (0.214) F1score: 0.2245 (0.1784) time: 0.4156 data: 0.0014 max mem: 721
Test: Total time: 0:03:13
Test: Total: 354 Metric Prec: 0.9834 Recall: 0.0997 F1: 0.1728
tensor(0.1728)

Train on the ChangeSim

Hello, I appreciate your efforts.

I want to train the model on the ChangeSim.
However, I cannot find the below files.
Could you provide the files?

    ├── dark_test_list.txt
    ├── dust_test_list.txt
    ├── idx2color.txt
    ├── test_list.txt
    ├── test_split.txt
    ├── train_list.txt
    └── train_split.txt

Model inference for new set of images

Hi and thanks for the amazing work!
I was wondering if you could give me any advice on how to perform the inference on my own set of images.
Thank you,
Laura

Model weights?

Hi, congratulations on the excellent work! Where can be accessed the weights of the models presented in the results table?

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.