Shi-Feng Peng,Guolei Sun, Yong Li , Hongsong Wang , Guo-Sen Xie.
Welcome to the official PyTorch implementation repository of our paper SAM-Aware Graph Prompt Reasoning Network for Cross-Domain Few-Shot Segmentation, accepted to AAAI 2025.
Download training and testing datasets for evaluation.
-
PASCAL VOC2012:
Download PASCAL VOC2012 devkit (train/val data):
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
Download PASCAL VOC2012 SDS extended mask annotations from [Google Drive].
-
Deepglobe:
Home: http://deepglobe.org/
Direct: https://www.kaggle.com/datasets/balraj98/deepglobe-land-cover-classification-dataset
Data Preprocessing Code: Please refer preprocess_deepglobe.py or PATNet repo.
-
ISIC2018:
Home: http://challenge2018.isic-archive.com
Direct (must login): https://challenge.isic-archive.com/data#2018
Class Information: data/isic/class_id.csv
Data Preprocessing Code: Please refer preprocess_isic.py or PATNet repo.
-
Chest X-ray:
Home: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4256233/
Direct: https://www.kaggle.com/datasets/nikhilpandey360/chest-xray-masks-and-labels
-
FSS-1000:
Home: https://github.com/HKUSTCV/FSS-1000
Direct: https://drive.google.com/file/d/16TgqOeI_0P41Eh3jWQlxlRXG9KIqtMgI/view
Download pre-trained ResNet models and SAM weights.
Pre-trained ResNet model weight
To save time, we have saved the masks generated by SAM to a file during actual operations, so you don’t need to regenerate them every time . You only need to run generate_mask.py
to generate them once. Note that you should reconfigure the configuration such as file path and GPU ID in generate_mask.py
.
python generate_mask.py
GPRN/
|--dataset/
| |--Deepglobe/
| | |--01_train_ori/
| | |--...
| | |--04_train_cat/
| | |--|--Deepglobe-SAM_mask/ # Masks generated by SAM
| |--FSS-1000/
| | |--ab_wheel/
| | |--...
| | |--FSS-SAM-MASK/ # Masks generated by SAM
| |--ISIC/
| | |--ISIC2018_Task1-2_Training_Input/
| | |--...
| | |--ISIC-SAM-MASK/ # Masks generated by SAM
| |--LungSegmentation/
| | |--CXR_PNG/
| | |--...
| | |--Lung-SAM-MASK/ # Masks generated by SAM
| |--VOC2012/
| | |--JPEGImages/
| | |--...
| | |--SAM-PASCAL/ # Masks generated by SAM
Please run the script file run.sh to evaluate our models. Here is an example on Deepglobe dataset:
CUDA_VISIBLE_DEVICES=0 python -W ignore test.py \
--dataset deepglobe --data-root ./dataset \
--backbone resnet50 --batch-size 6 --shot 1 --refine --positive_point 20 --negative_point 20 --alpha 0.5 --fuse_method coff \
--post_refine
This repository is built upon the foundations of Segment Anything, MGCL, IFA, VRP-SAM, MaskSLIC. We are very grateful for their contribution!