Abstract
In this work, we introduce Dual Attention Vision Transformers (DaViT), a simple yet effective vision transformer architecture that is able to capture global context while maintaining computational efficiency. We propose approaching the problem from an orthogonal angle: exploiting self-attention mechanisms with both "spatial tokens" and "channel tokens". With spatial tokens, the spatial dimension defines the token scope, and the channel dimension defines the token feature dimension. With channel tokens, we have the inverse: the channel dimension defines the token scope, and the spatial dimension defines the token feature dimension. We further group tokens along the sequence direction for both spatial and channel tokens to maintain the linear complexity of the entire model. We show that these two self-attentions complement each other: (i) since each channel token contains an abstract representation of the entire image, the channel attention naturally captures global interactions and representations by taking all spatial positions into account when computing attention scores between channels; (ii) the spatial attention refines the local representations by performing fine-grained interactions across spatial locations, which in turn helps the global information modeling in channel attention. Extensive experiments show our DaViT achieves state-of-the-art performance on four different tasks with efficient computations. Without extra data, DaViT-Tiny, DaViT-Small, and DaViT-Base achieve 82.8%, 84.2%, and 84.6% top-1 accuracy on ImageNet-1K with 28.3M, 49.7M, and 87.9M parameters, respectively. When we further scale up DaViT with 1.5B weakly supervised image and text pairs, DaViT-Gaint reaches 90.4% top-1 accuracy on ImageNet-1K.
Introduction
The primary bottleneck in standard Vision Transformers (ViTs) is the quadratic complexity of self-attention. In a standard ViT, every image patch (token) attends to every other token, meaning computational costs quadruple ($O(N^2)$) when image resolution doubles. This scaling behavior makes high-resolution processing for tasks like object detection or medical imaging prohibitively expensive.
Existing solutions, such as the Swin Transformer, utilize local windows to restrict attention to small neighborhoods. While this achieves linear complexity, it sacrifices the global receptive field that makes Transformers powerful. To compensate, researchers often introduce complex mechanisms like shifted windows or squeezed projections to re-introduce global information, which can complicate architecture design and hinder inference speed.
Methodology: Dual Attention
DaViT addresses these challenges through a clean, orthogonal approach called Dual Attention. Instead of attempting to make global spatial attention efficient through approximation, the architecture alternates between two distinct attention blocks that operate on different tokenizations of the same feature map.
- Spatial Window Multihead Self-attention: This block handles local interactions. The image is partitioned into non-overlapping spatial windows, and attention is computed only within these windows. This allows the model to capture fine-grained textures and local structures efficiently.
- Channel Group Self-attention: This block provides global context. By transposing the feature matrix, the model treats channels as tokens and spatial dimensions as feature dimensions. Because each channel token effectively aggregates information from the entire spatial extent of the image, attending across channels naturally captures global interactions.
To maintain linear complexity ($O(N)$) relative to both spatial and channel dimensions, the model groups tokens along the sequence direction for both types of attention. By alternating these blocks, DaViT refines local representations in one step and fuses them globally in the next, avoiding any $O(N^2)$ operations.
Experiments and Results
DaViT was evaluated across a comprehensive suite of computer vision benchmarks, including ImageNet-1K for classification, MS COCO 2017 for object detection and instance segmentation, and ADE20K for semantic segmentation. For extreme scaling, a version of the model (DaViT-Giant) was pre-trained on a private dataset of 1.5 billion weakly supervised image-text pairs.
Key Performance Metrics
- Image Classification: DaViT-Tiny (28.3M parameters) achieves 82.8% top-1 accuracy on ImageNet-1K, significantly outperforming Swin-Tiny (81.2%) at a similar computational cost. The DaViT-Giant model reached a staggering 90.4% top-1 accuracy.
- Object Detection & Segmentation: On COCO, DaViT-Tiny outperforms Focal-Tiny and Swin-Tiny while utilizing fewer FLOPs. In semantic segmentation on ADE20K, it achieves 46.3% mIoU, setting a new benchmark for "tiny" scale backbones.
- Hardware Efficiency: Beyond theoretical FLOPs, DaViT demonstrates superior real-world throughput. For instance, DaViT-Base processes 523 samples/s on an NVIDIA V100, compared to 496 samples/s for Swin-Base, proving its hardware-friendly nature.
Discussion and Key Insights
The core innovation of DaViT lies in the realization that channel-wise attention is inherently global. While spatial attention focuses on "where" features are located, channel attention identifies "what" features are present across the entire image. These two mechanisms are highly complementary: spatial attention refines the local details that are subsequently summarized into global channel tokens.
Furthermore, the simplicity of the architecture is a major advantage. By avoiding complex operations like shifted windows, DaViT is easier to implement and more efficient on modern GPU hardware. The architecture also exhibits strong scaling laws, consistently improving in performance as parameters and data scale up.
Conclusion
DaViT introduces a powerful yet simple paradigm for vision transformers. By alternating between spatial and channel-based attention, it achieves a global receptive field with linear complexity. While the most extreme results were achieved using massive private datasets, the underlying architecture provides a robust, efficient backbone for a wide variety of vision tasks. Future work may involve extending this dual-attention duality to video understanding and multi-modal domains.
Summary updated