Home

Awesome

cap

šŸ”„ News

šŸ“· Introduction

rssegmentation is an open-source semantic segmentation toolbox, which is dedicated to reproducing and developing advanced methods for semantic segmentation of remote sensing images.

šŸ” Preparation

conda create -n rsseg python=3.9
conda activate rsseg
conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.7 -c pytorch -c nvidia
pip install -r requirements.txt

šŸ“’ Folder Structure

Prepare the following folders to organize this repo:

rssegmentation
ā”œā”€ā”€ rssegmentation (code)
ā”œā”€ā”€ work_dirs (save the model weights and training logs)
ā”œā”€ā”€ data
ā”‚   ā”œā”€ā”€ LoveDA
ā”‚   ā”‚   ā”œā”€ā”€ Train
ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ Urban
ā”‚   ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ images_png (original images)
ā”‚   ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ masks_png (original labels)
ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ Rural
ā”‚   ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ images_png (original images)
ā”‚   ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ masks_png (original labels)
ā”‚   ā”‚   ā”œā”€ā”€ Val (the same with Train)
ā”‚   ā”‚   ā”œā”€ā”€ Test
ā”‚   ā”œā”€ā”€ vaihingen
ā”‚   ā”‚   ā”œā”€ā”€ ISPRS_semantic_labeling_Vaihingen 
ā”‚   ā”‚   ā”‚   ā”œā”€ā”€ top (original images)
ā”‚   ā”‚   ā”œā”€ā”€ ISPRS_semantic_labeling_Vaihingen_ground_truth_COMPLETE (original labels)
ā”‚   ā”‚   ā”œā”€ā”€ ISPRS_semantic_labeling_Vaihingen_ground_truth_eroded_COMPLETE (original noBoundary lables)
ā”‚   ā”‚   ā”œā”€ā”€ train (processed)
ā”‚   ā”‚   ā”œā”€ā”€ test (processed)
ā”‚   ā”œā”€ā”€ potsdam (the same with vaihingen)
ā”‚   ā”‚   ā”œā”€ā”€ 2_Ortho_RGB (original images)
ā”‚   ā”‚   ā”œā”€ā”€ 5_Labels_all (original labels)
ā”‚   ā”‚   ā”œā”€ā”€ 5_Labels_all_noBoundary (original noBoundary lables)
ā”‚   ā”‚   ā”œā”€ā”€ train (processed)
ā”‚   ā”‚   ā”œā”€ā”€ test (processed)

āœ‚ļø Data Processing

1ļøāƒ£ Vaihingen

train

python tools/dataset_patch_split.py \
--dataset-type "vaihingen" \
--img-dir "/home/xwma/data/Vaihingen/ISPRS_semantic_labeling_Vaihingen/top" \
--mask-dir "/home/xwma/data/Vaihingen/ISPRS_semantic_labeling_Vaihingen_ground_truth_COMPLETE" \
--output-img-dir "data/vaihingen/train/images_1024" \
--output-mask-dir "data/vaihingen/train/masks_1024" \
--split-size 1024 \
--stride 512 \
--mode "train"

test and val

python tools/dataset_patch_split.py \
--dataset-type "vaihingen" \
--img-dir "/home/xwma/data/Vaihingen/ISPRS_semantic_labeling_Vaihingen/top" \
--mask-dir "/home/xwma/data/Vaihingen/ISPRS_semantic_labeling_Vaihingen_ground_truth_COMPLETE" \
--output-img-dir "data/vaihingen/test/images_1024" \
--output-mask-dir "data/vaihingen/test/masks_1024_RGB" \
--split-size 1024 \
--stride 1024 \
--mode "test"
python tools/dataset_patch_split.py \
--dataset-type "vaihingen" \
--img-dir "/home/xwma/data/Vaihingen/ISPRS_semantic_labeling_Vaihingen/top" \
--mask-dir "/home/xwma/data/Vaihingen/ISPRS_semantic_labeling_Vaihingen_ground_truth_eroded_COMPLETE" \
--output-img-dir "data/vaihingen/test/images_1024" \
--output-mask-dir "data/vaihingen/test/masks_1024" \
--split-size 1024 \
--stride 1024 \
--mode "test"

2ļøāƒ£ potsdam

train

python tools/dataset_patch_split.py \
--dataset-type "potsdam" \
--img-dir "/home/xwma/data/Potsdam/2_Ortho_RGB" \
--mask-dir "/home/xwma/data/Potsdam/5_Labels_all" \
--output-img-dir "data/potsdam/train/images_1024" \
--output-mask-dir "data/potsdam/train/masks_1024" \
--split-size 1024 \
--stride 512 \
--mode "train"

test and val

python tools/dataset_patch_split.py \
--dataset-type "potsdam" \
--img-dir "/home/xwma/data/Potsdam/2_Ortho_RGB" \
--mask-dir "/home/xwma/data/Potsdam/5_Labels_all_noBoundary" \
--output-img-dir "data/potsdam/test/images_1024" \
--output-mask-dir "data/potsdam/test/masks_1024" \
--split-size 1024 \
--stride 1024 \
--mode "test"
python tools/dataset_patch_split.py \
--dataset-type "potsdam" \
--img-dir "/home/xwma/data/Potsdam/2_Ortho_RGB" \
--mask-dir "/home/xwma/data/Potsdam/5_Labels_all" \
--output-img-dir "data/potsdam/test/images_1024" \
--output-mask-dir "data/potsdam/test/masks_1024_RGB" \
--split-size 1024 \
--stride 1024 \
--mode "test"

šŸ“š Use example

1ļøāƒ£ Training

python train.py -c "configs/logcan.py"

2ļøāƒ£ Testing

Vaihingen and Potsdam

python test.py \
-c "configs/logcan.py" \
--ckpt "work_dirs/LoGCAN_ResNet50_Loveda/epoch=45.ckpt" \

LoveDA Note that since the loveda dataset needs to be evaluated online, we provide the corresponding test commands.

python online_test.py \
-c "configs/logcan.py" \
--ckpt "work_dirs/LoGCAN_ResNet50_Loveda/epoch=45.ckpt" \

3ļøāƒ£ Useful tools

We provide two useful commands to test the model for parameters, flops and latency.

python tools/flops_params_count.py \
-c "configs/logcan.py" \
python tools/latency_count.py \
-c "configs/logcan.py" \
--ckpt "work_dirs/LoGCAN_ResNet50_Loveda/epoch=45.ckpt" \

We will support feature visualizations as well as attention relationship visualizations soon.

šŸŒŸ Citation

If you find our repo useful for your research, please consider giving a šŸŒŸ and citing our work below.

@inproceedings{logcan,
  title={Log-can: local-global class-aware network for semantic segmentation of remote sensing images},
  author={Ma, Xiaowen and Ma, Mengting and Hu, Chenlu and Song, Zhiyuan and Zhao, Ziyan and Feng, Tian and Zhang, Wei},
  booktitle={ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
  pages={1--5},
  year={2023},
  organization={IEEE}
}

@inproceedings{sacanet,
  title={Sacanet: scene-aware class attention network for semantic segmentation of remote sensing images},
  author={Ma, Xiaowen and Che, Rui and Hong, Tingfeng and Ma, Mengting and Zhao, Ziyan and Feng, Tian and Zhang, Wei},
  booktitle={2023 IEEE International Conference on Multimedia and Expo (ICME)},
  pages={828--833},
  year={2023},
  organization={IEEE}
}

@article{docnet,
  title={DOCNet: Dual-Domain Optimized Class-Aware Network for Remote Sensing Image Segmentation},
  author={Ma, Xiaowen and Che, Rui and Wang, Xinyu and Ma, Mengting and Wu, Sensen and Feng, Tian and Zhang, Wei},
  journal={IEEE Geoscience and Remote Sensing Letters},
  year={2024},
  publisher={IEEE}
}

@misc{logcan++,
      title={LOGCAN++: Local-global class-aware network for semantic segmentation of remote sensing images}, 
      author={Xiaowen Ma and Rongrong Lian and Zhenkai Wu and Hongbo Guo and Mengting Ma and Sensen Wu and Zhenhong Du and Siyang Song and Wei Zhang},
      year={2024},
      eprint={2406.16502},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
      url={https://arxiv.org/abs/2406.16502}, 
}

šŸ“® Contact

If you are confused about the content of our paper or look forward to further academic exchanges and cooperation, please do not hesitate to contact us. The e-mail address is xwma@zju.edu.cn. We look forward to hearing from you!

šŸ’” Acknowledgement

Thanks to previous open-sourced repo: