Coder Social home page Coder Social logo

kaankalaycioglu / ddpm-cd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wgcban/ddpm-cd

0.0 0.0 0.0 19.32 MB

Remote Sensing Change Detection using Denoising Diffusion Probabilistic Models

Home Page: https://www.wgcban.com/research#h.ar24vwqlm021

License: MIT License

Python 100.00%

ddpm-cd's Introduction

DDPM-CD: Remote Sensing Change Detection using Denoising Diffusion Probabilistic Models

Paper | Project

This is the offical Pytorch implementation of Remote Sensing Change Detection using Denoising Diffusion Probabilistic Models.

▶️Motivation

image-20210228153142126 Images generated from the diffusion model trained on off-the-shelf remote sensing images. The generated images contain objects that we commonly see in real remote sensing images, such as buildings, trees, roads, vegetation, water surfaces, etc., demonstrating the powerful ability of the diffusion models to extract key semantics that can be further used in remote sensing change detection.

▶️Method

image-20210228153142126 We fine-tune a light-weight change detection head which takes multi-level feature representations from the pre-trained diffusion model as inputs and outputs change prediction map.

▶️Environment

conda create -n ddpm-cd python=3.9
conda activate ddpm-cd
pip3 install -r requirement.txt

▶️Training diffusion model with remote sensing data

🔅Collect off-the-shelf remote sensing data to train diffusion model

Dump all the remote sensing data sampled from Google Earth Engine and any other publically available remote sensing images to dataset folder or create a simlink.

🔅Training/Resume unconditional diffusion model on remote sensing data

We use ddpm_train.json to setup the configurations. Update the dataset name and dataroot in the json file. Then run the following command to start training the diffusion model. The results and log files will be save to experiments folder. Also, we upload all the metrics to wandb.

python ddpm_train.py --config config/ddpm_train.json -enable_wandb -log_eval

In case, if you want to resume the training from previosely saved point, provide the path to saved model in path/resume_state, else keep it as null.

🔅Sampling from the diffusion model

If you want generate samples from the diffusion model, first update the path to trained diffusion model in [path][resume_state]. Then run the following command.

python ddpm_train.py --config config/ddpm_sampling.json --phase val

The generated images will be saved in experiments.

▶️Change Detection

🔅Download the datasets

Download the change detection datasets from the following links. Place them inside your datasets folder.

Then, update the paths to those folders here [datasets][train][dataroot], [datasets][val][dataroot], [datasets][test][dataroot] in levir.json, whu.json, dsifn.json, and cdd.json.

Provide the path to pre-trained diffusion model

Udate the path to pre-trained diffusion model weights (*_gen.pth and *_opt.pth) here [path][resume_state] in levir.json, whu.json, dsifn.json, and cdd.json..

🔅Training the change detection network

Run the following code to start the training.

  • Training on LEVIR-CD:
    python ddpm_cd.py --config config/levir.json -enable_wandb -log_eval
  • Training on WHU-CD:
    python ddpm_cd.py --config config/whu.json -enable_wandb -log_eval
  • Training on DSIFN-CD:
    python ddpm_cd.py --config config/dsifn.json -enable_wandb -log_eval
  • Training on CDD:
    python ddpm_cd.py --config config/cdd.json -enable_wandb -log_eval

The results will be saved in experiments and also upload to wandb.

🔅Testing

To obtain the predictions and performance metrics (iou, f1, and OA), first provide the path to pre-trained diffusion model here [path][resume_state] and path to trained change detection model (the best model) here [path_cd][resume_state] in levir_test.json, whu_test.json, dsifn_test.json, and cdd_test.json.

Run the following code to start the training.

  • Test on LEVIR-CD:
    python ddpm_cd.py --config config/levir_test.json --phase test -enable_wandb -log_eval
  • Test on WHU-CD:
    python ddpm_cd.py --config config/whu_test.json --phase test -enable_wandb -log_eval
  • Test on DSIFN-CD:
    python ddpm_cd.py --config config/dsifn_test.json --phase test -enable_wandb -log_eval
  • Test on CDD:
    python ddpm_cd.py --config config/cdd_test.json --phase test -enable_wandb -log_eval

Predictions will be saved in experiments and performance metrics will be uploaded to wandb.

▶️Pre-trained models & Train/Val/Test logs

🔅Links to download pre-trained models

💥 If you face a problem when downloading from the DropBox try one of the following options:

🔅Train/Val Reports on wandb

🔅Test results on wandb

▶️Results

🔅Quantitative

image-20210228153142126

🔅Qualitative

  • LEVIR-CD image-20210228153142126
  • WHU-CD image-20210228153142126
  • DSIFN-CD image-20210228153142126
  • CDD image-20210228153142126

▶️Citation

@misc{https://doi.org/10.48550/arxiv.2206.11892,
  doi = {10.48550/ARXIV.2206.11892},
  
  url = {https://arxiv.org/abs/2206.11892},
  
  author = {Bandara, Wele Gedara Chaminda and Nair, Nithin Gopalakrishnan and Patel, Vishal M.},
  
  keywords = {Computer Vision and Pattern Recognition (cs.CV), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
  
  title = {Remote Sensing Change Detection (Segmentation) using Denoising Diffusion Probabilistic Models},
  
  publisher = {arXiv},
  
  year = {2022},
  
  copyright = {Creative Commons Attribution 4.0 International}
}

▶️References

  • The code of diffusion model is from here.

ddpm-cd's People

Contributors

wgcban avatar janspiry avatar ayulockin avatar drew6017 avatar mazeofencryption avatar

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.