Abstract
The emergence of vision transformers (ViTs) in image classification has shifted the methodologies for visual representation learning. In particular, ViTs learn visual representation at full receptive field per layer across all the image patches, in comparison to the increasing receptive fields of CNNs across layers and other alternatives (e.g., large kernels and atrous convolution). In this work, for the first time we explore the global context learning potentials of ViTs for dense visual prediction (e.g., semantic segmentation). Our motivation is that through learning global context at full receptive field layer by layer, ViTs may capture stronger long-range dependency information, critical for dense prediction tasks. We first demonstrate that encoding an image as a sequence of patches, a vanilla ViT without local convolution and resolution reduction can yield stronger visual representation for semantic segmentation. For example, our model, termed as SEgmentation TRansformer (SETR), excels on ADE20K (50.28% mIoU, the first position in the test leaderboard on the day of submission) and Pascal Context (55.83% mIoU), and performs competitively on Cityscapes. For tackling general dense visual prediction tasks in a cost-effective manner, we further formulate a family of Hierarchical Local-Global (HLG) Transformers, characterized by local attention within windows and global-attention across windows in a pyramidal architecture. Extensive experiments show that our methods achieve appealing performance on a variety of dense prediction tasks (e.g., object detection and instance segmentation and semantic segmentation) as well as image classification.
Introduction: Beyond the Convolutional Paradigm
For years, the Fully Convolutional Network (FCN) has been the dominant architecture for dense prediction tasks like semantic segmentation. However, FCNs possess an inherent limitation: their receptive field grows slowly through successive layers. To capture long-range dependencies—essential for understanding large objects or global scene context—FCNs require many layers of convolutions, which often leads to a loss of fine-grained spatial detail due to repeated downsampling.
This research proposes a paradigm shift by treating image segmentation as a sequence-to-sequence problem. By leveraging the Vision Transformer (ViT) architecture, which provides a global receptive field from the very first layer, the authors introduce SETR (SEgmentation TRansformer) and its efficient successor, the HLG (Hierarchical Local-Global) Transformer.
The SETR Framework
SETR rethinks semantic segmentation by encoding an image as a sequence of patches. Unlike traditional CNNs that progressively reduce spatial resolution, SETR maintains a constant resolution throughout its encoder, preserving spatial information.
The architecture consists of a pure Transformer encoder that processes flattened 16x16 pixel patches. To transform these global features back into pixel-wise labels, the authors developed several decoder heads:
- Naive Upsampling: A simple linear projection followed by bilinear interpolation.
- Progressive Upsampling (PUP): A multi-stage process that alternates between convolution and 2x upsampling to mitigate spatial artifacts.
- Multi-Level Aggregation (MLA): A head that gathers and fuses features from different layers of the Transformer to capture multi-scale information.
Hierarchical Local-Global (HLG) Transformers
While SETR demonstrates the power of global context, pure ViTs are computationally expensive, especially for high-resolution tasks. To address this, the authors introduced the HLG Transformer family. HLG adopts a pyramidal structure similar to CNNs but utilizes a novel hybrid attention mechanism.
HLG alternates between Local Attention (processing patches within small windows to capture fine details) and Global Attention (summarizing windows to maintain broad context). Additionally, Dilated Local Attention allows the network to sample pixels at a distance, increasing the effective reach without adding parameters. This hierarchical approach enables efficient multi-scale processing suitable for object detection and instance segmentation.
Experimental Evaluation
The models were evaluated on rigorous benchmarks including ADE20K, Cityscapes, Pascal Context, ImageNet-1K, and COCO 2017.
Key Results
- Semantic Segmentation: SETR achieved state-of-the-art results, reaching 50.28% mIoU on ADE20K and 82.2% mIoU on Cityscapes, outperforming established CNN-based models like DeepLabV3+.
- Efficiency and Versatility: The HLG-Tiny model outperformed ResNet-18 on COCO object detection by 11.5% AP while using fewer parameters. On ImageNet-1K, HLG-Large achieved a top-1 accuracy of 84.1%.
- Qualitative Advantage: Visualizations indicate that Transformer-based models are superior at identifying thin structures (e.g., railings) and large, uniform objects (e.g., buses) compared to dilated FCNs.
Discussion and Future Directions
The success of SETR and HLG underscores that global context is a critical component for dense prediction. By avoiding the "local-only" view of early convolutional layers, Transformers can better resolve complex spatial relationships. However, challenges remain:
- Computational Complexity: Standard self-attention scales quadratically with the number of patches, making high-resolution processing difficult without windowing techniques like those in HLG.
- Data Dependency: These models benefit significantly from large-scale pre-training (e.g., ImageNet-21K), suggesting they are more "data-hungry" than traditional CNNs.
- Hardware Optimization: Current hardware is highly optimized for convolutions; further efficiency gains may come from hardware-aware Transformer designs.
In summary, this work provides a new blueprint for visual representation learning, bridging the gap between global sequence modeling and dense pixel-level prediction.
Summary updated