RepositoryJupyter NotebookCACanada
amirhossein-kz

amirhossein-kz/HiFormer

HiFormer: Hierarchical Multi-scale Representations Using Transformers for Medical Image Segmentation (WACV 2023)

149stars
22forks
0issues
0views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: medical-image-segmentation

#1 Repository of the week

1
TINIX TRENDING·Topic: multi-organ-segmentation

#1 Repository of the week

1
TINIX TRENDING·Topic: segpc

#1 Repository of the week

HiFormer: Hierarchical Multi-scale Representations Using Transformers for Medical Image Segmentation, WACV 2023

Hierarchical Multi-scale Representations for medical image segmentation with state of the art results on synapse multi-organ segmentation, skin lesion segmentation, multiple myeloma cell segmentation. This method designs two multi-scale feature representations using the seminal Swin Transformer module and a CNN-based encoder, then using a Double-Level Fusion (DLF) module, it allows a fine fusion of global and local features. If this code helps with your research please consider citing the following paper:

Moein Heidari*, Amirhossein Kazerouni*, Milad Soltany*, R. Azad, Ehsan Khodapanah Aghdam, Julien Cohen-Adad and Dorit Merhof , "HiFormer: Hierarchical Multi-scale Representations Using Transformers for Medical Image Segmentation", download link.

Please consider starring us, if you found it useful. Thanks!

Updates

This code has been implemented in python language using Pytorch library and tested in ubuntu OS, though should be compatible with related environment. following Environement and Library needed to run the code:

  • Python 3
  • Pytorch

Prepare data, Train/Test

Please go to "Instructions.ipynb" for complete detail on dataset preparation and Train/Test procedure or follow the instructions below. Open In Colab

  1. Download the Synapse Dataset from here.

  2. Run the following code to install the Requirements.

    pip install -r requirements.txt

  3. Run the below code to train HiFormer on the synapse dataset.

    python train.py --root_path ./data/Synapse/train_npz --test_path ./data/Synapse/test_vol_h5  --model_name hiformer-b --batch_size 10 --eval_interval 20 --max_epochs 400 
    

    --root_path [Train data path]

    --test_path [Test data path]

    --eval_interval [Evaluation epoch]

    --model_name [Choose from [hiformer-s, hiformer-b, hiformer-l]]

  4. Run the below code to test HiFormer on the synapse dataset.

    python test.py --test_path ./data/Synapse/test_vol_h5 --model_name hiformer-b --is_savenii --model_weight './hiformer-b_best.pth'
    

    --test_path [Test data path]

    --model_name [choose from [hiformer-s, hiformer-b, hiformer-l]]

    --is_savenii [Whether to save results during inference]

    --model_weight [HiFormer trained model path]

Quick Overview

Diagram of the proposed method

Results

For evaluating the performance of the proposed method, three challenging tasks in medical image segmentaion has been considered. In bellow, results of the proposed approach for synapse multi-organ segmentation is illustrated.

Performance Comparision on Synapse Multi-Organ Segmentation

Methods

DSC↑

HD↓

Aorta

Gallbladder

Kidney(L)

Kidney(R)

Liver

Pancreas

Spleen

Stomach

DARR69.77-74.7453.7772.3173.2494.0854.1889.9045.96
R50 U-Net74.6836.8787.7463.6680.6078.1993.7456.9085.8774.16
U-Net76.8539.7089.0769.7277.7768.6093.4353.9886.6775.58
R50 Att-UNet75.5736.9755.9263.9179.2072.7193.5649.3787.1974.95
Att-UNet77.7736.0289.5568.8877.9871.1193.5758.0487.3075.75
R50 ViT71.2932.8773.7355.1375.8072.2091.5145.9981.9973.95
TransUnet77.4831.6987.2363.1381.8777.0294.0855.8685.0875.62
SwinUnet79.1321.5585.4766.5383.2879.6194.2956.5890.6676.60
LeVit-Unet78.5316.8478.5362.2384.6180.2593.1159.0788.8672.76
DeepLabv3+ (CNN)77.6339.9588.0466.5182.7674.2191.2358.3287.4373.53
HiFormer-S80.2918.8585.6373.2982.3964.8494.2260.8491.0378.07
HiFormer-B80.3914.7086.2165.6985.2379.7794.6159.5290.9981.08
HiFormer-L80.6919.1487.0368.6184.2378.3794.0760.7790.4482.03

Perceptual visualization results on test data

Synapse Multi-Organ Segmentation result

References

Query

All implementations are done by Amirhossein Kazerouni, Milad Soltany and Moein Heidari. For any query, please contact us for more information.

amirhossein477@gmail.com

soltany.m.99@gmail.com

moeinheidari7829@gmail.com

Citation

@inproceedings{heidari2023hiformer,
  title={Hiformer: Hierarchical multi-scale representations using transformers for medical image segmentation},
  author={Heidari, Moein and Kazerouni, Amirhossein and Soltany, Milad and Azad, Reza and Aghdam, Ehsan Khodapanah and Cohen-Adad, Julien and Merhof, Dorit},
  booktitle={Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision},
  pages={6202--6212},
  year={2023}
}

Similar Projects

Discover other similar projects and AI models.

Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
157.6M
Jun 1, 2026
RepositoryPython
ai4colonoscopy/PraNet-V2

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

50
Mar 21, 2026
RepositoryPython
Significant-Gravitas/AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

188.2k
Nov 29, 2026
Modelimage-text-to-text
Qwen/Qwen3.8-27B

Qwen3.8-27B !Note This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format. These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc. !Tip F...

♥0
4.8M
Nov 7, 2026
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryTypeScript
openclaw/openclaw

The AI that really does things. Any OS. Any Platform. The lobster way. 🦞

395.6k
Dec 2, 2026
Repository
jwasham/coding-interview-university

A complete computer science study plan to become a software engineer.

365.2k
Nov 7, 2026
RepositoryShell
obra/superpowers

An agentic skills framework & software development methodology that works.

331.2k
Nov 28, 2026
RepositoryJavaScript
affaan-m/ECC

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

315.1k
Dec 1, 2026