[Paper Review] Vision Transformer with Quadrangle Attention
This paper proposes Quadrangle Attention (QA), a learnable, data-driven alternative to fixed-window self-attention in Vision Transformers that dynamically shapes attention regions into adaptive quadrangles via a differentiable regression module. By learning transformation matrices for each head, QA enables attention to focus on objects of varying sizes, shapes, and orientations, significantly improving performance across classification, detection, segmentation, and pose estimation with minimal computational overhead, as demonstrated by SOTA results on ImageNet and COCO benchmarks.
Window-based attention has become a popular choice in vision transformers due to its superior performance, lower computational complexity, and less memory footprint. However, the design of hand-crafted windows, which is data-agnostic, constrains the flexibility of transformers to adapt to objects of varying sizes, shapes, and orientations. To address this issue, we propose a novel quadrangle attention (QA) method that extends the window-based attention to a general quadrangle formulation. Our method employs an end-to-end learnable quadrangle regression module that predicts a transformation matrix to transform default windows into target quadrangles for token sampling and attention calculation, enabling the network to model various targets with different shapes and orientations and capture rich context information. We integrate QA into plain and hierarchical vision transformers to create a new architecture named QFormer, which offers minor code modifications and negligible extra computational cost. Extensive experiments on public benchmarks demonstrate that QFormer outperforms existing representative vision transformers on various vision tasks, including classification, object detection, semantic segmentation, and pose estimation. The code will be made publicly available at \href{https://github.com/ViTAE-Transformer/QFormer}{QFormer}.
Motivation & Objective
- To address the limitation of fixed, hand-crafted square windows in window-based self-attention, which constrain the model's ability to adapt to objects of varying sizes, shapes, and orientations.
- To develop a data-driven attention mechanism that learns optimal quadrangle-shaped attention regions directly from input data, enhancing feature representation and long-range modeling.
- To integrate the proposed QA into both plain and hierarchical Vision Transformer architectures with minimal code changes and negligible computational cost.
- To demonstrate that the resulting QFormer architecture achieves state-of-the-art performance across diverse vision tasks, including image classification, object detection, semantic segmentation, and pose estimation.
Proposed method
- Proposes a novel Quadrangle Attention (QA) mechanism that replaces fixed square windows with learnable quadrangles, enabling adaptive attention regions based on input data.
- Introduces an end-to-end learnable quadrangle regression module that predicts a transformation matrix per attention head to map default square windows to target quadrangles.
- The transformation matrix is composed of basic geometric operations—translation, scaling, rotation, shearing, and projection—ensuring training stability and interpretability.
- Each multi-head attention head independently applies its own quadrangle transformation, allowing diverse attention patterns and facilitating information exchange across overlapping windows.
- Integrates QA into both plain and hierarchical Vision Transformers to create QFormer, requiring only minor code modifications and incurring negligible extra computation.
- Uses sparse token sampling within each predicted quadrangle, maintaining computational efficiency by limiting the number of tokens per window to match the default window size.
Experimental results
Research questions
- RQ1Can a learnable, adaptive attention mechanism outperform fixed-window self-attention in modeling objects of diverse shapes and orientations in vision tasks?
- RQ2How does the proposed quadrangle attention mechanism improve feature representation and long-range dependency modeling compared to standard window-based attention?
- RQ3To what extent does the QFormer architecture, built with quadrangle attention, improve performance across diverse vision benchmarks such as ImageNet, COCO, and Cityscapes?
- RQ4How do the learned transformation parameters (e.g., scaling, rotation) vary across layers and model depths, and what do they reveal about the attention dynamics during feature learning?
- RQ5Does the adaptive attention mechanism enable better performance with minimal computational overhead compared to existing state-of-the-art Vision Transformers?
Key findings
- QFormer achieves state-of-the-art performance on ImageNet-1K classification, outperforming Swin Transformer across all input resolutions, with improvements of up to 1.2% top-1 accuracy.
- The proposed QA mechanism achieves significantly larger average attention distances than vanilla window attention, especially in deeper layers, indicating enhanced long-range modeling capability.
- Visualization of scaling factors shows that early layers in QFormer focus on local structures (mean scaling ~1.0), while deeper layers exhibit diverse scaling (both >1.0 and ~1.0), enabling multi-scale context aggregation.
- The standard deviation of attention distances in QA is higher than in Swin Transformer, indicating greater diversity in attention regions, which supports richer contextual modeling and cross-window information exchange.
- Ablation studies confirm that the quadrangle regression module and independent head-wise transformations are essential for performance gains, with ablation on these components leading to significant accuracy drops.
- The model maintains negligible computational cost and minimal code changes, making QA a practical and effective plug-in for existing Vision Transformer architectures.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.