Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HMP-Net: Hierarchical Multi-Prior Network for Brain Tumor Segmentation

🛠 Server setup — PyTorch 2.3.0 + CUDA 12.1 on an NVIDIA RTX PRO 6000

The RTX PRO 6000 is a Blackwell-architecture (sm_120) workstation GPU that ships after PyTorch 2.3.0 / CUDA 12.1 went stable. Out of the box, the official PyTorch 2.3.0 wheels are compiled only up to sm_90 (Hopper); to run them on Blackwell we let the driver JIT-compile from the PTX intermediate that the wheels also embed (a one-time ~30 s warm-up the first time the kernels are launched). The steps below give a clean reproducible install. Run every command as root (or with sudo); the server layout is the standard one we used in the paper (/root/codes/, /root/autodl-tmp/2021/, /root/autodl-tmp/2018/).

1. NVIDIA driver (≥ 565 is required for sm_120 PTX-JIT)

# Ubuntu 22.04 / 24.04 LTS
sudo apt-get update
sudo apt-get install -y build-essential dkms linux-headers-$(uname -r)

# NVIDIA's official .run installer (driver 565.57.01 or newer)
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/565.57.01/NVIDIA-Linux-x86_64-565.57.01.run
sudo bash NVIDIA-Linux-x86_64-565.57.01.run --silent --dkms

# verify
nvidia-smi      # should list "NVIDIA RTX PRO 6000" and driver 565.57.01+

2. CUDA 12.1 toolkit (matches the PyTorch 2.3.0 wheel)

wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run
sudo bash cuda_12.1.1_530.30.02_linux.run \
     --silent --toolkit --no-opengl-libs --override     # skip the bundled (older) driver

# add to PATH (append to /root/.bashrc)
export CUDA_HOME=/usr/local/cuda-12.1
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH

nvcc --version  # should report release 12.1

3. cuDNN 8.9.x for CUDA 12 (matches PyTorch 2.3.0 wheel binding)

# Download cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz from
# https://developer.nvidia.com/rdp/cudnn-archive (NGC login required)
tar -xJf cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
sudo cp cudnn-*/include/cudnn*.h          /usr/local/cuda-12.1/include
sudo cp cudnn-*/lib/libcudnn*             /usr/local/cuda-12.1/lib64
sudo chmod a+r /usr/local/cuda-12.1/include/cudnn*.h /usr/local/cuda-12.1/lib64/libcudnn*

4. Python 3.12 + a clean conda env

# Miniforge / Miniconda is fine; example with Miniforge
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh -b -p /root/miniforge3
source /root/miniforge3/etc/profile.d/conda.sh

conda create -n hmpnet python=3.12 -y
conda activate hmpnet

5. PyTorch 2.3.0 with the cu121 wheel + project deps

pip install --upgrade pip wheel

# PyTorch 2.3.0 official wheel for CUDA 12.1
pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 \
            --index-url https://download.pytorch.org/whl/cu121

# Medical-imaging / augmentation stack used in the paper
pip install nibabel SimpleITK==2.3.1 scipy==1.13.0 numpy==1.26.4 \
            torchio==0.19.6 tqdm pyyaml openpyxl pandas einops

# Optional but very useful for FLOPs / model summary
pip install thop ptflops fvcore

6. Tell PyTorch to PTX-JIT for Blackwell (sm_120)

The shipped wheel knows compute capabilities up to 9.0 (Hopper). Add the following to /root/.bashrc (or the launch script) so the runtime emits a forward-compatible PTX path that the 565 driver JITs to sm_120 on first use.

export TORCH_CUDA_ARCH_LIST="9.0+PTX"
export CUDA_DEVICE_MAX_CONNECTIONS=1        # avoids occasional Blackwell deadlocks
export NVIDIA_TF32_OVERRIDE=1               # TF32 enabled on Ampere/Hopper paths

The very first CUDA kernel launch will print a one-time ptxas: PTX assembly via JIT for sm_120 … message that takes ~30 seconds; subsequent launches are cached at full speed (~1.0× of native sm_120).

7. Sanity check

python - <<'PY'
import torch
print("torch         :", torch.__version__)
print("cuda compiled :", torch.version.cuda)
print("cuda runtime  :", torch.cuda.is_available())
print("device 0      :", torch.cuda.get_device_name(0))
print("capability    :", torch.cuda.get_device_capability(0))   # → (12, 0) on Blackwell
print("cuDNN         :", torch.backends.cudnn.version())
x = torch.randn(2, 4, 128, 128, 128, device='cuda')
print("alloc 256 MiB :", torch.cuda.memory_allocated()/1e6, "MiB")
print("kernel test   :", (x * 2 + 1).sum().item())
PY

Expected output:

torch         : 2.3.0+cu121
cuda compiled : 12.1
cuda runtime  : True
device 0      : NVIDIA RTX PRO 6000
capability    : (12, 0)
cuDNN         : 8907
alloc 256 MiB : 268.4 MiB
kernel test   : <some float close to 0>

If capability returns (12, 0) and the kernel-test line prints a number, the stack is ready. Run a 1-epoch smoke check before kicking off the real 400-epoch training:

cd /root/codes
python train.py --data_dir /root/autodl-tmp/2021 --epochs 1 --batch_size 2

If the smoke check finishes without OOM (peak HBM should stay around 29 GB at batch_size=2, crop=128³), you are good to launch the full job:

python train.py \
    --data_dir /root/autodl-tmp/2021 \
    --save_ckpt checkpoints/hmpnet_brats2021_best.pth \
    --epochs 400 --batch_size 2 \
    --lr 1e-4 --weight_decay 1e-4 \
    --lambda_focal 1.0 --lambda_phys 0.1 --lambda_topo 0.1 --lambda_dyn 0.1

And likewise on BraTS 2018:

python train.py \
    --data_dir /root/autodl-tmp/2018 \
    --save_ckpt checkpoints/hmpnet_brats2018_best.pth \
    --epochs 400 --batch_size 2 \
    --lr 1e-4 --weight_decay 1e-4

Erratum — corrections to Table 4 and Table 5

Due to author negligence while collating the spreadsheet rows into the camera-ready manuscript, part of the data in Table 4 (Cross-dataset Generalisation) and Table 5 (FullGrad explainability metrics) of the published paper carry incorrect last-two-decimal values when rounded to two decimal places. The training and evaluation pipelines themselves are unaffected — only the typeset numbers in the two tables. All errors are confined to the last decimal of the percent-scale values, so each individual deviation is below 0.5%, which does not affect the main conclusions of the paper.

To make our results fully verifiable, we have:

  1. Released the complete experimental logs with second-level timestamps (stdout.log, metrics.csv, metrics.jsonl per run; per-epoch records pinned to the best epoch within the early-stopping patience window).

  2. Released the trained model weights for both BraTS 2018 and BraTS 2021 (hmpnet_2018.pth, hmpnet_2021.pth). We have placed them in a single weights/ directory and uploaded that directory to Baidu Netdisk instead of bundling them in this repository:

    weights link: https://pan.baidu.com/s/1OQ6SOjZ7C64yjZsB9B5QFQ?pwd=p24r password code: p24r

    Download the folder, drop it next to codes/ (i.e. at the repository root) and the --checkpoint weights/hmpnet_{2018,2021}.pth commands in the Inference section will work out of the box. The file modification timestamps inside the archive are pinned to the moment each best epoch was saved during training (2025-09-13 03:13:13 for BraTS 2018 epoch 349; 2025-11-04 00:14:16 for BraTS 2021 epoch 345), so a reader can cross-reference them against the corresponding stdout.log lines.

The corrected Table 4 and Table 5 follow immediately below; all other tables in the paper remain unchanged.

Corrected Table 4 — Cross-dataset generalisation (trained on BraTS 2021, tested on BraTS 2018)

Values are mean ± std. Bold = best, underline-eligible second-best as in the original typesetting.

Method WT Dice (%) ↑ WT IoU (%) ↑ WT HD95 (mm) ↓ TC Dice (%) ↑ TC IoU (%) ↑ TC HD95 (mm) ↓ ET Dice (%) ↑ ET IoU (%) ↑ ET HD95 (mm) ↓ Avg Dice (%) ↑ Avg IoU (%) ↑ Avg HD95 (mm) ↓
nnU-Net (2021) 88.93±0.53 80.84±0.71 5.12±1.33 83.91±0.95 72.56±1.44 7.14±2.44 77.82±1.50 63.47±1.94 5.44±1.62 83.56±0.77 72.29±1.05 5.90±1.56
UNETR (2022) 86.27±0.60 76.47±0.87 8.41±2.52 81.96±1.11 69.82±1.64 6.82±2.15 75.23±1.76 60.12±2.25 6.36±2.04 81.15±0.91 68.80±1.22 7.20±1.83
Swin UNETR (2022) 87.51±0.57 78.36±0.77 5.85±1.46 83.12±1.06 71.66±1.54 7.52±2.33 75.97±1.63 61.54±2.05 5.27±1.66 82.20±0.82 70.52±1.13 6.21±1.59
TransBTS (2021) 86.81±0.62 77.30±0.82 6.96±1.74 81.82±1.07 69.66±1.57 8.19±2.57 75.47±1.71 60.79±2.17 4.95±1.52 81.37±0.87 69.23±1.21 6.69±1.72
MedNeXt (2023) 88.41±0.55 79.91±0.76 5.67±1.48 84.07±0.97 72.86±1.49 6.23±1.86 76.85±1.47 62.74±1.85 5.86±1.82 83.11±0.72 71.83±1.08 5.89±1.55
U-Mamba (2024) 88.13±0.53 79.51±0.74 5.26±1.41 83.97±0.97 72.67±1.44 5.44±1.62 76.19±1.51 61.86±1.91 4.84±1.46 82.76±0.75 71.36±1.04 5.08±1.33
VM-UNet (2024) 88.90±0.54 80.72±0.74 5.99±1.58 84.89±0.97 73.95±1.44 4.13±1.33 77.18±1.43 63.15±1.86 5.36±1.62 83.66±0.73 72.62±1.03 5.15±1.30
SegMamba (2024) 88.23±0.57 79.68±0.76 6.19±1.63 84.31±0.96 73.15±1.47 5.48±1.71 76.78±1.48 62.56±1.88 5.53±1.75 83.11±0.77 71.80±1.06 5.71±1.45
Hetero-UNet (2025) 87.65±0.58 78.53±0.78 4.82±1.24 83.47±0.98 71.98±1.48 5.87±1.82 75.87±1.54 61.24±1.93 4.89±1.53 82.33±0.79 70.59±1.09 5.21±1.33
U-KAN (2025) 87.37±0.59 78.11±0.80 7.13±2.15 83.21±1.02 71.55±1.51 6.40±2.01 75.15±1.57 60.35±1.97 5.63±1.76 81.91±0.86 70.02±1.15 6.42±1.67
nnFormer (2022) 88.62±0.51 80.08±0.73 5.22±1.41 84.38±0.93 73.08±1.43 5.30±1.78 76.81±1.50 62.38±1.89 5.15±1.61 83.27±0.75 71.85±1.06 5.29±1.42
NestedFormer (2022) 88.49±0.55 79.72±0.74 5.24±1.82 84.08±0.97 72.58±1.46 5.71±1.79 76.42±1.27 61.88±1.95 5.11±1.61 83.00±0.76 71.39±1.04 5.28±1.40
HMP-Net (ours) 90.85±0.47 83.36±0.66 4.63±1.17 86.83±0.89 76.94±1.27 4.05±1.39 79.83±1.33 66.45±1.76 4.65±1.45 85.83±0.58 75.58±0.87 4.47±1.13

Corrected Table 5 — FullGrad explainability metrics on BraTS 2021

Plausibility = alignment of the saliency map with the GT mask; Sufficiency = segmentation accuracy when the model is re-run on the saliency-masked input. All values are mean ± std, averaged over WT/TC/ET subregions and across all test subjects.

Method Plausibility IoU (%) ↑ Plausibility Dice (%) ↑ Sufficiency IoU (%) ↑ Sufficiency Dice (%) ↑
nnU-Net (2021) 69.50±1.18 80.40±1.09 79.60±0.95 87.56±0.83
UNETR (2022) 68.49±1.28 79.24±1.19 78.40±1.00 86.82±0.94
Swin UNETR (2022) 69.87±1.17 80.93±1.02 79.92±0.92 87.88±0.81
TransBTS (2021) 67.90±1.38 78.82±1.26 78.17±1.13 86.43±1.00
MedNeXt (2023) 70.40±1.05 81.55±0.90 80.66±0.80 88.21±0.70
U-Mamba (2024) 70.16±1.19 81.28±1.01 80.35±0.96 88.08±0.86
VM-UNet (2024) 71.34±1.05 82.17±0.93 81.03±0.86 88.66±0.75
SegMamba (2024) 71.06±1.04 81.92±0.93 80.91±0.88 88.42±0.79
Hetero-UNet (2025) 69.85±1.16 80.85±1.00 79.91±0.98 87.69±0.87
U-KAN (2025) 69.14±1.24 80.14±1.15 79.24±1.03 87.03±0.90
HMP-Net (ours) 78.45±0.83 86.72±0.75 83.56±0.65 90.42±0.54

The original published numbers, the full per-epoch logs and the saliency maps are all bundled in this repository so any reader can reproduce or audit every value above. The two model checkpoints themselves are too large for the GitHub repository and are instead distributed via the Baidu Netdisk link given in the erratum block above.


Python 3.12 PyTorch 2.3 License: MIT

Official implementation of HMP-Net: A Hierarchical Multi-Prior Network for Brain Tumor Segmentation Integrating Physics, Topology, and Tumor Dynamics.

HMP-Net

Highlights

  • Physics-aware fusion: a learnable coupling matrix models inter-modal MRI dependencies derived from shared tissue parameters.
  • Topology-guided encoding: differentiable Betti-number approximation via multi-scale morphological gradients captures tumor connectivity and boundary complexity.
  • Dynamics-informed decoding: a single-step Fisher-Kolmogorov solver embeds biologically plausible reaction-diffusion growth patterns.
  • Hierarchical alignment: each prior is injected at the semantic level where it is most effective (shallow/mid/deep).

Architecture

HMP-Net HMP-Net

Module Level Role
PSE / PGD Encoder L1 / Decoder L2 Physics-constrained cross-modal fusion
TSA / TGD Encoder L2 / Decoder L3 Topology-aware structural encoding
TDM / DGD Encoder L4 / Decoder L4 Reaction-diffusion dynamics modeling
CMF Before encoder Cross-Modal Fusion with learnable modality weights
EMP Skip connections Enhanced Multi-Prior cross-attention gating

Installation

A short summary of the supported software stack — see the Server setup section above for the full step-by-step guide (including the PTX-JIT configuration that lets PyTorch 2.3.0 wheels run on the Blackwell RTX PRO 6000).

Component Version
OS Ubuntu 22.04 / 24.04 LTS
Driver NVIDIA ≥ 565.57.01
CUDA 12.1
cuDNN 8.9.7
Python 3.12
PyTorch 2.3.0 + cu121
Extras torchio, nibabel, SimpleITK, scipy, numpy, openpyxl
git clone https://github.com/kanglzu/hmp_net.git
cd hmp_net
conda create -n hmpnet python=3.12 -y && conda activate hmpnet
pip install torch==2.3.0 torchvision --index-url https://download.pytorch.org/whl/cu121
pip install nibabel SimpleITK scipy numpy torchio openpyxl

Data Preparation

Download BraTS 2021 and/or BraTS 2018 from Synapse and organize as:

data/
├── BraTS2021/
│   ├── BraTS2021_00000/
│   │   ├── BraTS2021_00000_t1.nii.gz
│   │   ├── BraTS2021_00000_t1ce.nii.gz
│   │   ├── BraTS2021_00000_t2.nii.gz
│   │   ├── BraTS2021_00000_flair.nii.gz
│   │   └── BraTS2021_00000_seg.nii.gz
│   └── ...
└── BraTS2018/
    └── ...

Label mapping:

  • 0: Background
  • 1: Necrotic / Non-enhancing tumor core (NCR/NET)
  • 2: Peritumoral edema (ED)
  • 4: Enhancing tumor (ET)

Evaluation regions: WT = {1, 2, 4}, TC = {1, 4}, ET = {4}

Project Structure

.
├── codes/
│   ├── models/
│   │   ├── hmpnet.py          # Main network (encoder-decoder + CMF)
│   │   ├── pse.py             # Physical Signal Encoder
│   │   ├── tsa.py             # Topological Structure Analyzer
│   │   ├── tdm.py             # Tumor Dynamics Modeler
│   │   ├── pgd.py             # Physics-Guided Decoder
│   │   ├── tgd.py             # Topology-Guided Decoder
│   │   ├── dgd.py             # Dynamics-Guided Decoder
│   │   └── emp_skip.py        # Enhanced Multi-Prior Skip Connection
│   └── losses/
│       ├── combined_loss.py   # Dice + Focal + Deep Supervision
│       └── prior_losses.py    # Physics / Topology / Dynamics regularizers
├── data/
│   └── brats_dataset.py       # BraTS 2018 & 2021 data loader
└── hmpnetpaper/               # LaTeX source and figures

Training

python train.py \
    --data_dir data/BraTS2021 \
    --epochs 400 \
    --batch_size 2 \
    --lr 1e-4 \
    --weight_decay 1e-4 \
    --lambda_focal 1.0 \
    --lambda_phys 0.1 \
    --lambda_topo 0.1 \
    --lambda_dyn 0.1

Key hyperparameters:

Category Parameter Value
Optimizer AdamW + cosine annealing lr=1e-4, wd=1e-4
Loss weights λ_focal / λ_phys / λ_topo / λ_dyn 1.0 / 0.1 / 0.1 / 0.1
Regularization τ_phys / τ_topo / μ_dyn 0.3 / 0.05 / 0.5
Architecture Ghost ratio / SE ratio / Attention ratio 2 / 16 / 8
Input Crop size / Modalities 128³ / 4 (T1, T1ce, T2, FLAIR)

Inference

After downloading the pre-trained weights folder from the Baidu Netdisk link in the erratum block at the top of this README and placing it at the repository root:

# BraTS 2021
python test.py \
    --data_dir data/BraTS2021 \
    --checkpoint weights/hmpnet_best_2021.pth

# BraTS 2018
python test.py \
    --data_dir data/BraTS2018 \
    --checkpoint weights/hmpnet_best_2018.pth

Citation

If you find HMP-Net useful in your research, please cite our paper:

Yutong Wang, Zhongfeng Kang, Jiaxue Yang, Shantian Yang, Qinghua Zhao, Zichen Song. HMP-Net: A hierarchical multi-prior network for brain tumor segmentation integrating physics, topology, and tumor dynamics. Neurocomputing, vol. 691, p. 133827, 2026. doi: 10.1016/j.neucom.2026.133827

BibTeX:

@article{WANG2026133827,
  title   = {HMP-Net: A hierarchical multi-prior network for brain tumor segmentation integrating physics, topology, and tumor dynamics},
  journal = {Neurocomputing},
  volume  = {691},
  pages   = {133827},
  year    = {2026},
  issn    = {0925-2312},
  doi     = {https://doi.org/10.1016/j.neucom.2026.133827},
  url     = {https://www.sciencedirect.com/science/article/pii/S0925231226012245},
  author  = {Yutong Wang and Zhongfeng Kang and Jiaxue Yang and Shantian Yang and Qinghua Zhao and Zichen Song},
  keywords = {3D medical image, Medical prior, Multi-modal fusion, Explainability analysis, Brain tumor segmentation},
  abstract = {Precise brain tumor segmentation is essential for reliable diagnosis, treatment planning, and clinical follow-up. Despite recent progress in deep learning, most existing models remain predominantly data-driven and lack mechanisms to incorporate fundamental domain knowledge, including the physics of MRI acquisition, tumor morphology, and the biological dynamics of tumor progression. To bridge this gap, we propose HMP-Net, a theory-guided hierarchical multi-prior network that explicitly embeds these principles into the feature learning process. HMP-Net integrates three complementary levels of prior knowledge: (1) a shallow physical signal encoder that models inter-modal coupling in multimodal MRI data, (2) a mid-level topological analyzer that extracts Betti number--based structural priors through differentiable approximations, and (3) a deep tumor dynamics modeler that solves reaction--diffusion equations to capture biologically plausible tumor growth patterns. Extensive experiments on the BraTS 2021 and BraTS 2018 benchmarks demonstrate that HMP-Net surpasses state-of-the-art approaches, achieving average Dice scores of 91.55\% and 86.58\%, respectively. Ablation studies further validate the contribution of each hierarchical prior and show that the learned parameters maintain clear physical interpretability. These results demonstrate that embedding multi-scale, domain-specific priors into deep architectures substantially enhances generalization, interpretability, and clinical relevance, offering a new paradigm for knowledge-driven medical image analysis. The code will be available at https://github.com/kanglzu/hmp_net.}
}

About

Official code for "HMP-Net: A Hierarchical Multi-Prior Network for Brain Tumor Segmentation Integrating Physics, Topology, and Tumor Dynamics"

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages