ConvFormer: Combining CNN and Transformer for Medical Image Segmentation

Pengfei Gu, Yejia Zhang, Chaoli Wang, Danny Z. Chen

TL;DR

ConvFormer is a novel hierarchical hybrid architecture that effectively marries Convolutional Neural Networks (CNNs) and Transformers for medical image segmentation. By integrating depth-wise convolutions directly into the Transformer’s feed-forward network and utilizing a residual-shaped hybrid stem, it captures both fine-grained local details and long-range global context, achieving state-of-the-art performance on 2D and 3D medical datasets without requiring large-scale pre-training.

What Problem Does This Paper Address?

Medical image segmentation requires a delicate balance. You need to see the "big picture" (global context) to understand where organs or lesions are relative to each other, but you also need "pixel-perfect" local accuracy to define boundaries.

Standard CNNs are the traditional workhorses here; they have a strong "inductive bias" for local patterns but suffer from limited receptive fields—they struggle to see the whole image at once. Transformers, borrowed from natural language processing, excel at capturing these long-range dependencies. However, they lack the inherent local focus of CNNs, are computationally heavy, and often require massive pre-training to perform well.

Existing hybrid models often just "stack" these two—for example, putting a Transformer at the end of a CNN encoder. The authors argue these approaches are sub-optimal because they don't effectively fuse local and global information across multiple scales, which is critical for medical images where targets (like tumors or lymph nodes) vary wildly in size and shape.

Methods

The authors introduce ConvFormer, a U-shaped architecture built on three primary innovations:

  1. Enhanced DeTrans: The authors take the Deformable Transformer (DeTrans) and redesign its Feed-Forward Module (FFM). Instead of just using linear layers, they insert a depth-wise convolution (DW Conv). This allows the Transformer block to learn local spatial context while it's processing global attention.
  2. Residual-shaped Hybrid Stem: Instead of a pure CNN or pure Transformer encoder, ConvFormer uses a hybrid stem. It combines stacked convolutions (for local features) with Enhanced DeTrans blocks (for global features) via residual connections. This design prevents "feature collapse" (where feature diversity disappears in deep layers) and ensures better fusion of information types.
  3. Enhanced Positional Encoding (EPE): Standard Transformers use fixed sinusoidal functions to tell the model where pixels are. ConvFormer adds a parallel branch with a DW Conv to this encoding. This makes the positional information more adaptable and flexible to the specific geometry of the input data.
The ConvFormer architecture, highlighting the Enhanced DeTrans and the hierarchical hybrid encoder-decoder structure.

Datasets

The model was evaluated on three distinct tasks to prove its versatility:

  • Lymph Node Ultrasound (2D): An in-house dataset for segmenting lymph nodes (137 training, 100 test images).
  • 2017 MM-WHS CT (3D): A public dataset for segmenting seven cardiac structures (e.g., ventricles, atria, aorta) from 3D CT scans.
  • 2017 ISIC Skin Lesion (2D): A public dataset for segmenting skin lesion boundaries in dermoscopic images (2000 training, 600 test images).

Key Insights and Ideas

  • Interleaving is better than Stacking: The core "aha moment" is that local and global processing shouldn't be separate stages. By putting convolutions inside the Transformer's FFM, the model learns a more integrated representation.
  • Multi-scale Hierarchies are Essential: By using the hybrid stem in a hierarchical manner (processing the image at different resolutions), the model can handle objects of vastly different sizes—a common challenge in medical imaging.
  • Inductive Bias Matters: Even with the power of Transformers, the "local" bias of convolutions is so important for segmentation that removing the CNN components leads to a massive performance drop (nearly 10% in F1 score in their ablation study).
  • Pre-training is Optional: Unlike many pure Transformer models that need to see millions of natural images (like ImageNet) first, ConvFormer achieves SOTA results when trained from scratch on relatively small medical datasets.

Key Results

ConvFormer consistently outperformed both pure CNN-based (like U-Net) and recent hybrid or pure Transformer-based models (like UNETR and CoTr).

  • 3D Cardiac Segmentation (MM-WHS): ConvFormer achieved a mean Dice score of 0.925, outperforming the previous SOTA (kCBAC-Net) and significantly beating Transformer-based competitors like UNETR (0.915) and CoTr (0.911).
  • Lymph Node Segmentation: It reached an F1 score of 0.916, a 1.0% improvement over the previous best method.
  • Qualitative Excellence: Visual results show that ConvFormer produces much cleaner boundaries and fewer false positives compared to other models, especially in complex 3D cardiac structures.
Fig. 2. Some visual qualitative results on the lymph node dataset (a) and the 2017 MM-WHS CT dataset (b), demon- strating the capability of our ConvFormer.

Limitations and Future Work

While ConvFormer is highly effective, the paper notes a few areas for consideration:

  • Model Complexity: With 61 million parameters, it is more efficient than some giants (like kCBAC-Net at 134M) but heavier than others (like CoTr at 42M). Balancing this complexity for real-time clinical use remains a challenge.
  • Computational Cost: While the authors used depth-wise convolutions to save on computation, Transformers still inherently require more memory and time than simple CNNs.
  • Future Directions: The authors suggest that the Enhanced Positional Encoding (EPE) could be further refined to improve how the model handles the specific spatial continuity found in medical volumes.

For a detailed breakdown of the 3D results, see the table below:

Table 2. Quantitative results of different models on the 2017 MM-WHS CT dataset. “—” means that the results were not reported by the original papers, “Para.” means the number of parameters of the model, and “HDF” represents Hausdorff.

Summary updated

Abstract

Convolutional neural network (CNN) based methods have achieved great successes in medical image segmentation, but their capability to learn global representations is still limited due to using small effective receptive fields of convolution operations. Transformer based methods are capable of modelling long-range dependencies of information for capturing global representations, yet their ability to model local context is lacking. Integrating CNN and Transformer to learn both local and global representations while exploring multi-scale features is instrumental in further improving medical image segmentation. In this paper, we propose a hierarchical CNN and Transformer hybrid architecture, called ConvFormer, for medical image segmentation. ConvFormer is based on several simple yet effective designs. (1) A feed forward module of Deformable Transformer (DeTrans) is re-designed to introduce local information, called Enhanced DeTrans. (2) A residual-shaped hybrid stem based on a combination of convolutions and Enhanced DeTrans is developed to capture both local and global representations to enhance representation ability. (3) Our encoder utilizes the residual-shaped hybrid stem in a hierarchical manner to generate feature maps in different scales, and an additional Enhanced DeTrans encoder with residual connections is built to exploit multi-scale features with feature maps of different scales as input. Experiments on several datasets show that our ConvFormer, trained from scratch, outperforms various CNN- or Transformer-based architectures, achieving state-of-the-art performance.
BibTeX
@inproceedings{gu2023convformer,
  author = {Pengfei Gu and Yejia Zhang and Chaoli Wang and Danny Z. Chen},
  title = {{ConvFormer: Combining CNN and Transformer for Medical Image Segmentation}},
  booktitle = {ISBI},
  year = {2023},
  doi = {10.1109/isbi53787.2023.10230838},
}
Figure