SGL-Net (Structured Global-Local Network) is a hybrid CNN-Transformer encoder-decoder framework for medical image segmentation.
The design focuses on:
- multi-granularity contextual modeling,
- dual-path feature resampling,
- local spatial-structure preservation,
- semantic-guided skip-feature alignment,
- and a reproducible segmentation framework evaluated on public datasets.
The model is composed of the following core modules:
- Multi-Granularity Attention Block (MGAB)
- Parallel Multi-Window Attention (PMWA)
- Local Spatial Injector (LSI)
- Dual-Path Reduction (DPR)
- Dual-Path Restoration (DPRestore)
- Semantic-Guided Aligner (SGA)
These modules are integrated into a U-shaped architecture with encoder-decoder feature interaction and skip-feature refinement.
Figure: Encoder-decoder structure of SGL-Net. Encoder/decoder stages use MGAB with PMWA. Downsampling uses DPR, upsampling uses DPRestore, and skip features are aligned with SGA.
conda create -n sglnet python=3.8 -y
conda activate sglnet
# Install PyTorch (adjust CUDA version as needed)
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
# Install dependencies
pip install timm einops thopOr with a requirements file:
pip install -r requirements.txtOrganize datasets under ./data/ with a train/test split per dataset.
python train.py \
--dataset ISIC-Melanoma \
--data_path ./data/ISIC-Melanoma \
--img_size 224 \
--batch_size 16 \
--num_epochs 300 \
--lr 0.001 \
--output_dir ./output/python test.py \
--dataset ISIC-Melanoma \
--data_path ./data/ISIC-Melanoma \
--img_size 224 \
--checkpoint ./output/best_model.pth \
--output_dir ./results/The Ablation Study/ directory contains controlled ablation variants:
| File | Description |
|---|---|
SGL_Net_NoSGA.py |
SGL-Net without Semantic-Guided Aligner (SGA) |
SGL_Net_NoDPR.py |
SGL-Net without Dual-Path Reduction (DPR) |
SGL_Net_NoDPRestore.py |
SGL-Net without Dual-Path Restoration (DPRestore) |
SGL_Net_NoMGAB.py |
SGL-Net without MGAB (uses standard Swin Transformer blocks) |
Swin_UNet_SGA.py |
Swin-UNet baseline + SGA |
Swin_UNet_DPR.py |
Swin-UNet baseline + DPR |
Swin_UNet_DPRestore.py |
Swin-UNet baseline + DPRestore |
Swin_UNet_MGAB.py |
Swin-UNet baseline + MGAB |
SGL-Net/
├── SGL_Net.py # Main model (Structured Global-Local Network)
├── Modules/
│ ├── MGAB.py # Multi-Granularity Attention Block (PMWA/S-PMWA)
│ ├── LSI.py # Local Spatial Injector
│ ├── DPR.py # Dual-Path Reduction
│ ├── DPRestore.py # Dual-Path Restoration
│ └── SGA.py # Semantic-Guided Aligner
├── Ablation Study/ # Ablation model variants
└── README.md
The datasets used in this study are publicly available from the following repositories:
-
2018 Data Science Bowl (DSB)
Repository: Kaggle
Link: https://www.kaggle.com/competitions/data-science-bowl-2018/data
Usage in this study: microscopy images for nuclei segmentation. -
ISIC 2017 Skin Lesion Analysis Towards Melanoma Detection
Repository: ISIC Archive
Link: https://challenge.isic-archive.com/data/
Usage in this study: dermoscopic images for melanoma and seborrheic keratosis lesion segmentation. -
Skin Lesion Dataset (SLD)
Repository: Kaggle
Link: https://www.kaggle.com/datasets/ojaswipandey/skin-lesion-dataset
Usage in this study: large-scale skin lesion images for lesion segmentation. -
Brain MRI Segmentation Dataset (BM)
Repository: Kaggle
Link: https://www.kaggle.com/datasets/mateuszbuda/lgg-mri-segmentation
Usage in this study: brain MRI scans of lower-grade glioma with pixel-level annotations.
These datasets are reference data used for experimental evaluation. No new clinical or private dataset was collected in this study. Users should follow the licenses, terms of use, and citation requirements of the original dataset providers.
The source code in this repository is provided for peer-review assessment and reproducibility of the proposed SGL-Net framework. A permanent repository link will be provided upon publication.
If you find this work useful, please cite:
@article{sglnet2025,
title = {SGL-Net: Multi-Granularity Attention and Dual-Path Feature Resampling for Efficient Medical Image Segmentation},
author = {[Author Names]},
journal = {Engineering Applications of Artificial Intelligence},
year = {2025},
volume = {},
pages = {},
doi = {}
}This repository builds on open-source efforts including Swin Transformer, Swin-UNet, and TransUNet.
