TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation

Jieneng Chen, Yongyi Lu, Qihang Yu, Xiangde Luo, Ehsan Adeli, Yan Wang, Le Lu, Alan L. Yuille, Yuyin ZhouarXiv 2021

Abstract

Medical image segmentation requires a precise balance between global contextual understanding and local spatial localization. While Convolutional Neural Networks (CNNs) like U-Net have long been the standard, their inherent inductive bias of locality limits their ability to model long-range dependencies. TransUNet addresses this by treating image segmentation as a sequence-to-sequence prediction task. By combining a hybrid CNN-Transformer encoder with a U-shaped decoder and skip-connections, TransUNet leverages the global self-attention of Transformers and the high-resolution features of CNNs. Our experiments on abdominal and cardiac datasets demonstrate that TransUNet achieves state-of-the-art performance, particularly excelling in the segmentation of complex organ structures.

Introduction

In medical imaging, the ability to accurately segment organs and tissues is fundamental for clinical workflows. This task is challenging because it requires the model to understand the "big picture"—where an organ is located relative to others—while simultaneously identifying precise boundaries at the pixel level. Historically, the U-Net architecture has been the dominant choice, utilizing an encoder-decoder structure with skip-connections to preserve spatial detail. However, the convolution operation is fundamentally local, making it difficult for U-Nets to capture the long-range dependencies necessary for robust global context.

Recently, Transformers have revolutionized natural language processing and are increasingly applied to computer vision. Unlike CNNs, Transformers use self-attention to model global relationships across the entire input sequence. However, when applied to segmentation, "naive" Transformers often produce coarse results due to the loss of low-level spatial information. TransUNet is proposed as a hybrid framework that marries the global modeling power of Transformers with the localization capabilities of CNNs.

Methodology

TransUNet utilizes a hybrid architecture designed to capture multi-scale features while maintaining global coherence.

Hybrid Encoder

Instead of feeding raw image patches directly into a Transformer, TransUNet first employs a CNN (specifically a ResNet-50 backbone) to extract high-level feature maps. This initial step preserves essential local spatial information. These feature maps are then "tokenized" into a sequence of patches and embedded with positional information before being passed through a series of 12 Transformer layers. This allows the model to learn complex, long-range interactions between different regions of the image.

Cascaded Upsampler (CUP) and Skip-Connections

To recover the original image resolution, the model uses a Cascaded Upsampler (CUP). This decoder consists of multiple upsampling blocks that progressively increase the spatial dimensions of the Transformer's output. Crucially, TransUNet incorporates U-Net style skip-connections. High-resolution feature maps from the early CNN stages are concatenated with the upsampled features in the decoder. This integration allows the model to refine segmentation boundaries using fine-grained spatial cues that the Transformer might have smoothed over.

The TransUNet architecture: (a) Detail of the Transformer layer; (b) The overall hybrid framework combining a CNN-Transformer encoder with a cascaded upsampler and skip-connections.

Experimental Results

The effectiveness of TransUNet was evaluated on two primary benchmarks: the Synapse multi-organ segmentation dataset (abdominal CT) and the Automated Cardiac Diagnosis Challenge (ACDC) dataset (cardiac MRI).

Performance on Synapse Dataset

On the Synapse dataset, which involves segmenting eight abdominal organs, TransUNet achieved an average Dice Similarity Coefficient (DSC) of 77.48% and a Hausdorff Distance (HD) of 31.69. As shown in the table below, TransUNet significantly outperforms standard CNN-based models like U-Net (74.68% DSC) and Attention U-Net (75.57% DSC), as well as pure Transformer-based approaches.

Quantitative comparison of TransUNet against state-of-the-art frameworks on the Synapse multi-organ segmentation dataset. TransUNet achieves the highest average DSC and lowest HD.

Qualitative Analysis and Robustness

Qualitatively, TransUNet produces more anatomically consistent segmentations with sharper boundaries. For instance, it successfully identifies the internal structures of the kidneys where other models often produce fragmented or blurry results. Furthermore, on the ACDC cardiac dataset, TransUNet achieved an average DSC of 89.71%, demonstrating its robustness across different imaging modalities and organ types.

Discussion

The success of TransUNet provides several key insights into the application of Transformers in medical imaging:

  • The Necessity of the "U": The authors found that a U-shaped architecture is essential. Without skip-connections and a proper decoder, Transformers struggle with the precise localization required for medical tasks.
  • Resolution and Patch Size: Increasing the input resolution or decreasing the patch size (thereby increasing the sequence length) leads to consistent performance gains, highlighting the Transformer's ability to handle high-resolution context given sufficient computational resources.
  • Benefits for Small Organs: Interestingly, the performance boost from the hybrid architecture and skip-connections was most evident for smaller organs like the pancreas and aorta. These structures are often difficult for pure CNNs to segment accurately due to their small size and variable appearance.

Conclusion

TransUNet demonstrates that Transformers can serve as powerful encoders for medical image segmentation when integrated into a hybrid, U-shaped architecture. By effectively combining global self-attention with local spatial features, TransUNet sets a new state-of-the-art on challenging benchmarks. Future research will focus on reducing the computational complexity of the Transformer layers and exploring 3D implementations to further improve volumetric segmentation accuracy.

Summary updated

BibTeX
@misc{chen2021transunet,
  author = {Jieneng Chen and Yongyi Lu and Qihang Yu and Xiangde Luo and Ehsan Adeli and Yan Wang and Le Lu and Alan L. Yuille and Yuyin Zhou},
  title = {{TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation}},
  year = {2021},
  eprint = {2102.04306},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.04306},
}
Figure