{"id":13785111,"url":"https://github.com/wgcban/SemiCD","last_synced_at":"2025-05-11T20:32:04.053Z","repository":{"id":46021062,"uuid":"455213952","full_name":"wgcban/SemiCD","owner":"wgcban","description":"Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images","archived":false,"fork":false,"pushed_at":"2024-01-09T13:49:39.000Z","size":2409,"stargazers_count":133,"open_issues_count":5,"forks_count":19,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T01:38:10.532Z","etag":null,"topics":["change-detection","consistency","levir-cd","remote-sensing","segmentation","semi-supervised","supervised-learning","whu-cd"],"latest_commit_sha":null,"homepage":"https://www.wgcban.com/research#h.ar24vwqlm021","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wgcban.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-02-03T15:15:06.000Z","updated_at":"2025-03-27T08:38:58.000Z","dependencies_parsed_at":"2024-01-17T09:21:34.342Z","dependency_job_id":"5ad2b0f2-6614-4ee2-b0b3-fed9b0d4fa44","html_url":"https://github.com/wgcban/SemiCD","commit_stats":{"total_commits":141,"total_committers":3,"mean_commits":47.0,"dds":"0.46808510638297873","last_synced_commit":"72517f97067c879503fd35225c2e0e2576c0005a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wgcban%2FSemiCD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wgcban%2FSemiCD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wgcban%2FSemiCD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wgcban%2FSemiCD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wgcban","download_url":"https://codeload.github.com/wgcban/SemiCD/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253632070,"owners_count":21939370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-detection","consistency","levir-cd","remote-sensing","segmentation","semi-supervised","supervised-learning","whu-cd"],"created_at":"2024-08-03T19:00:57.106Z","updated_at":"2025-05-11T20:32:03.582Z","avatar_url":"https://github.com/wgcban.png","language":"Python","funding_links":[],"categories":["Multispectral"],"sub_categories":["Deep Learning"],"readme":"## Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images\n[`Wele Gedara Chaminda Bandara`](https://www.wgcban.com/), and [`Vishal M. Patel`](https://engineering.jhu.edu/vpatel36/sciencex_teams/vishalpatel/)\n\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-levir-cd)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-levir-cd?p=revisiting-consistency-regularization-for-1)\n [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-levir-cd-1)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-levir-cd-1?p=revisiting-consistency-regularization-for-1) [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-levir-cd-2)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-levir-cd-2?p=revisiting-consistency-regularization-for-1) [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-levir-cd-3)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-levir-cd-3?p=revisiting-consistency-regularization-for-1)\n \n [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-whu-5)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-whu-5?p=revisiting-consistency-regularization-for-1)\n [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-whu-10)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-whu-10?p=revisiting-consistency-regularization-for-1)\n [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-whu-20)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-whu-20?p=revisiting-consistency-regularization-for-1)\n [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-consistency-regularization-for-1/semi-supervised-change-detection-on-whu-40)](https://paperswithcode.com/sota/semi-supervised-change-detection-on-whu-40?p=revisiting-consistency-regularization-for-1)\n \n\n:open_book:\t:open_book:\t :open_book:\t:open_book:\t View paper [`here`](https://arxiv.org/abs/2204.08454).\n\n:bookmark: :bookmark: :bookmark: View project page [`here`](https://www.wgcban.com/research#h.ar24vwqlm021).\n\nThis repocitory contains the official implementation of our paper:  **Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images**.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./imgs/method.jpg\" width=\"900\"\u003e\u003c/p\u003e\n\n## :speech_balloon: Requirements\n\nThis repo was tested with `Ubuntu 18.04.3 LTS`, `Python 3.8`, `PyTorch 1.1.0`, and `CUDA 10.0`. But it should be runnable with recent PyTorch versions \u003e=1.1.0.\n\nThe required packages are `pytorch` and `torchvision`, together with `PIL` and `opencv` for data-preprocessing and `tqdm` for showing the training progress.\n\n```bash\nconda create -n SemiCD python=3.8\n\nconda activate SemiCD\n\npip3 install -r requirements.txt\n```\n\n## :speech_balloon: Datasets\nWe use two publicly available, widely-used CD datasets for our experiments, namely [`LEVIR-CD`](https://justchenhao.github.io/LEVIR/) and [`WHU-CD`](http://gpcv.whu.edu.cn/data/building_dataset.html). Note that LEVIR-CD and WHU-CD are building CD datasets.\n\nAs we described in the paper, following previous works [`ChangeFormer`](https://github.com/wgcban/ChangeFormer) and [`BIT-CD`](https://github.com/justchenhao/BIT_CD) on supervised CD, we create non-overlapping patches of size 256x256 for the training. The dataset preparation codes are written in MATLAB and can be found in ``dataset_preperation`` folder. These scripts will also generate the supervised and unsupervised training scripts that we used to train the model under diffrent percentage of labeled data.\n\n**Instead, you can directely download the processed LEVIR-CD and WHU-CD through the following links. Save these datasets anywhere you want and change the ``data_dir`` to each dataset in the corresponding ``config`` file.**\n\nThe processed LEVIR-CD dataset, and supervised-unsupervised splits can be downloaded [`here`](https://www.dropbox.com/s/18fb5jo0npu5evm/LEVIR-CD256.zip?dl=0).\n\nThe processed WHU-CD dataset, and supervised-unsupervised splits can be downloaded [`here`](https://www.dropbox.com/s/r76a00jcxp5d3hl/WHU-CD-256.zip?dl=0).\n\n## :speech_balloon: Training\n\nTo train a model, first download processed dataset above and save them in any directory you want, then set `data_dir` to the dataset path in the config file in ``configs/config_LEVIR.json``/``configs/config_WHU.json`` and set the rest of the parameters, like ``experim_name``, ``sup_percent``, ``unsup_percent``, ``supervised``, ``semi``, ``save_dir``, ``log_dir`` ... etc., more details below. \n\n### :point_right: Training on LEVIR-CD dataset\nThen simply run:\n```bash\npython train.py --config configs/config_LEVIR.json\n```\n\nThe following table summarizes the **required changes** in ``config`` file to train a model ``supervised`` or ``unsupervised`` with different percentage of labeled data. \n\n| Setting | Required changes in `config_LEVIR.json` file |\n| --- | --- |\n| Supervised - 5% labeled data | Experiment name: `SemiCD_(sup)_5`, sup_percent= `5`, model.supervised=`True`, model.semi=`False` |\n| Supervised - 10% labeled data | Experiment name: `SemiCD_(sup)_10`, sup_percent= `10`, model.supervised=`True`, model.semi=`False` |\n| Supervised - 20% labeled data | Experiment name: `SemiCD_(sup)_20`, sup_percent= `20`, model.supervised=`True`, model.semi=`False` |\n| Supervised - 40% labeled data | Experiment name: `SemiCD_(sup)_40`, sup_percent= `40`, model.supervised=`True`, model.semi=`False` |\n| Supervised - 100% labeled data (**Oracle**) | Experiment name: `SemiCD_(sup)_100`, sup_percent= `100`, model.supervised=`True`, model.semi=`False` |\n|  |  |\n| Semi-upervised - 5% labeled data | Experiment name: `SemiCD_(semi)_5`, sup_percent= `5`, model.supervised=`Flase`, model.semi=`True` |\n| Semi-upervised - 10% labeled data | Experiment name: `SemiCD_(semi)_10`, sup_percent= `10`, model.supervised=`Flase`, model.semi=`True` |\n| Semi-upervised - 20% labeled data | Experiment name: `SemiCD_(semi)_20`, sup_percent= `20`, model.supervised=`Flase`, model.semi=`True` |\n| Semi-upervised - 40% labeled data | Experiment name: `SemiCD_(semi)_40`, sup_percent= `40`, model.supervised=`Flase`, model.semi=`True` |\n\n### :point_right: Training on WHU-CD dataset\nPlease follow the same changes that we outlined above to WHU-CD dataset as well. \nThen simply run:\n```bash\npython train.py --config configs/config_WHU.json\n```\n\n### :point_right: Training with cross-domain data (i.e., LEVIR as supervised and WHU as unsupervised datasets)\nIn this case we use LEVIR-CD as the supervised dataset and WHU-CD as the unsupervised dataset. Therefore, you need to update the ``train_supervised`` ``data_dir``  as the path to LEVIR-CD dataset, and ``train_unsupervised`` ``data_dir``  as the path to WHU-CD dataset in ``config_LEVIR-sup_WHU-unsup.json``. Then change the ``sup_percent`` in the config file as you want and then simply run:\n```bash\npython train.py --config configs/config_LEVIR-sup_WHU-unsup.json\n```\n\n### :point_right: Monitoring the training log via TensorBoard\nThe log files and the `.pth` checkpoints will be saved in `saved\\EXP_NAME`, to monitor the training using tensorboard, please run:\n\n```bash\ntensorboard --logdir saved\n```\n\nTo resume training using a saved `.pth` model:\n\n```bash\npython train.py --config configs/config_LEVIR.json --resume saved/SemiCD/checkpoint.pth\n```\n\n**Results**: The results will be saved in `saved` as an html file, containing the validation results,\nand the name it will take is `experim_name` specified in `configs/config_LEVIR.json`.\n\n## :speech_balloon: Inference\n\nFor inference, we need a pretrained model, the pre-chage and pos-change imags that we wouldlike to dtet changes and the config used in training (to load the correct model and other parameters), \n\n```bash\npython inference.py --config config_LEVIR.json --model best_model.pth --images images_folder\n```\n\nHere are the flags available for inference:\n\n```\n--images       Folder containing the jpg images to segment.\n--model        Path to the trained pth model.\n--config       The config file used for training the model.\n```\n\n## :speech_balloon: Pre-trained models\n\nPre-trained models can be downloaded from the following links.\n\nPre-trained models on LEVIR-CD can be downloaded from [`here`](https://www.dropbox.com/sh/0m8t6dq37f11ukx/AAAgTgIxr_eyJJeHWqZ_SRVYa?dl=0). \n\nPre-trained models on WHU-CD can be downloaded from [`here`](https://www.dropbox.com/sh/oyn3d8hyz6qnzm5/AAAct3ueZ39xYINQbbO0oSJ_a?dl=0). \n\nPre-trained models for cross-dataset experiments can be downloaded from [`here`](https://www.dropbox.com/sh/mvszluw944jvhc3/AAB-eR-stgVsjmNSvzZ5Hlqqa?dl=0).\n\n## :speech_balloon: Citation\n\nIf you find this repo useful for your research, please consider citing the paper as follows:\n\n```\n@misc{bandara2022revisiting,\n      title={Revisiting Consistency Regularization for Semi-supervised Change Detection in Remote Sensing Images}, \n      author={Wele Gedara Chaminda Bandara and Vishal M. Patel},\n      year={2022},\n      eprint={2204.08454},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n\n```\n\n#### Acknowledgements\n\n- This code is based on [CCT](https://github.com/yassouali/CCT).\n- Code structure was based on [Pytorch-Template](https://github.com/victoresque/pytorch-template/blob/master/README.m)\n- ResNet backbone was downloaded from [torchcv](https://github.com/donnyyou/torchcv)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwgcban%2FSemiCD","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwgcban%2FSemiCD","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwgcban%2FSemiCD/lists"}