---
title: "ScaleFormer: Revisiting the Transformer-based Backbones from a Scale-wise Perspective for Medical Image Segmentation"
authors:
  - "Huimin Huang"
  - "Shiao Xie"
  - "Lanfen Lin"
  - "Yutaro Iwamoto"
  - "Xian-Hua Han"
  - "Yen-Wei Chen"
  - "Ruofeng Tong"
doi: "10.24963/ijcai.2022/135"
url: "https://ijcai.org/proceedings/2022/135"
pdf: "https://ijcai.org/proceedings/2022/0135.pdf"
venue: "Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence"
year: 2022
pages: "964-971"
track: "Main Track"
keywords:
  - "Computer Vision: Biomedical Image Analysis"
  - "Computer Vision: Segmentation"
---

# ScaleFormer: Revisiting the Transformer-based Backbones from a Scale-wise Perspective for Medical Image Segmentation

Huimin Huang, Shiao Xie, Lanfen Lin, Yutaro Iwamoto, Xian-Hua Han, Yen-Wei Chen, Ruofeng Tong

*Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence*, pages 964-971. DOI: [10.24963/ijcai.2022/135](https://doi.org/10.24963/ijcai.2022/135)

## Abstract

Recently, a variety of vision transformers have been developed as their capability of modeling long-range dependency. In current transformer-based backbones for medical image segmentation, convolutional layers were replaced with pure transformers, or transformers were added to the deepest encoder to learn global context. However, there are mainly two challenges in a scale-wise perspective: (1) intra-scale problem: the existing methods lacked in extracting local-global cues in each scale, which may impact the signal propagation of small objects; (2) inter-scale problem: the existing methods failed to explore distinctive information from multiple scales, which may hinder the representation learning from objects with widely variable size, shape and location. To address these limitations, we propose a novel backbone, namely ScaleFormer, with two appealing designs: (1) A scale-wise intra-scale transformer is designed to couple the CNN-based local features with the transformer-based global cues in each scale, where the row-wise and column-wise global dependencies can be extracted by a lightweight Dual-Axis MSA. (2) A simple and effective spatial-aware inter-scale transformer is designed to interact among consensual regions in multiple scales, which can highlight the cross-scale dependency and resolve the complex scale variations. Experimental results on different benchmarks demonstrate that our Scale-Former outperforms the current state-of-the-art methods. The code is publicly available at: https://github.com/ZJUGiveLab/ScaleFormer.

## Full text

## 1 Introduction

In the past decades, Convolutional Neural Networks (CNNs) have greatly promoted the development of dense prediction tasks [Shelhamer et al., 2015], and a variety of CNN-based segmentation models have been developed [Ronneberger et al., 2015; Chen et al., 2017; Huang et al., 2021]. Despite its great success, CNNs failed to model explicit long-range relations beyond local regions (shown in Fig.2.(b) and (f)), since the effective receptive field of a networkÕs units is severely limited [Luo et al., 2016]. 1

* Corresponding Authors: Lanfen Lin (llf@zju.edu.cn), YenWei Chen (chen@is.ritsumei.ac.jp).

Figure 1: Comparison of current transformer-based backbones ((a) and (b)) with our ScaleFormer (c).

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000000_d3c410094d851800175e3944959ed963f786c8e8ad4688e9a670a5294a7bda39.png)

Recently, the transformer architecture has been introduced to visual tasks and shown to be an efficient way of modeling global context [Dosovitskiy et al., 2020]. This largely attributes to the multi-head self-attention (MSA) and Multilayer Perceptron (MLP) structure. Fig.1. (a) illustrates one of the transformer-based architectures for medical image segmentation, e.g. SwinUNet [Cao et al., 2021] and Missformer [Huang et al., 2021]. They typically utilized a stack of transformer blocks to model global representations. However, these pure transformer-based architectures often failed to achieve satisfactory performance, since lack of spatial inductive-bias in modelling local information. As shown in Fig.2(c) and (g), SwinUNet activated the background extensively and was difficult to distinguish objects from background. Another popular architecture, e.g. TransUNet [Chen et al., 2021] and AFTer-UNet [Yan et al., 2022], in Fig.1(b), used a CNNbased encoder to explore detailed high-resolution spatial information, and added several transformers into the deepest layer to learn global context. However, this kind of deepest

Huimin Huang and Shiao Xie are co-first authors.

Figure 2: Visualization of feature maps from different layers of four methods. The CNN-based ResUNet (in (b), (f)) limits in modeling longrange relations and thus fails to activate on objects beyond local regions (e.g. unactivated liver, gallbladder and pancreas). The pure transformer, SwinUNet (in (c), (g)), activates background extensively as a result it is difficult to distinguish objects from background. TransUNet (in (d), (h)) stacks transformers in the deepest encoder of UNet, but it still has problems accurately localizing small objects (e.g. blurred gallbladder and pancreas with small size). Our ScaleFormer (in (a), (e)) improves the transformer-based backbone from a scale-wise perspective, which can recognize objects in various sizes and long-range scenarios. (e.g. long-distant large-size liver and small-size pancreas).

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000001_6ef4cd42d809a66de38e3932ff011d80059e0735910a87e25a72010d6ecd7664.png)

hybrid transformer structure still led to blurred and inaccurate activation on the salient objects in Fig.2.(d) and (h).

The observed unsatisfactory activations of current transformer-based backbones may be imputed to two main challenges in a scale-wise perspective. (i) Intra-scale problem: As we know, both contextual local-level details and positional global-level cues are essential complements in each scale, especially for small objects, whose fine signals in the shallow layer (in Fig.2(b)-(d)) may be gradually diluted during downsampling (in Fig.2 (f)-(h)). But the integration of intra-scale local features with global representations remains a fundamental challenge. (ii) Inter-scale problem: As shown in Fig.2, the objects in medial image often have widely variable size, shape and location. The existing methods were incapable of extracting sufficient information from multiple scales generated by hierarchical encoder, which failed to notice the complete salient objects. To address these challenges, we propose a novel backbone for medial image segmentation task (in Fig.1. (c)), namely ScaleFormer, which is motivated by the following two aspects:

Firstly, considering both the spatial difference and global distribution of objects are essential characteristics, a scalewise intra-scale transformer is designed to couple the CNNbased local features with the transformer-based global representations in each scale. In this way, we are able to highlight both detailed spatial information (e.g. contextual cues) and long-range dependencies (e.g. positional cues). However, the quadratic computational cost of previous transformers becomes the main obstacle in such intra-scale structure, especially for the shallow scales with high-resolution feature maps. To achieve this, we also design a lightweight and universal Dual-Axis MSA to suppress less-relevant information and recognize salient parts with fast speed, which is realized by capturing row-wise and column-wise global dependencies.

Secondly, as many previous studies demonstrated, multiscale features explore distinctive information and are capable of resolving the complex scale variations. In this inter-scale circumstance, for a specific object (e.g. liver), instead of calculating the redundant relationships with long-distant objects (e.g. spleen and aorta) at various scales, we focus on the longrange cross-scale dependency of the object itself and the nearby objects (e.g. liver and gallbladder), which can effectively capture the scale difference (e.g. shape variation) of each object, and achieve promising performance with satisfactory boundary. Inspired by this, we design a spatial-aware inter-scale transformer considering that there is a spatial correspondence among patches in various scales through downsampling operation. In this way, we focus on the cross-scale similarities among these spatial-aware patches, which efficiently learns the mutual information in a lightweight manner.

The ability of ScaleFormer in capturing local-global cues is shown in Fig.2(a), (e). By extracting the intra-scale local details and global semantics, ScaleFormer can focus on the small object in both shallow and deep layers. Additionally, benefiting from the inter-scale interactions, ScaleFormer also attends full object extent with in various sizes and long-range scenarios. The major contributions of this work are four-fold: (i) We analyze the intra-scale and inter-scale problems faced by the current transformer-based backbones, and propose a novel backbone in a scale-wise perspective, termed as ScaleFormer, to improve the segmentation quality of medical image segmentation. (ii) We propose a scale-wise intra-scale transformer to associate CNN-based local features with intrascale transformer-based global cues in each scale. Accordingly, we design a lightweight and universal Dual-Axis MSA to capture row-wise and column-wise global dependencies. (iii) We propose a spatial-aware inter-scale transformer to interact among consensual regions in multiple scales, which is capable of capturing cross-scale dependency and resolving complex scale variations in a simple and effective manner. (iv) We conduct extensive experiments on three public datasets, which shows ScaleFormer surpasses SOTA methods.

## 2 Related Work

Vision transformers. In the most current research, ViT [Dosovitskiy et al. 2020] introduced transformer into visual tasks and achieved competitive performance. Motivated by the success of ViT, SegFormer [Xie et al., 2021], SETER [Zheng et al., 2020], DETR [Carion et al., 2020] have been proposed for semantic segmentation and object detection tasks, which achieved comparative results with CNN-based methods. To reduce the computational cost of self-attention operation in ViT, CMT [Guo et al., 2021] utilized depth-wise convolution to downsample key and value to extract important information; while Swin transformer [Liu et al. 2021] restricted the attention in local regions. Different from existing methods, we design a novel backbone that couples local CNN blocks and global Transformer. Such a structure not only inherits sufficient structural prior from CNN but also embeds global representations from transformer block in each scale.

Figure 3: An overview of our ScaleFormer. First, the input image passes the CNN blocks to generate local-level details, which are sent to the intra-scale transformers to capture the global-level cues. The inter-scale transformer then takes the enhanced representation from each scale as the inputs and interacts among different scales to model the mutual information of objects. Finally, the reinforced output is further combined with the same-scale CNN features, and then send to the corresponding decoder block for the final prediction.

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000002_3c3f3af62ff15d95841cd5599ce27ffd022624d9ca4c4c0dee83b7d8799c176b.png)

## Multi-scale architectures for medical image segmentation.

Multi-scale fusion has been proved to improve the segmentation performance in CNN-based methods. PSPNet [Zhao et al., 2017] exploited the capability of global context information by aggregating different region-based features. UNet++ [Zhou et al.,2020] and UNet 3+ [Huang et al., 2020] have been proposed to bridge the semantic gap between shallow encoder layers and deep decoder layers and made full use of multi-scale information through skip connection. To learn more extensive and rich context information, MS-DualGuided network [Sinha et al., 2020] applied attention in both spatial and channel dimension of feature maps on different scales. Considering the multi-scale cues, we further propose a simple and effective spatial-aware inter-scale transformer, which captures long-distance relationships among scales.

## 3 ScaleFormer

## 3.1 Overview

The proposed ScaleFormer learns intra-scale local-global cues as well as modeling inter-scale dependencies as shown in Fig.3. In special, we utilize ResUNet backbone to extract local features in a hierarchical manner. The encoder part has five CNN blocks comprised of basic resnet-34 blocks, where the channel number increases with network depth while the resolution of feature maps decreases. When the CNN goes deeper, different fine-grained features are extracted in various stages. Considering that transformer is powerful at capturing long-distance relationships, the scale-wise intra-scale transformer (in Sec.3.2) is coupled with the corresponding CNN block to highlight both detailed spatial information and long-range dependencies in each scale. To learn mutual regions at different scales, the spatial-aware inter-scale transformer (in Sec.3.3) further interacts among multiple scales. Finally, the enhanced representation is aggregated with the local-level CNN features in the same scale, and then sends to the decoder block for the final prediction. In the following, we will describe each step of ScaleFormer in detail.

## 3.2 Intra-Scale Transformer Block

As shown in Fig.3, the initial transformer only receives input from the CNN branch of same stage, whereas the input of other intra-scale transformer blocks incorporates global information from previous transformer stages to aggregate fine-grained details and coarse semantics information. Let i indexes the down-sampling layer along transformer branch, 𝑁# refers to the total number of transformers. The stack of feature maps 𝑋#%&amp;'( ) can be represented as:

<!-- formula-not-decoded -->

where function 𝐷𝑜𝑤𝑛(∙) indicates the patch embedding mechanism, which is realized by a convolution operation with stride of 2 and followed by a batch normalization and a ReLU activation function. [á] is the concatenation operation. 𝑇𝑟𝑎𝑛𝑠(∙) is the intra-scale transformer block, which consists of a lightweight Dual-Axis MSA module, and an enhanced MLP. We will describe these parts in the following.

Dual-Axis MSA. In the Fig.4, we illustrate the previous two MSA architecture and our proposed method. In original MSA [Dosovitskiy et al., 2020] (shown in Fig.4.(a)), the input 𝑋 ∈ ℝB×D×E is linearly transformed into query 𝑄, key 𝐾 and value 𝑉 with the same shape of 𝐻𝑊×𝐶. The computational cost of the original MSA is 𝑂(𝐻M𝑊M𝐶). To achieve lower cost, some works [Guo et al., 2021] used a spatial reduction mechanism by applying a reduction ratio 𝑅 to the key 𝐾 and value 𝑉 (shown in Fig.4.(b)) and the computational cost is decreased to 𝑂(𝐻M𝑊M𝐶 𝑅M ). However, it still requires large reduction ratio 𝑅 when applied to high-resolution feature map, which degrades the horizontal and vertical information.

Figure 4: Comparison of previous MSAs (a) and (b) with the proposed Dual-axis MSA (c).

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000003_b42ba2ac43e360fde87a35d97e7a33a688826533199fc99cfc9120c79a7d39e8.png)

Different from the previous MSAs, we design a lightweight and universal Dual-Axis MSA mechanism, which replaces the full-image relation (𝐻𝑊×𝐻𝑊) with a row-wise (𝐻×𝐻) and column-wise (𝑊×𝑊) relation, as illustrated inFig.4.(c). To adaptively learn the horizontal and vertical representation [Chi et al., 2020], we first apply four distinctive depth-wise convolutions on 𝑄 and 𝐾 to obtain row-wise enhanced 𝑄%, 𝐾% and column-wise enhanced 𝑄1, 𝐾1. We then pass these into average pooling operation in two directions, which estimates global and compact conditions (𝑄%O, 𝐾%O, 𝑄1O, 𝐾1O) over the whole feature map. The process can be formulated as:

<!-- formula-not-decoded -->

when applying the row-wise MSA, the value 𝑉 is reshaped into 𝐻×𝑊𝐶; while using the column-wise MSA, 𝑉 is reshaped into 𝐻𝐶×𝑊. In this way, the complexity of our DualAxis MSA is 𝑂(𝐻M𝑊𝐶 +𝐻𝑊M𝐶). Compared with Axial Attention [Ho et al.,2019] that requires consecutive two blocks to capture long-term relations, our method learns global conditions using a single block. Then, we utilize an enhanced MLP [Huang et al., 2021] with recursive skip connection before the depth-wise convolution for feature delivery.

## 3.3 Spatial-Aware Inter-Scale Transformer Block

Multi-scale cues have been proven to be powerful in resolving complex scale variations, which are essential for medical image segmentation. Hence, we aim to design a transformerbased block to interact among different scales based on the hierarchical structure of ScaleFormer. The input sequence of enhanced intra-scale tokens is first rearranged into 2D lattice. Instead of calculating the dependencies on a long sequence that directly concatenated from multi-scale tokens (flattened from the complete 2D feature map of each scale), we take full advantage of the spatial correspondence among patches in different scales through down-sampling operation, which is called Patch Matching. As an example, Fig.5.(a) illustrates how to find the spatial-aware patches on three successive feature maps from i-th to (i+2)-th scale. Note that we first regularize feature maps into the same channel dimension 𝐶. Let denote 𝑝d) as the j-th patch in the i-th scale, and the corresponding down-sampeled patches are 𝑝d)e; and 𝑝d)eM sharing the bounding box with the same color (i.e. blue). In this way, we focus on the most related patches, and thus maintain the spatial correspondence as well as reduce the redundancy.

Figure 5: An illustration of spatial-aware inter-scale transformer.

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000004_d8990776fc06dc07e747fd0ca607293d8eaedd357f08d338dd4017a5006fe064.png)

Then we apply Scale Fusion to concatenate spatial corresponding inter-scale patches, which can be formulated as:

<!-- formula-not-decoded -->

where 𝑓𝑙𝑎𝑡𝑡𝑒𝑛(∙) operation rearrange the patch 𝑝d) into the shape of 𝐻𝑊 2M) ×𝐶 and [·] represents the concatenation operation. Because the sequence of tokens lacks horizontal and vertical information, in this part, we utilize the original MSA and MLP proposed by [Dosovitskiy et al., 2020] in our Transformer block, instead of using our Dual-Axis MSA (shown in eq.(2)). The spatial-aware inter-scale dependencies among patches can obtained as follows:

<!-- formula-not-decoded -->

<!-- formula-not-decoded -->

where 𝐿𝑁(∙) denotes the layer normalization operator. Then we utilize Scale Division to reverse the enhanced sequence back to patches according to the order of concatenation:

<!-- formula-not-decoded -->

where 𝑆𝑝𝑙𝑖𝑡(∙) is an inverse operation of previous concatenation operation [·]. In the reverse procedure of patch matching, patch reversion assembles all patches in the same scale into a feature map. Then we concatenate the global-level transformer feature and the local-level CNN feature as skip connection, which further sends to the decoder stage.

Table 1: Comparison to state-of-the-art (SOTA) methods on Synapse dataset.

| Method                 |   DSC(↑) | HD(↓)   |   Aorta |   Gallbladdr |   Kidney(L) |   Kidney(R) |   Liver |   Pancreas |   Spleen |   Stomach |
|------------------------|----------|---------|---------|--------------|-------------|-------------|---------|------------|----------|-----------|
| V-Net                  |    68.81 | -       |   75.34 |        51.87 |       77.10 |       80.75 |   87.84 |      40.05 |    80.56 |     56.98 |
| DARR                   |    69.77 | -       |   74.74 |        53.77 |       72.31 |       73.24 |   94.08 |      54.18 |    89.90 |     45.96 |
| R50 U-Net              |    74.68 | 36.87   |   87.74 |        63.66 |       80.60 |       78.19 |   93.74 |      56.90 |    85.87 |     74.16 |
| U-Net                  |    76.85 | 39.70   |   89.07 |        69.72 |       77.77 |       68.60 |   93.43 |      53.98 |    86.67 |     75.58 |
| R50 Att-UNet           |    75.57 | 36.97   |   55.92 |        63.91 |       79.20 |       72.71 |   93.56 |      49.37 |    87.19 |     74.95 |
| Att-UNet               |    77.77 | 36.02   |   89.55 |        68.88 |       77.98 |       71.11 |   93.57 |      58.04 |    87.30 |     75.75 |
| R50 ViT                |    71.29 | 32.87   |   73.73 |        55.13 |       75.80 |       72.20 |   91.51 |      45.99 |    81.99 |     73.95 |
| TransUnet              |    77.48 | 31.69   |   87.23 |        63.13 |       81.87 |       77.02 |   94.08 |      55.86 |    85.08 |     75.62 |
| SwinUNet               |    79.12 | 21.55   |   85.47 |        66.53 |       83.28 |       79.61 |   94.29 |      56.58 |    90.66 |     76.60 |
| AFTer-UNet             |    81.02 | -       |   90.91 |        64.81 |       87.90 |       85.30 |   92.20 |      63.54 |    90.99 |     72.48 |
| MISSFormer             |    81.96 | 18.20   |   86.99 |        68.65 |       85.21 |       82.00 |   94.41 |      65.67 |    91.92 |     80.81 |
| ScaleFormer(w/o inter) |    82.08 | 18.03   |   88.29 |        76.48 |       83.10 |       80.59 |   94.88 |      63.90 |    89.29 |     80.12 |
| ScaleFormer            |    82.86 | 16.81   |   88.73 |        74.97 |       86.36 |       83.31 |   95.12 |      64.85 |    89.40 |     80.14 |

Discussion. In this section, we analyze the successive operations of the intra-scale and inter-scale transformers. The local features firstly passed through intra-scale transformer to extract the contextual information, which learns the entire pixelwise dependency in each scale. Then, the enhanced feature maps are fed into inter-scale transformer, which explores the corresponding patch-wise dependencies among multiple scales. In this way, even though two pixels (𝑥)&amp; , 𝑥ds ) in different scales ( 𝑖 and 𝑗 ) and irrelevant patches (𝑎 and 𝑏), in Fig5.(c), their relationship can be also captured via first finding the intra-scale dependencies of 𝑥)&amp; and 𝑥)s , then calculating the inter-scale dependencies of 𝑥)s and 𝑥ds . These two consecutive steps realize the goal of capturing pixel-wise dependencies in full scales with less computational cost.

## 4 Experiments

## 4.1 Dataset and Evaluation

We perform experiments on three public medical image datasets:

Synapse. The multi-organ segmentation challenge [Landman et al., 2015] consists 30 abdominal CT scans. Following [Chen et al., 2021], we split 18 cases for training and remaining 12 cases for testing. We reported the Dice Coefficient (DSC) and Hausdorff Distance (HD) on 8 different organs.

MoNuSeg. The Multi-Organ Nucleus Segmentation Challenge [Kumar et al., 2017] contains 30 images for training, and 14 images for testing. Following [Wang et al., 2021], we utilized DSC and Intersection over Union (IoU) metrics.

ACDC. The automated cardiac diagnosis challenge [Bernard et al., 2018] contains 100 MRI scans with three organs, left ventricle (LV), right ventricle (RV) and myocardium (MYO). Following [Chen et al., 2021], we reported the DSC with a random split of 70 training cases, 10 validation cases and 20

testing cases. We split the dataset randomly because the previous division was unavailable.

## 4.2 Implementation Details

We utilized data augmentations to avoid overfitting, including random rotation and flipping. Note that our ScaleFormer did not require pretrain on any large datasets. Here, we itemized the batch size (bs), learning rate (lr), maximum training epochs (ep), optimizer (opt) for three datasets:

- ∞ Synapse: bs=8; lr=3e-3; ep=600; opt=SGD;
- ∞ ACDC: bs=8; lr=3e-3; ep=200; opt=SGD;
- ∞ MoNuSeg: bs=4; lr=1e-3; ep=200; opt=Adam;

All models were trained with momentum 0.9 and weight decay 1e-4. For fair comparison, we used the same settings and combined cross entropy loss and dice loss for all experiments.

## 4.3 Comparison with the State-of-the-Arts

To demonstrate the effectiveness of ScaleFormer, we first compare it with 11 state-of- the-art methods on the Synapse dataset, including V-Net [Milletari et al., 2016], DARR [Fu et al., 2020], U-Net, Att-UNet [Schlemper et al., 2019], ViT, TransUnet, SwinUNet, AFTer-UNet, MISSFormer. Both TransUnet and SwinUNet are pretrained on the ImageNet. Here, we abbreviate ResNet-50 as ÒR50Ó, which is utilized as encoder and combined with U-Net, Att-UNet and ViT.

Experimental results are reported in Table 1 and the best results are highlighted in bold. As shown, our ScaleFormer without inter-scale former (w/o inter) outperforms all the other methods in both regional measures DSC (82.08%) and boundary-aware measure HD (18.03mm). In particular, our ScaleFormer (w/o inter) surpasses other transformer-based methods, including SwinUNet and MISSFormer with pure transformers, as well as TransUNet and AFTer-UNet that stack several transformers in the deep layers of encoder. It indicates that the structure combined with CNN and intrascale transformer has the ability of capturing local-global clues. Additionally, an increment of (DSC: +0.78% and HD: -1.22mm) is achieved when utilizing inter-scale transformer, which achieves the new SOTA on synapse dataset.

Table 2: Comparison to SOTA methods on MoNuSeg dataset.

| Methods                |   DSC(↑) |   IOU(↑) |
|------------------------|----------|----------|
| UNet                   |    73.97 |    59.42 |
| UNet++                 |    75.28 |    60.89 |
| AttUNet                |    76.20 |    62.64 |
| MRUNet                 |    77.54 |    63.80 |
| MedT                   |    79.24 |    65.73 |
| TransUNet              |    79.20 |    65.68 |
| SwinUNet               |    78.49 |    64.72 |
| UCTransNet             |    79.87 |    66.68 |
| ScaleFormer(w/o inter) |    79.59 |    66.27 |
| ScaleFormer            |    80.06 |    66.87 |

Table 3: Comparison to SOTA methods on ACDC dataset.

| Methods                |   DSC(↑) |    RV |   Myo |    LV |
|------------------------|----------|-------|-------|-------|
| R50 U-Net              |    87.55 | 87.10 | 80.63 | 94.92 |
| R50 Att-UNet           |    86.75 | 87.58 | 79.20 | 93.47 |
| R50 ViT                |    87.57 | 86.07 | 81.88 | 94.75 |
| TransUNet              |    89.71 | 88.86 | 84.53 | 95.73 |
| SwinUNet               |    90.00 | 88.55 | 85.62 | 95.83 |
| TransUNet*             |    89.63 | 86.70 | 86.96 | 95.33 |
| SwinUNet*              |    89.16 | 87.04 | 86.22 | 94.24 |
| ScaleFormer(w/o inter) |    89.74 | 86.54 | 87.66 | 95.01 |
| ScaleFormer            |    90.17 | 87.33 | 88.16 | 95.04 |

To demonstrate the generality of ScaleFormer, we conduct experiments on another two public datasets. Additionally, we compare it with UNet++, MRUNet [Ibtehaz et al.,2020], MedT [Valanarasu et al.,2021] and UCTransNet [Wang et al., 2021], which are four SOTA methods on MoNuSeg dataset. Table 2 presents DSC and IoU metrics on MoNuSeg, and Table 3 reports DSC on our divided ACDC dataset (*) with retrained TransUnet and SwinUnet using their original settings. Our ScaleFormer achieves the best result for capturing more useful representations, which demonstrates the superior generalization and robustness of ScaleFormer.

Fig.6 shows the qualitative comparison of classic UNet, TransUNet, SwinUNet and our ScaleFormer on Synapse dataset. It can be observed that ScaleFormer not only accurately localizes organs but also produces coherent boundaries, even in small object circumstances.

## 4.4 Ablation Study

Ablation of intra-scale transformers on different stages. We investigate how intra-scale transformers affect performance among different scales on synapse dataset, which is varied from Stage6 (deepest layer with size of 7×7) to Stage2 (shallowest layer with size of 112×112). As shown in Fig.7, the accuracy is improved with stacking the transformer blocks, which achieves the highest results (DSC: 82.08%, HD:18.03mm) when extracting intra-scale local-global cues on four consecutive stages (Stage6543). However, applying the transformer on the Stage2 may affect the genuine characteristics and increase the computational cost (required two GPUs). Therefore, in our experiments, we introduce the intrascale transformers on Stage3-Stage6, which provides the best results within a considerable computational complexity.

Figure 6: Qualitative results of different models on Synapse dataset.

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000005_8e1e1437f26fcfc891171ce10559e6ebec6efb7f7351f5d699e0b750513824f0.png)

Figure 7: Ablation of intra-scale transformers on different stages

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000006_4455105e8140ee14f380029da7403737c67df7b16c951ae9962794f6137c81ad.png)

Figure 8: Ablation of the input for intra-scale transformer block.

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000007_af64af04792e801b9926a9e4bc2a83f0e9fbd6b1047700cc7294273dafd13659.png)

Ablation of the input for intra-scale transformer block. Based on the architecture with four-stage intra-scale transformers, we present the ablation of its input, i.e. the samestage CNN and the previous-stage transformer (Pre-Trans). As shown in Fig.8 that only using pre-trans in a staking manner achieves inferior results than using CNN feature (DSC: - 0.80%, HD: +3.05mm), which means that staking transform ers may dilute detailed signals by extracting global information. By combining two inputs, the best results (DSC: 82.08%, HD: 18.03mm) are achieved for aggregating finegrained details and coarse-grained semantics.

Effectiveness of our Dual-Axis MSA. To verify the capability of Dual-Axis MSA in capturing global cues, we compare it with CMT [Guo et al., 2021], PVT [Wang et al. 2021], and Axial attention [Ho et al., 2019] in Fig.9(b). We find that our method achieves a better accuracy (higher DSC and lower HD) than these methods with less computation cost and fewer parameters. It indicates the superiority of Dual-Axis MSA via splitting the full-image dependency in the row-wise and the column-wise manner.

Ablation of inter-scale transformers on various stages. Additionally, we conduct several experiments to assess the influence of inter-scale transformers on various stages. As shown in Fig.9 (a), by learning interactive information on deeper stages, an increment from 81.37% to 82.86% is achieved, where 0.67% and 0.82% improvements are produced by adding Stage5 and Stage6. It indicates that the learned mutual relations can enhance segmentation quality.

Figure 9: (a) Ablation of inter-scale transformers on various stages; (b) Comparison of Dual-Axis MSA with CMT, PVT and Axial attention on Params, DSC and HD.

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000008_6a79f1e0902323792f4a7e154cb5261d9d35473722caafb50ae3ad300bd3553a.png)

Figure 10: Visualization of the feature map of various methods.

![Image](https://ijcai.org/proceedings/2022/fulltext/135/image_000009_80e3738f266e7f877ae8f03e12a31bac63d3535639f1e3e81c4e57892c8deb23.png)

## 4.5 Interpretation of ScaleFormer

We visualize the feature map from the final decoder in Fig.10. As shown, ResUNet (in Fig.10.(f)) has the capability of focusing on the local areas but it fails to activate larger regions; while TransUNet (in Fig.10.(e)) and SwinUNet (in Fig.10.(d)) can globally model the long-term relationships but decline the important detailed local features. Impressively, our ScaleFormer (w/o inter) (in Fig.10.(b)) not only inherits sufficient structural prior from CNN but also embeds the global representations from transformer block, which helps to find the tiny objects. Considering the multi-scale cues, ScaleFormer (in Fig.10.(c)) has more complete attention areas on objects with widely variable size, shape and location.

## 5 Conclusion

In this paper, we proposed a novel transformer-based backbone, namely ScaleFormer, from a scale-wise perspective to improve the medical image segmentation quality even for the small objects. In each scale, a scale-wise intra-scale transformer with a lightweight Dual-Axis MSA is designed to combine the CNN-based local features and transformerbased global features; while among multiple scales, a simple and effective spatial-aware inter-scale transformer was proposed to interact across scales. Experiments showed that ScaleFormer outperformed both CNN-based and transformer-based segmentation networks on three datasets.

## Acknowledgements

This work was supported in part by Zhejiang Provincial Natural Science Foundation of China under the Grant No. LZ22F020012, Major Scientific Research Project of Zhejiang Lab under the Grant No. 2020ND8AD01, and in part by the Grant-in Aid for Scientific Research from the Japanese Ministry for Education, Science, Culture and Sports (MEXT) under the Grant No. 20KK0234, No. 21H03470 and No. 20K21821.

## References

1. [Shelhamer et al., 2015] Evan Shelhamer, Jonathan Long ,Trevor Darrell . Fully Convolutional Networks for Semantic Segmentation. The IEEE Conference on Com- puter Vision and Pattern Recognition (CVPR), 2015.
2. [Ronneberger et al., 2015] Olaf Ronneberger, Philipp Fischer, Thomas Brox. U-Net: Convolutional Networks for Bio- medical Image Segmentation. Medical Image Computing and Computer-Assisted Intervention (MICCAI), 2015.
3. [Chen et al., 2017] Liang-Chieh Chen, George Papandreou, Florian Schroff, et al. Rethinking atrous convolution for semantic image segmentation. arXiv preprint arXiv:1706.05587, 2017.
4. [Huang et al., 2020] Huimin Huang, Han Zheng, Lanfen Lin, et al. Medical Image Segmentation with Deep Atlas Prior. IEEE Trans. Medical Imaging 40.12: 3519-3530, 2021.
5. [Luo et al., 2016] Wenjie Luo, Yujia Li, Raquel Urtasun, et al. Understanding the effective receptive field in deep con- volutional neural networks. In NIPS, 2016.
6. [Dosovitskiy et al., 2020] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020. .
7. [Cao et al., 2021] Hu Cao, Yueyue Wang, Joy Chen,et al. Swin-Unet: Unet-like Pure Transformer for Medical Im- age Segmentation. arXiv:2105.05537, 2021.
8. [Huang et al., 2021] Xiaohong Huang, Zhifang Deng, Dan- dan Li, et al. MISSFormer: An Effective Medical Image Segmentation Transformer. arXiv:2109.07162, 2021.
9. [Chen et al., 2021] Jieneng Chen, Yongyi Lu, Qihang Yu, et al. Transunet: Transformers make strong encoders for medical image segmentation. arXiv:102.04306, 2021.
10. [Guo et al., 2021] Jianyuan Guo, Kai Han, Han Wu, Chang Xu, et al. Cmt: Convolutional neural networks meet vision transformers. arXiv:2107.06263, 2021.
11. [Zhao et al., 2017] Hengshuang Zhao, Jianping Shi, Xiaojuan Qi, et al. Pyramid scene parsing network. The IEEE Con- ference on Computer Vision and Pattern Recognition (CVPR), 2017.
12. [Zhou et al.,2020] Zongwei Zhou, Md Mahfuzur Rahman Siddiquee, Nima Tajbakhsh, et al. UNet++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation. IEEE Trans. Medical Imaging 39.6:1856- 1867, 2020.
13. [Huang et al., 2020] Huimin Huang, Lanfen Lin, Ruofeng Tong, et al. Unet 3+: A full-scale connected unet for med- ical image segmentation. ICASSP 2020-2020 IEEE Inter- national Conference on Acoustics, Speech and Signal Processing (ICASSP), 2020.
14. [Sinha et al., 2020] Ashish Sinha and Jose Dolz. Multi-scale self-guided attention for medical image segmenta- tion. IEEE Journal of Biomedical and Health Informat- ics 25.1: 121-130, 2020.
15. [Zheng et al., 2020] Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, et al. Rethinking semantic segmentation from a se- quence-to-sequence perspective with transformers. The IEEE Conference on Computer Vision and Pattern Recog- nition (CVPR), 2021.
16. [Xie et al., 2021] Enze Xie, Wenhai Wang, Zhiding Yu, et al. SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers. arXiv:2105.15203, 2021.
17. [Carion et al., 2020] Nicolas Carion, Francisco Massa, Ga- briel Synnaeve, et al. End-to-end object detection with transformers. European Conference on Computer Vision (ECCV). Springer, Cham, 2020.
18. Wang et al. 2021]
19. Wenhai Wang, Enze Xie, et al. Pyramid vision transformer: A versatile backbone for dense pre- diction without convolutions. arXiv:2102.12122, 2021.
20. [Ho et al., 2019] Jonathan Ho, Nal Kalchbrenner, Dirk Weis- senborn, et al. Axial attention in multidimensional trans- formers. arXiv:1912.12180, 2019.
21. [Liu et al.,2021] Ze Liu, Yutong Lin, Yue Cao, et al. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv:2103.14030, 2021.
22. [Milletari et al., 2016] Fausto Milletari, Nassir Navab, et al. V-Net: Fully Convolutional Neural Networks for Volu- metric Medical Image Segmentation. 2016 Fourth Inter- national Conference on 3D Vision (3DV) IEEE, 2016.
23. [Fu et al., 2020] Shuhao Fu, Yongyi Lu, Yan Wang, et al. Domain adaptive relational reasoning for 3d multi-organ segmentation. Medical Image Computing and Computer- Assisted Intervention (MICCAI). Springer, Cham, 2020.
24. [Schlemper et al., 2019] Jo Schlemper, Ozan Oktay, Michiel Schaap, et al. Attention gated networks: Learning to lev- erage salient regions in medical images. Medical Image Analysis 53: 197-207, 2019.
25. [Valanarasu et al., 2021] Jeya Maria Jose Valanarasu, Poojan Oza, Ilker Hacihaliloglu, et al.Medical transformer: Gated axial-attention for medical image segmentation. arXiv preprint arXiv:2102.10662, 2021.
26. [Ibtehaz et al.,2020] Nabil Ibtehaz and M. Sohel Rahman. MultiResUNet: Rethinking the U-Net architecture for multimodal biomedical image segmentation. Neural Net- works 121: 74-87, 2020.
27. [Wang et al., 2021] Haonan Wang, Peng Cao, Jiaqi Wang, et al. UCTransNet: Rethinking the skip connections in U-Net from a channel-wise perspective with transformer. arXiv:2109.04335, 2021.
28. [Kumar et al., 2017] Neeraj Kumar, Ruchika Verma, Sanuj Sharma, et al. A dataset and a technique for generalized nuclear segmentation for computational pathology. IEEE Trans. Medical Imaging 36.7: 1550-1560, 2017.
29. [Landman et al., 2015] Bennett Landman, Zhoubing Xu, Juan Eugenio Igelsias, et al.Segmentation Outside the Cranial Vault Challenge. In MICCAI: Multi Atlas Labeling Be- yond Cranial Vault-Workshop Challenge, 2015 [
30. [Bernard et al., 2018] Olivier Bernard, Alain Lalande, Clem- ent Zotti, et al. Deep learning techniques for automatic MRI cardiac multi-structures segmentation and diagnosis: Is the problem solved?. IEEE Trans. Medical Imag- ing 37.11: 2514-2525, 2018.
31. [Chi et al., 2020] Lu Chi, Zehuan Yuan, Yadong Mu, et al. Non-local neural networks with grouped bilinear atten- tional transforms. The IEEE Conference on Computer Vi- sion and Pattern Recognition (CVPR), 2020.
