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

✨ WACV 2023 ✨

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

*Equal contribution

Figure 1. (a) The overview of the proposed HiFormer. HiFormer consists of a hierarchical CNN-transformer feature extractor module; outputs of the first and last levels are fed through the DLF feature fusion module. Afterward, the decoder uses the DLF’s output to generate accurate segmentation maps. In the diagram, blue and orange blocks denote Swin Transformer and CNN levels, respectively. (b) The overview of Cross Attention. The class token of the small level, CLSs, is first projected for dimension alignment and then appended to Pl. The resulting embedding performs as a key and value. Moreover, CLS s is utilized for the query. Finally, after computing attention and back projection, Zs is obtained. This process can also be extended to the large level.

Abstract

Convolutional neural networks (CNNs) have been the consensus for medical image segmentation tasks. However, they suffer from the limitation in modeling long-range dependencies and spatial correlations due to the nature of convolution operation. Although transformers were first developed to address this issue, they fail to capture low-level features. In contrast, it is demonstrated that both local and global features are crucial for dense prediction, such as segmenting in challenging contexts. In this paper, we propose HiFormer, a novel method that efficiently bridges a CNN and a transformer for medical image segmentation. Specifically, we design two multi-scale feature representations using the seminal Swin Transformer module and a CNN-based encoder. To secure a fine fusion of global and local features obtained from the two aforementioned representations, we propose a Double-Level Fusion (DLF) module in the skip connection of the encoder-decoder structure. Extensive experiments on various medical image segmentation datasets demonstrate the effectiveness of HiFormer over other CNN-based, transformer-based, and hybrid methods in terms of computational complexity, and quantitative and qualitative results. Our code is publicly available at: https://github.com/amirhossein-kz/HiFormer

Experiments

Table 1. The proposed model configurations. WS represents window size, D expresses the embedding dimension, and r denotes the MLP expanding ratio used in the transformer block. The number of heads in the DLF module is the same for both levels.
ModelCNNSwin TransformerDLF
Dimension
D# Layer# HeadWSPsPlSLr# Head
HiFormer-SResNet3496[2,2,6][3,6,12]7384961113
HiFormer-BResNet5096[2,2,6][3,6,12]7384962126
HiFormer-LResNet3496[2,2,6][3,6,12]7384964146
Segmentation results of the proposed method on the Synapse dataset. The red rectangles identify organ regions where the
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.
Table 2. Comparison results of the proposed method on the Synapse dataset. Blue indicates the best result, and red displays the second-best.
MethodsDSC ↑HD ↓AortaGallbladderKidney(L)Kidney(R)LiverPancreasSpleenStomach
DARR [24]69.77-74.7453.7772.3173.2494.0854.1889.9045.96
R50 U-Net [13]74.6836.8787.7463.6680.6078.1993.7456.9085.8774.16
U-Net [43]76.8539.7089.0769.7277.7768.6093.4353.9886.6775.58
R50 Att-UNet [13]75.5736.9755.9263.9179.2072.7193.5649.3787.1974.95
Att-UNet [44]77.7736.0289.5568.8877.9871.1193.5758.0487.3075.75
R50 ViT [13]71.2932.8773.7355.1375.8072.2091.5145.9981.9973.95
TransUnet [13]77.4831.6987.2363.1381.8777.0294.0855.8685.0875.62
Swin-Unet [10]79.1321.5585.4766.5383.2879.6194.2956.5890.6676.60
LeVit-Unet [55]78.5316.8478.5362.2384.6180.2593.1159.0788.8672.76
DeepLabv3+ (CNN) [16]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
Table 3. Performance comparison of the proposed method against the SOTA approaches on skin lesion segmentation benchmarks. Blue indicates the best result, and red displays the second-best.
MethodsISIC 2017ISIC 2018PH2
DSCSESPACCDSCSESPACCDSCSESPACC
U-Net [43]0.81590.81720.96800.91640.85450.88000.96970.94040.89360.91250.95880.9233
Att-UNet [44]0.80820.79980.97760.91450.85660.86740.98630.93760.90030.92050.96400.9276
DAGAN [34]0.84250.83630.97160.93040.88070.90720.95880.93240.92010.83200.96400.9425
TransUNet [13]0.81230.82630.95770.92070.84990.85780.96530.94520.88400.90630.94270.9200
MCGU-Net [1]0.89270.85020.98550.95700.89500.84800.98600.95500.92630.83220.97140.9537
MedT [48]0.80370.80640.95460.90900.83890.82520.96370.93580.91220.84720.96570.9416
FAT-Net [52]0.85000.83920.97250.93260.89030.91000.96990.95780.94400.94410.97410.9703
TMU-Net [42]0.91640.91280.97890.96600.90590.90380.97460.96030.94140.93950.97560.9647
Swin-Unet [10]0.91830.91420.97980.97010.89460.90560.97980.96450.94490.94100.95640.9678
DeepLabv3+ (CNN) [16]0.91620.87330.99210.96910.88200.85600.97700.95100.92020.88180.98320.9503
HiFormer-S0.92380.91530.98320.96950.90790.89340.98010.96180.94550.97370.96040.9646
HiFormer-B0.92530.91550.98400.97020.91020.91190.97550.96210.94600.94200.97720.9661
HiFormer-L0.92250.90460.98560.96930.90530.88280.98200.96110.94510.95610.96910.9659
Table 4. Performance evaluation on the SegPC challenge.
MethodsmIOU
Frequency recalibration U-Net [3]0.9392
XLAB Insights [7]0.9360
DSC-IITISM [7]0.9356
Multi-scale attention deeplabv3+ [7]0.9065
U-Net [43]0.7665
Contextual attention [42]0.9395
HiFormer-S0.9392
HiFormer-B0.9406
HiFormer-L0.9395
Figure 3. Visual comparisons of different methods on the ISIC2017 skin lesion segmentation dataset. Ground truth boundaries are shown in green, and predicted boundaries are shown in blue.
Figure 4. Visual representation of the proposed method on the SegPC cell segmentation dataset.

Ablation Study

Table 5. Comparison of model parameters.
Model# Params (M)DSC ↑HD ↓
TransUnet105.2877.4831.69
Swin-Unet27.1779.1321.55
LeVit-Unet52.1778.5316.84
DeepLabv3+ (CNN)59.5077.6339.95
HiFormer-S23.2580.2918.85
HiFormer-B25.5180.3914.70
HiFormer-L29.5280.6919.14
Table 6. Impact of the DLF module on the Synapse dataset.
ModelDLFDSC ↑HD ↓
HiFormer-B✗77.1516.88
HiFormer-B✓80.3914.70
Table 7. Comparison of different backbones for the CNN module on the Synapse dataset. Except for the CNN module, all configurations are identical to HiFormer-B.
Model# Params (M)DSC ↑HD ↓
HiFormer+ResNet1819.3677.1516.88
HiFormer+ResNet3424.7579.3922.71
HiFormer+ResNet5025.5180.3914.70
HiFormer+ResNet10144.5079.4217.18
HiFormer+DenseNet12123.9278.6516.18
HiFormer+DenseNet16929.5578.7315.94
HiFormer+DenseNet20135.3679.0821.30

Discussion

Table 8. Ablation study for the DLF module with different parameters on the Synapse dataset. For a fair comparison, ResNet-50 has been used as the CNN module in all the configurations, and r denotes the MLP expanding ratio used in the transformer block of the DLF module.
ModelDimension# HeadsParams
PsPlSLrPsPlDSC ↑HD ↓(M)
HiFormer-B384962126680.3914.7025.51
A3849621212679.0015.8125.51
B384962123377.9519.1125.51
C384962116679.3516.5224.90
D384962136679.2217.9626.12
E384961126679.4820.1524.33
F384962226678.8619.7525.59

BibTeX

@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 (WACV)},
  pages     = {6191--6201},
  year      = {2023},
  doi       = {10.1109/WACV56688.2023.00614}
}