Adapting SAM to Nuclei Instance Segmentation and Classification via Cooperative Fine-Grained Refinement
Jingze Su1, Tianle Zhu1, Jiaxin Cai1, Zhiyi Wang1, Qi Li1, Xiao Zhang1, Tong Tong3, Shu Wang2†, Wenxi Liu1†
1 College of Computer and Data Science, Fuzhou University, Fuzhou, China
2 School of Mechanical Engineering and Automation, Fuzhou University, Fuzhou, China
3 College of Physics and Information Engineering, Fuzhou University, Fuzhou, China
† Corresponding authors
🔥🔥CFR-SAM Paper Published in Medical Image Analysis (MIA).
The code was developed with the following core dependencies:
torch 2.0.1
mmcv
mmdet
mmengine
albumentations
opencv-python
scipy
scikit-image
pytorch-toolbelt
prettytable
terminaltables
thop
Prepare the data under datasets/ before training. A typical layout is:
datasets/
pannuke/
fold 1/
fold 2/
fold 3/
Images/
Masks/
pannuke123_train_files.npy
pannuke123_val_files.npy
pannuke123_test_files.npy
pannuke213_train_files.npy
pannuke213_val_files.npy
pannuke213_test_files.npy
pannuke321_train_files.npy
pannuke321_val_files.npy
pannuke321_test_files.npy
cpm17/
train/
test/
cpm17_train_files.npy
cpm17_test_files.npy
monuseg/
images/
labels/
monuseg_train_files.npy
monuseg_test_files.npy
| Dataset | weight |
|---|---|
| PanNuke123 | GoogleDrive |
| PanNuke213 | GoogleDrive |
| PanNuke321 | GoogleDrive |
| CPM-17 | GoogleDrive |
| MoNuSeg | GoogleDrive |
| Dataset | weight(Ours-H) |
|---|---|
| PanNuke123 | GoogleDrive |
| PanNuke213 | GoogleDrive |
| PanNuke321 | GoogleDrive |
| CPM-17 | GoogleDrive |
| MoNuSeg | GoogleDrive |
| Dataset | weight(Ours-B) |
|---|---|
| PanNuke123 | GoogleDrive |
| PanNuke213 | GoogleDrive |
| PanNuke321 | GoogleDrive |
PanNuke:
python main.py --config pannuke123.py --output_dir stage1_pannuke123 --model-ema
# python main.py --config pannuke213.py --output_dir stage1_pannuke213 --model-ema
# python main.py --config pannuke321.py --output_dir stage1_pannuke321 --model-emaCPM17:
python main.py --config cpm17.py --output_dir stage1_cpm17 --model-emaMoNuSeg:
python main.py --config monuseg.py --output_dir stage1_monuseg --model-emaPanNuke:
python predict_prompts.py --config pannuke123.py --resume checkpoint/stage1_pannuke123/best.pth
# python predict_prompts.py --config pannuke213.py --resume checkpoint/stage1_pannuke213/best.pth
# python predict_prompts.py --config pannuke321.py --resume checkpoint/stage1_pannuke321/best.pthCPM17:
python predict_prompts.py --config cpm17.py --resume checkpoint/stage1_cpm17/best.pthMoNuSeg:
python predict_prompts.py --config monuseg.py --resume checkpoint/stage1_monuseg/best.pthDownload the SAM pretrained weights from the official Segment Anything release and place them under:
pretrained/
sam_vit_b_01ec64.pth
sam_vit_h_4b8939.pth
PanNuke:
python main.py --config pannuke123_h.py --output_dir pannuke123_h
# python main.py --config pannuke213_h.py --output_dir pannuke213_h
# python main.py --config pannuke321_h.py --output_dir pannuke321_hCPM17:
python main.py --config cpm17_h.py --output_dir cpm17_hMoNuSeg:
python main.py --config monuseg_h.py --output_dir monuseg_hExamples:
python main.py --resume checkpoint/pannuke123_h/best.pth --eval --config pannuke123_h.py
python main.py --resume checkpoint/cpm17_h/best.pth --eval --config cpm17_h.py
python main.py --resume checkpoint/monuseg_h/best.pth --eval --config monuseg_h.py