8000 GitHub - ai4colonoscopy/PraNet-V2: PraNet-V2: Upgrading PraNet from binary (V1) to multi-class (V2) segmentation . Support both Jittor & PyTorch DL frameworks.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PraNet-V2: Upgrading PraNet from binary (V1) to multi-class (V2) segmentation . Support both Jittor & PyTorch DL frameworks.

License

Notifications You must be signed in to change notification settings

ai4colonoscopy/PraNet-V2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PraNet-V2: Dual-Supervised Reverse Attention for Medical Image Segmentation

Bo-Cheng Hu 1,  Ge-Peng Ji 2,  Dian Shao 3,  Deng-Ping Fan 1 
1 Nankai University  2 Australian National University  3 Northwestern Polytechnical University 
vis.mp4

πŸ”₯NewsπŸ”₯

  • Apr 15, 2025: πŸŽ‰ We are excited to introduce the inference code for the PraNet series models (PraNet-V1, PVT-PraNet-V1, PraNet-V2, PVT-PraNet-V2) running on the Jittor framework! Performance evaluation and inference speed tests have shown that Jittor significantly boosts inference speed compared to the PyTorch framework. Give it a try and feel the difference! ✨😊

  • Apr 15, 2025: πŸš€ Released training/testing code! PraNet-V2 now supports both

    πŸ”Ή Binary Segmentation (e.g., polyp segmentation) 🩺

    πŸ”Ή Multi-Class Segmentation (e.g., multi-organ/tissue segmentation) 🌈

    Explore the training and testing details in their respective directories or follow the detailed setup steps below in this README! πŸŽ‰

Overview

Abstract

Accurate medical image segmentation is essential for effective diagnosis and treatment. PraNet-V1 enhanced polyp segmentation by introducing a parallel reverse attention (RA) module that leverages background information. However, it is limited in handling complex multi-organ segmentation within medical imaging datasets. To extend the applicability of RA to a broader range of medical imaging tasks, we propose a Dual-Supervised Reverse Attention (DSRA) module, which incorporates explicit background supervision, independent background modeling structure and semantically enriched attention fusion. Based on DSRA, we develop the PraNet-V2 framework, which shows strong performance across diverse polyp segmentation datasets. Additionally, leveraging DSRA as a plug-and-play module, we integrate DSRA into three state-of-the-art models for medical image semantic segmentation and achieved a maximum improvement of 1.36% in the Dice score compared to their original performances.

Framework Overview

pipline

Quantitative Results

Quantitative3

Quantitative2

Qualitative Results

Qualitative1

Usage

Environment Setup

git clone git@github.com:ai4colonoscopy/PraNet-V2.git
cd PraNet-V2
# We use Python3.9, CUDA 12.2, PyTorch2.0.1.
conda env create -f pranet2.yaml
conda activate pranet2
cd PraNet-V2

Dataset Preparation

  1. Polyp datasets
    • To download the training and testing datasets, use this Google Drive Link and place it in the directory ./binary_seg/data.
  2. ACDC and Synapse datasets

Backbones Preparation

We also require the pre-trained weights for PVTV2B2, Res2Net, and VIT, Please click here to download them 🎯. Then, make sure to place the files in the following locations:

  1. πŸ—‚οΈ pvt_v2_b2.pth (ckpt):

    • ./binary_seg/models
    • ./multiclass_seg/EMCAD/pretrained_pth/pvt
  2. πŸ—‚οΈ maxvit_rmlp_small_rw_224_sw-6ef0ae4f.pth (ckpt) and maxxvit_rmlp_small_rw_256_sw-37e217ff.pth (ckpt):

    • ./multiclass_seg/MERIT/maxvit
    • ./multiclass_seg/MIST/maxvit
  3. πŸ—‚οΈ res2net50_v1b_26w_4s-3cf99910.pth (ckpt):

    • ./binary_seg/models

πŸ“‹ The final file organization should look like this:

binary
β”œβ”€β”€ models
β”‚   β”œβ”€β”€ pvt_v2_b2.pth
β”‚   β”œβ”€β”€ res2net50_v1b_26w_4s-3cf99910.pth
β”œβ”€β”€ ...

multi-class
β”œβ”€β”€ EMCAD
β”‚   β”œβ”€β”€ pretrained_pth
β”‚   β”‚   β”œβ”€β”€ pvt
β”‚   β”‚   β”‚   β”œβ”€β”€ pvt_v2_b2.pth
β”‚   β”œβ”€β”€ ...
β”œβ”€β”€ MIST
β”‚   β”œβ”€β”€ pretrained_pth
β”‚   β”‚   β”œβ”€β”€ maxvit
β”‚   β”‚   β”‚   β”œβ”€β”€ maxvit_rmlp_small_rw_224_sw-6ef0ae4f.pth
β”‚   β”‚   β”‚   β”œβ”€β”€ maxxvit_rmlp_small_rw_256_sw-37e217ff.pth
β”‚   β”œβ”€β”€ ...
β”œβ”€β”€ MERIT
β”‚   β”œβ”€β”€ pretrained_pth
β”‚   β”‚   β”œβ”€β”€ maxvit
β”‚   β”‚   β”‚   β”œβ”€β”€ maxvit_rmlp_small_rw_224_sw-6ef0ae4f.pth
β”‚   β”‚   β”‚   β”œβ”€β”€ maxxvit_rmlp_small_rw_256_sw-37e217ff.pth
β”‚   β”œβ”€β”€ ...

Model Weights Preparation

πŸ“¦ Before running the training or inference scripts, make sure to grab the pre-trained model weights πŸ”—.

PraNet-V2 series

We provide RES-V1.pth for PraNet-V1, RES-V2.pth for PraNet-V2, PVT-V1.pth for PVT-PraNet-V1 and PVT-V2.pth for PVT-PraNet-V2.

We recommend to organize the PraNet series models under ./binary_seg/snapshots following the structure below:

snapshots
β”œβ”€β”€ PraNet-V1
β”‚   └── RES-V1.pth
β”œβ”€β”€ PraNet-V2
β”‚   └── RES-V2.pth
β”œβ”€β”€ PVT-PraNet-V1
β”‚   └── PVT-V1.pth
└── PVT-PraNet-V2
    └── PVT-V2.pth

Multi-class segmentation models

For the multi-class segmentation models, place our trained models in their respective model_pth folders. For example:

  • EMCAD_Synapse.pth ---> ./multiclass_seg/EMCAD/model_pth/Synapse/EMCAD_Synapse.pth
  • MIST_ACDC.pth ---> ./multiclass_seg/MIST/model_pth/ACDC/MIST_ACDC.pth
  • MIST_Synapse.pth ---> ./multiclass_seg/MIST/model_pth/Synapse/MIST_Synapse.pth

Training

PraNet-V2 series

The data path is pre-configured. Follow the TODO markers in MyTrain_med.py to set the model save path and select the training model type. (PraNet-V2 with ResNet50 as the backbone; PVT-PraNet-V2 with PVTV2B2 as the backbone)

cd ./binary_seg
python -W ignore ./MyTrain_med.py --model_type PraNet-V2 # train PraNet-V2 with resnet50
python -W ignore ./MyTrain_med.py --model_type PVT-PraNet-V2 # train PVT-PraNet-V2 with PVTV2B2

Multi-class segmentation models

You’ll also need to provide the dataset paths for your environment by following the TODO markers in the training scripts. Once done, run the command:

export CUDA_VISIABLE_DEVICES=0 # using single GPU 

### train MERIT (w/ DSTA)###
cd ./multiclass_seg/MERIT
# On ACDC dataset
python -W ignore train_ACDC.py --dual

### train MIST (w/ DSTA)###
cd ./multiclass_seg/MIST
# On ACDC dataset
python -W ignore ACDC_train_test.py --dual
# On Synapse dataset
python -W ignore Synapse_train.py --dual

### train EMCAD (w/ DSTA)###
cd ./multiclass_seg/EMCAD
# On Synapse dataset
python -W ignore train_synapse.py --dual

inference

PraNet-V2 series

Please don’t forget to fill in the model path and segmentation result save path as guided by the TODO markers in ./binary_seg/MyTest.py. Once done, run the following command:

cd ./binary_seg
python -W ignore ./MyTest_med.py

The polyp segmentation results will be saved in your predefined result save path. πŸ“‚

After that, follow the steps in the Evaluation section to obtain all the metrics! πŸ“Š

Multi-class segmentation models

Next, update the dataset path and model path in the test script based on the TODO markers. We recommend changing the default values directly to avoid overly long command-line arguments. For example:

parser.add_argument('--volume_path', type=str, default='./data/synapse/test_vol_h5_new', help='root dir for validation volume data') # TODO: replace with actual path

Finally, run the corresponding inference scripts to get test results (πŸ“Logs will be saved in ./test_log) :

export CUDA_VISIABLE_DEVICES=0 # using single GPU

# MIST 
cd ./multiclass_seg/MIST
python -W ignore Synapse_test.py --dual
python -W ignore test_ACDC.py --dual

# EMCAD
cd ./multiclass_seg/EMCAD --dual
python -W ignore test_synapse.py --dual

# 【Visualization】 Use the –is_savefig option to save visualization results, e.g., python -W ignore Synapse_test.py --is_savefig.

Evaluation

PraNet-V2 series

For the PraNet series models, follow the inference steps to generate segmentation results, which will be saved in the results folder. Afterward, run the eval.py script to generate a performance evaluation table in the eval_results folder.

cd ./binary
python -W ignore ./eval.py

The eval.py script provides four eval_config options for evaluating the performance of the following models: PraNet-V1、PVT-PraNet-V1、PraNet-V2、PVT-PraNet-V2. You can try different configs in the script to check out the evaluation results for these models.

Multi-class segmentation models

For the three multi-class segmentation models, the evaluation results are already logged in the test_log folder during the inference step.

Segmentation Results

To facilitate reproducibility and further analysis, we provide our segmentation predictions alongside their ground truth for both binary segmentation and multi-class segmentation tasks. 🎯

Acknowledgement

A huge thanks to the following excellent works: PraNet, Polyp-PVT, UACANet, CASCADE, MERIT, MIST, and EMCAD. πŸ™Œβœ¨

Bibtex

@article{hu2025pranet2,
  title={PraNet-V2: Dual-Supervised Reverse Attention for Medical Image Segmentation},
  author={Hu, Bo-Cheng and Ji, Ge-Peng and Shao, Dian and Fan, Deng-Ping},
  journal={arXiv preprint arXiv:2504.10986},
  year={2025},
}

About

PraNet-V2: Upgrading PraNet from binary (V1) to multi-class (V2) segmentation . Support both Jittor & PyTorch DL frameworks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages

0