Skip to content

IamDerrick666/SGL-Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SGL-Net: Multi-Granularity Attention and Dual-Path Feature Resampling for Efficient Medical Image Segmentation

License: MIT Python 3.8+ PyTorch


Overview

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.

Architecture Modules

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.


Architecture Figure

SGL-Net Architecture

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.


Getting Started

1. Environment Setup

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 thop

Or with a requirements file:

pip install -r requirements.txt

2. Dataset Preparation

Organize datasets under ./data/ with a train/test split per dataset.

3. Training

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/

4. Testing / Evaluation

python test.py \
    --dataset ISIC-Melanoma \
    --data_path ./data/ISIC-Melanoma \
    --img_size 224 \
    --checkpoint ./output/best_model.pth \
    --output_dir ./results/

Ablation Study Models

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

Repository Structure

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

Data Availability

The datasets used in this study are publicly available from the following repositories:

  1. 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.

  2. 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.

  3. 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.

  4. 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.


Code Availability

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.


Citation

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     = {}
}

Acknowledgments

This repository builds on open-source efforts including Swin Transformer, Swin-UNet, and TransUNet.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages