Skip to content

Cyber-CCOrange/PC-SAM

Repository files navigation

Acknowledgement

This work is built upon the Segment Anything Model (SAM).

PC-SAM: Patch-Constrained Fine-Grained Interactive Road Segmentation in High-Resolution Remote Sensing Images

This repository provides the implementation of PC-SAM, a fine-grained interactive road segmentation model for high-resolution remote sensing images.

PC-SAM supports both automatic road segmentation and interactive segmentation refinement. By using point prompts, users can correct segmentation errors locally and obtain more accurate road segmentation masks.


SAM/PC-SAM Checkpoint

Before starting, place the pretrained SAM-B checkpoint "sam_vit_b_01ec64.pth" in:

./sam-checkpoint/

The checkpoints of our PC-SAM can be downloaded from the following link:

Place the PC-SAM checkpoints in:

./train-checkpoint/

Dataset

The dataset should be placed in:

./datasets/

The dataset directory should be organized as follows:

datasets/
└── [dataset_name]/
    ├── input
    ├── gt-mask
    ├── valid-input
    └── valid-mask

Where:

  • input: training images
  • gt-mask: ground truth masks for training
  • valid-input: validation images
  • valid-mask: ground truth masks for validation

Training

To train PC-SAM, run the following command:

python PC-SAM.py --config configs/PC-SAM_{Dataset_name}.yml

Example: training on the DeepGlobe dataset

python PC-SAM.py --config configs/PC-SAM_DG.yml

Testing

To test the trained model:

python PC-SAM.py --config configs/PC-SAM_{Dataset_name}.yml --load_model --valid --batch_size 1

Example: testing on the DeepGlobe dataset

python PC-SAM.py --config configs/PC-SAM_DG.yml --load_model --valid --batch_size 1

To save the predictions, add the argument:

--save_valid_predictions

The predictions will be saved in:

./datasets/[dataset_name]/PC-SAM/

The test results will be saved in the ./logs directory:

  • {model_save_name}_test_iou.log: records the IoU for each image
  • {model_save_name}_test.log: records the overall evaluation results

Visualization

To visualize the segmentation results:

python PC-SAM.py --config configs/PC-SAM_{Dataset_name}.yml --load_model --valid --batch_size 1 --valid_show_img_mask

Example:

python PC-SAM.py --config configs/PC-SAM_DG.yml --load_model --valid --batch_size 1 --valid_show_img_mask

Description

PC-SAM is designed for fine-grained interactive road segmentation in high-resolution remote sensing images.

The model allows users to refine segmentation results through interactive point prompts, enabling local correction of:

  • false positives
  • missing road segments

This interactive mechanism provides better controllability compared with traditional fully automatic segmentation models.


Citation

If you find this work useful, please cite:

@misc{lv2026pcsampatchconstrainedfinegrainedinteractive,
      title={PC-SAM: Patch-Constrained Fine-Grained Interactive Road Segmentation in High-Resolution Remote Sensing Images}, 
      author={Chengcheng Lv and Rushi Li and Mincheng Wu and Xiufang Shi and Zhenyu Wen and Shibo He},
      year={2026},
      eprint={2604.00495},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2604.00495}, 
}

License

This project is released for academic research purposes.

About

Open code for "PC-SAM: Patch-Constrained Fine-Grained Interactive Road Segmentation in High-Resolution Remote Sensing Images"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages