Paper Title: S3H-Net: Injecting Hybrid Semantic-Spatial Guidance via Superpixel Hypergraphs for Medical Image Segmentation
Conference: MICCAI 2026 (Submission ID: 2653)
Status: π’ Accept
- [2026-06-13] π Accept! Our paper has been accepted to MICCAI 2026!
- [2026-02-27] π Paper submitted to MICCAI 2026.
This repository contains the official PyTorch implementation of S3H-Net, a novel architecture designed to push the boundaries of medical image segmentation by integrating Superpixel-based Semantic-Spatial Hypergraphs.
Accurate medical image segmentation is often hindered by complex geometries and blurred boundaries. While graph-based methods have gained popularity, they often suffer from semantic ambiguity due to fixed-patch nodes and limited global context injection. S3H-Net overcomes these bottlenecks through a boundary-aware and multi-scale reasoning approach.
Key Contributions:
- π Boundary-Aware Node Construction: Unlike traditional patch-based methods, we utilize the Simple Linear Iterative Clustering (SLIC) algorithm for node construction. This ensures strict alignment with target contours and preserves semantic purity by avoiding the mixing of heterogeneous features.
- π§ Hybrid Semantic-Spatial Hypergraph (HSSH): We introduce a parallel Semantic Encoder built on HSSH blocks. This component captures high-order, multi-scale semantic guidance continuously across the network, rather than being restricted to bottlenecks.
- π Cross-Covariance Semantic Injection (CCSI): To bridge the gap between non-local hypergraph topology and local CNN features, the CCSI module leverages inter-channel attention to effectively inject reasoned global context into local features.
- π State-of-the-Art Performance: S3H-Net has been extensively validated across five medical imaging modalities, consistently outperforming current SOTA methods in both accuracy and robustness.
S3H-Net employs a dual-branch design, which parallels a standard CNN backbone with a Semantic Encoder based on HSSH blocks. The Semantic Encoder captures high-order semantic correlations, which are then hierarchically injected through the CCSI module to dynamically rectify local pixel-wise features.
Qualitative comparison of our S3H-Net with other SOTA methods. Oversegmented areas are marked in red, and under-segmented areas are marked in green.
We conduct comprehensive experiments on six public datasets across five medical imaging modalities:
| Dataset | Modality | Target Structure | Samples | Download |
|---|---|---|---|---|
| CVC-ClinicDB | Endoscopy | Polyp | 612 | Official Link |
| ETIS-LaribPolypDB | Endoscopy | Polyp | 196 | Kaggle |
| ISIC2018 | Dermoscopy | Skin Lesion | 2,593 | Official Link |
| USG | Ultrasound | Breast Cancer | 252 | Official Link |
| DSB2018 | Microscopy | Nuclei | 670 | Kaggle |
| PROMISE12 | MRI | Prostate | 80 (2172 slices) | Official Link |
Tip
Download Propressed Data: You can also download the data files we have collected on Quark Cloud Drive (will be open after double-blind review). All you need to do is replace the datasets directory.
Please arrange your project directory as follows:
Project_Root/
βββ datasets/
β βββ Dataset_A/
β β βββ images/ # Raw images (.tif, .png, etc.)
β β βββ masks/ # Ground truth masks
β βββ Dataset_B/
β βββ images/
β βββ masks/
βββ configs/
β βββ default.yaml # Default setting of our model
β βββ PROMISE_split.json
βββ checkpoints/ # Pre-trained weights
βββ runs/ # Logging files
βββ outputs/ # Output predictions
βββ src/ # Source code
βββ requirements.txt
βββ test.py
βββ train.py
Default Splitting Strategy:
All datasets were split into Training, Validation, and Test sets with a ratio of 8:1:1, except for PROMISE12. For PROMISE12, we strictly adhered to the official challenge split provided in PROMISE_split.json.
Custom Splitting:
If you wish to customize the data partitioning, simply create a JSON configuration file (e.g., my_split.json) with the following structure:
{
"train": [
"001.png",
"002.png",
"... (list all training filenames)"
],
"val": [
"009.png",
"... (list all validation filenames)"
],
"test": [
"010.png",
"... (list all test filenames)"
]
}Then, specify this file in your configuration (default.yaml) or via command line arguments.
Warning
Filename Consistency: When using our code, the filename of the input image must exactly >match the filename of its corresponding ground truth mask.
- β Correct: images/001.png β masks/001.png
- β Incorrect: images/001.png β masks/001_mask.png
Mismatched filenames will result in data loading errors or incorrect pairing.
We recommend using Python 3.10+ and PyTorch 2.0+. Our implementation is built on PyTorch Lightning, a high-level framework that eliminates boilerplate code to let you focus on research logic while natively supporting scalable multi-GPU training and rigorous reproducibility.
# Step 1: Create a new isolated environment named 'S3H_Net' with Python 3.12
conda create -n S3H_Net python=3.12 -y
# Step 2: Activate the environment
conda activate S3H_Net
# Step 3: Install PyTorch & Lightning Core
# This ensures CUDA compatibility. Adjust 'cu118' based on your GPU driver.
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install lightning==2.5
# Step 4: Install remaining project dependencies
pip install -r requirements.txtImportant
Reproducibility & Seed: All results in this work were generated using the random seed 3407. Our code defaults to this seed to ensure exact reproducibility of the reported metrics. If you modify the seed, slight performance variations may occur.
Our project includes a comprehensive default configuration file: configs/default.yaml. It covers all essential settings, including:
- π² Random Seed (Default:
3407for reproducibility) - π Dataset Paths & Preprocessing parameters
- ποΈ Model Architecture hyperparameters
- π Training Settings (optimizer, learning rate, epochs, early stopping)
- π Logging & Checkpoint saving paths
Note
Ready to Use: The provided default.yaml is pre-configured and ready for immediate execution. You can directly run the training scripts without modification unless you intend to customize specific hyperparameters or switch datasets.
To train the model from scratch:
python train.py --config configs/default.yamlTip
Visualize Results: PyTorch Lightning integrate TensorBoard for logging. While training is running (or after), launch the dashboard with:
tensorboard --logdir=runsThen visit http://localhost:6006 in your browser.
To evaluate the trained model:
python test.py --config configs/default.yaml --ckpt_path checkpoints/best.ckptOutput Details:
- π¨οΈ Metrics: Evaluation metrics (e.g., DSC, HD95) will be printed directly to the terminal.
- πΌοΈ Visualizations: Segmentation results for the test set will be saved automatically to the
outputs/directory.
This repo is based in part on the works of SSN-PyTorch, HGNN and ViHGNN for their open-source code. We thank the authors for their valuable contributions, which inspired and guided our implementation.
