ClassWise-SAM-Adapter: Parameter Efficient Fine-tuning Adapts Segment Anything to SAR Domain for Semantic Segmentation
Xinyang Pu, Hecheng Jia, Linghao Zheng, Feng Wang, Feng Xu
The Key Laboratory of Information Science of Electromagnetic Waves, Fudan University, Shanghai, China
This code was implemented with Python 3.8 and PyTorch 1.13.0. You can install all the requirements via:
pip install -r requirements.txt
- Prepare the dataset.
- Download the pre-trained SAM(Segment Anything) and put it in ./pretrained.
- Training:
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nnodes 1 --nproc_per_node 2 train.py --config [CONFIG_PATH]
- Evaluation:
python test.py --config [CONFIG_PATH] --model [MODEL_PATH]
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nnodes 1 --nproc_per_node 2 train.py --config [CONFIG_PATH]
CUDA_VISIBLE_DEVICES=1 python -m torch.distributed.launch --nnodes 1 --nproc_per_node 1 train.py --master_port='29600' --config [CONFIG_PATH]
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nnodes 1 --nproc_per_node 2 train.py --config configs_git/fusar-sar-map2-sam-vit-b-10cls-ce-trainval_1024_lr2e4_CE_e200.yaml
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nnodes 1 --nproc_per_node 2 train.py --config configs_git/fusar-sar-map-sam-vit-b-5cls-ce-trainval_1024_lr2e4_CEv2_e200_ignore_bg.yaml
python test.py --config [CONFIG_PATH] --model [MODEL_PATH]
export CUDA_VISIBLE_DEVICES=2
python test.py --config configs/fusar-sar-map-sam-vit-b-5cls-ce-trainval_1024_lr2e4_CEv2_e200_ignore_bg.yaml --model ./save/fusar-sar-map-sam-vit-b-5cls-ce-trainval_1024_lr2e4_CEv2_e200_ignore_bg/model_epoch_best.pth
If you find our work useful in your research, please consider citing:
@misc{pu2024classwisesamadapter,
title={ClassWise-SAM-Adapter: Parameter Efficient Fine-tuning Adapts Segment Anything to SAR Domain for Semantic Segmentation},
author={Xinyang Pu and Hecheng Jia and Linghao Zheng and Feng Wang and Feng Xu},
year={2024},
eprint={2401.02326},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
The part of the code is derived from SAM-adapter: KOKONI, Moxin Technology (Huzhou) Co., LTD , Zhejiang University, Singapore University of Technology and Design, Huzhou University, Beihang University.