SeaFormer: Squeeze-enhanced Axial Transformer for Mobile Semantic Segmentation

Qiang Wan, Zilong Huang, Jiachen Lu, Gang Yu, Li Zhang · OpenReview

Abstract

Since the introduction of Vision Transformers, the landscape of many computer vision tasks (e.g., semantic segmentation), which has been overwhelmingly dominated by CNNs, recently has significantly revolutionized. However, the computational cost and memory requirement render these methods unsuitable on the mobile device, especially for the high-resolution per-pixel semantic segmentation task. In this paper, we introduce a new method squeeze-enhanced Axial TransFormer (SeaFormer) for mobile semantic segmentation. Specifically, we design a generic attention block characterized by the formulation of squeeze Axial and detail enhancement. It can be further used to create a family of backbone architectures with superior cost-effectiveness. Coupled with a light segmentation head, we achieve the best trade-off between segmentation accuracy and latency on the ARM-based mobile devices on the ADE20K and Cityscapes datasets. Critically, we beat both the mobile-friendly rivals and Transformer-based counterparts with better performance and lower latency without bells and whistles. Beyond semantic segmentation, we further apply the proposed SeaFormer architecture to image classification problem, demonstrating the potentials of serving as a versatile mobile-friendly backbone.

The Challenge of Mobile Vision Transformers

While Vision Transformers (ViTs) have revolutionized computer vision by capturing long-range dependencies, they impose a significant computational "tax." Standard self-attention scales quadratically with the number of pixels ($O(H^2W^2)$), making high-resolution tasks like semantic segmentation nearly impossible on mobile hardware.

Existing mobile-friendly solutions often compromise by using local windows—which lose global context—or by aggressive downsampling that sacrifices the fine details necessary for accurate per-pixel classification. SeaFormer aims to bridge this gap by providing the global receptive field of a Transformer with the efficiency and local precision of a mobile-optimized CNN.

Methods: Squeeze-enhanced Axial (SEA) Attention

The core innovation of SeaFormer is the Squeeze-enhanced Axial (SEA) attention block. This architecture achieves linear complexity ($O(HW)$) through three primary mechanisms:

  1. Squeeze Axial Attention: Instead of attending to every pixel, the model "squeezes" feature maps along horizontal and vertical axes into compact vectors. Self-attention is then performed only along these axes, drastically reducing complexity.
  2. Detail Enhancement Kernel: To recover local spatial details lost during axial squeezing, a parallel depth-wise convolution branch captures local features and fuses them back into the attention output.
  3. Adaptive Squeezing: SeaFormer uses an input-adaptive approach with learnable masks to ensure the most important information is preserved during the squeeze operation.
The Squeeze-enhanced Axial (SEA) attention block, featuring parallel axial squeeze and detail enhancement branches.

In the enhanced SeaFormer++ version, the authors introduce Multi-resolution Distillation. A specialized Feature Alignment Module allows a "Student" model processing low-resolution images to align its internal features with a high-resolution "Teacher," achieving high-res accuracy with low-res latency.

Key Results and Performance

SeaFormer was evaluated across standard benchmarks including ADE20K, Cityscapes, and ImageNet-1K. The results demonstrate a superior trade-off between accuracy and inference speed on ARM-based mobile devices.

  • ADE20K (Segmentation): SeaFormer-Base achieved 41.0 mIoU with only 106ms latency on a Snapdragon 865. In comparison, MobileNetV3-Large reached only 33.1 mIoU while being slower (126ms).
  • The Distillation Boost: Using multi-resolution distillation, the SeaFormer-T++(KD) model achieved 35.5 mIoU on ADE20K with a lightning-fast latency of just 22ms.
  • ImageNet-1K (Classification): SeaFormer-L++ reached 80.6% Top-1 accuracy, outperforming MobileOne and EfficientFormer variants of similar size.
Accuracy vs. Latency trade-off on the ADE20K dataset, comparing SeaFormer to other mobile-friendly models.

Conclusion

SeaFormer demonstrates that linear complexity is the "gold standard" for mobile deployment. By integrating depth-wise convolutions to recover high-frequency spatial information, the architecture proves that hybrid models can outperform pure Transformers in resource-constrained environments. While the dual-branch architecture and two-stage distillation process add some training complexity, the resulting backbone is a versatile, high-performance replacement for traditional CNNs in mobile vision tasks.

Summary updated

BibTeX
@inproceedings{wan2023seaformer,
  author = {Qiang Wan and Zilong Huang and Jiachen Lu and Gang Yu and Li Zhang},
  title = {{SeaFormer: Squeeze-enhanced Axial Transformer for Mobile Semantic Segmentation}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=-qg8MQNrxZw},
}
Figure