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

Moein Heidari, Amirhossein Kazerouni, Milad Soltany, Reza Azad, Ehsan Khodapanah Aghdam, Julien Cohen-Adad, Dorit Merhof

TL;DR

HiFormer is a highly efficient, hybrid encoder-decoder framework that successfully bridges Convolutional Neural Networks (CNNs) and Vision Transformers (ViTs) for medical image segmentation. By combining a hierarchical Swin Transformer with a CNN encoder through a novel Double-Level Fusion (DLF) module, it achieves state-of-the-art accuracy across multiple medical benchmarks while using up to 75% fewer parameters than competing hybrid models.

What Problem Does This Paper Address?

Accurate medical image segmentation requires a delicate balance: a model must grasp the global context (to understand overall organ boundaries and spatial relationships) while simultaneously capturing fine-grained local details (to delineate precise, complex edges).

Standard Convolutional Neural Networks (CNNs) excel at extracting local features, but their limited receptive fields mean they struggle with long-range dependencies. Conversely, Vision Transformers (ViTs) excel at capturing global context via self-attention but often miss low-level spatial details and require massive datasets to generalize well.

While hybrid CNN-Transformer architectures have emerged to solve this, they often suffer from two major flaws: they fail to maintain feature consistency when combining local and global representations across different scales, or they introduce massive computational overhead, making them impractical for real-world clinical deployment.

Methods

HiFormer introduces an elegant architecture that pairs a dual-encoder scheme with an optimized fusion mechanism:

  1. Hierarchical CNN Module: An input image is first passed through a CNN backbone (like ResNet) to extract multi-scale local semantic features across three distinct resolution levels.
  2. Hierarchical Swin Transformer Module: Sits on top of the CNN's shallow features to capture global interactions using shifted-window self-attention (W-MSA/SW-MSA). Skip connections directly feed the CNN's local features into the Transformer blocks to encourage feature reusability and preserve localization information.
  3. Double-Level Fusion (DLF) Module: Instead of naively summing or concatenating all layers, the authors introduce a cross-attention-based fusion module that targets only the largest ($P^l$) and smallest ($P^s$) feature maps. It uses Global Average Pooling (GAP) to generate a "class token" for each scale, swaps them, and computes cross-attention. This allows the network to align fine-grained spatial details with high-level semantic context in linear time, intentionally skipping the middle layer to minimize computational complexity.
  4. Decoder: Inspired by Semantic FPN, the decoder combines the refined multi-scale features from the DLF module into a unified, high-resolution segmentation mask.
Overview of the HiFormer architecture

Datasets

The authors evaluated HiFormer on three diverse medical imaging tasks:

  • Synapse Multi-Organ Segmentation: 30 abdominal CT cases featuring 8 organs (aorta, gallbladder, kidneys, liver, pancreas, spleen, and stomach).
  • Skin Lesion Segmentation: Evaluated across three benchmarks: ISIC 2017 (2,000 training images), ISIC 2018, and the $PH^2$ database.
  • Multiple Myeloma Segmentation: The SegPC 2021 grand challenge dataset, focusing on plasma cell segmentation in microscopic images.

No new datasets or benchmarks were introduced in this paper.

Key Insights and Ideas

  • The "Goldilocks" Scale Fusion: Fusing every single layer of a multi-scale network is computationally redundant. HiFormer proves that cross-attending just the shallowest (high localization) and deepest (high semantic) layers is sufficient to achieve superior consistency and accuracy.
  • Class Tokens for Cross-Scale Communication: Borrowing a concept from NLP, HiFormer uses a single pooled token to summarize an entire feature map. Swapping these tokens across scales allows the model to achieve global-local alignment with minimal computational overhead.
  • Drastic Parameter Efficiency: More parameters do not always equal better medical segmentation. HiFormer challenges the trend of bloated models, demonstrating that smart architectural bridging can outperform heavyweights while slashing parameter counts significantly.

Key Results

HiFormer consistently outperformed state-of-the-art CNN, Transformer, and hybrid models across all datasets:

  • Synapse Dataset: HiFormer-B achieved an average Dice Similarity Coefficient (DSC) of 80.39% and a 95% Hausdorff Distance (HD) of 14.70, significantly outperforming the popular TransUnet (77.48% DSC / 31.69 HD) and Swin-Unet (79.13% DSC / 21.55 HD).
  • Skin Lesion Segmentation: On the ISIC 2017 dataset, HiFormer-B achieved a top DSC of 0.9253, proving highly robust against noisy boundaries where pure transformers typically degrade.
  • Model Complexity: HiFormer-S achieves its competitive performance with just 23.25M parameters, compared to TransUnet’s massive 105.28M parameters—a reduction of roughly 78%.
Figure 2: Segmentation results of the proposed method on the Synapse dataset. The red rectangles identify organ regions where the superiority of our proposed method can be clearly seen.

Limitations and Future Work

Despite its strong performance, the authors note a few remaining challenges:

  • Low-Contrast Boundaries: Extremely low-contrast images, particularly in some skin lesion dermoscopic samples, still pose difficulties for precise boundary delineation.
  • Organ-Specific Variations: While HiFormer excels at segmenting large organs like the liver and kidneys, it occasionally encounters failure cases on highly complex, smaller structures like the Aorta.
  • Future Directions: Promising next steps include extending the hierarchical DLF framework to handle 3D medical volumes directly and exploring self-supervised pre-training strategies tailored for this hybrid design.

Summary updated

BibTeX
@inproceedings{heidari2023hiformer,
  author = {Moein Heidari and Amirhossein Kazerouni and Milad Soltany and Reza Azad and Ehsan Khodapanah Aghdam and Julien Cohen-Adad and Dorit Merhof},
  title = {{HiFormer: Hierarchical Multi-scale Representations Using Transformers for Medical Image Segmentation}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2023},
}
Figure