QuadTree Attention for Vision Transformers
Shitao Tang, Jiahui Zhang, Siyu Zhu, Ping Tan
Introcution
Transformers can capture long-range dependencies by the attention module and have demonstrated tremendous success in natural language processing tasks. In recent years, transformers have also been adapted to computer vision tasks for image classification (Dosovitskiy et al., 2020), object detection (Wang et al., 2021c), semantic segmentation (Liu et al., 2021), feature matching (Sarlin et al., 2020), and stereo (Li et al., 2021), etc. Typically, images are divided into patches and these patches are flattened and fed to a transformer as word tokens to evaluate attention scores. However, transformers have quadratic computational complexity in terms of the number of tokens, i.e. number of image patches. Thus, applying transformers to computer vision applications requires careful simplification of the involved computation.
To utilize the standard transformer in vision tasks, many works opt to apply it on low resolution or sparse tokens. ViT (Dosovitskiy et al., 2020) uses coarse image patches of pixels to limit the number of tokens. DPT (Ranftl et al., 2021) up-samples low-resolution results from ViT to high resolution maps to achieve dense predictions. SuperGlue (Sarlin et al., 2020) applies transformer on sparse image keypoints. Focusing on correspondence and stereo matching applications, Germain et al. (2021) and Li et al. (2021) also apply transformers at a low resolution feature map.
However, as demonstrated in several works (Wang et al., 2021c; Liu et al., 2021; Sun et al., 2021; Li et al., 2021; Shao et al., 2020), applying transformers on high resolution is beneficial for a variety of tasks. Thus, many efforts have been made to design efficient transformers to reduce computational complexity. Linear approximate transformers (Katharopoulos et al., 2020; Wang et al., 2020) approximate standard attention computation with linear methods. However, empirical studies (Germain et al., 2021; Chen et al., 2021) show those linear transformers are inferior in vision tasks. To reduce the computational cost, the PVT (Wang et al., 2021c) uses downsampled keys and values, which is harmful to capture pixel-level details. In comparison, the Swin Transformer (Liu et al., 2021) restricts the attention in local windows in a single attention block, which might hurt long-range dependencies, the most important merit of transformers.
Unlike all these previous works, we design an efficient vision transformer that captures both fine image details and long-range dependencies. Inspired by the observation that most image regions are irrelevant, we build token pyramids and compute attention in a coarse to fine manner. In this way, we can quickly skip irrelevant regions in the fine level if their corresponding coarse level regions are not promising. For example, as in Figure 1, at the 1st level, we compute the attention of the blue image patch in image A with all the patches in image B and choose the top (here, ) patches which are also highlighted in blue. In the 2nd level, for the four framed sub-patches in image A (which are children patches of the blue patch at the 1st level), we only compute their attentions with the sub-patches corresponding to the top patches in image B at the 1st level. All the other shaded sub-patches are skipped to reduce computation. We highlight two sub-patches in image A in yellow and green. Their corresponding top patches in image B are also highlighted in the same color. This process is iterated in the 3rd level, where we only show the sub-sub-patches corresponding to the green sub-patch at the 2nd level. In this manner, our method can both obtain fine scale attention and retain long-range connections. Most importantly, only sparse attention is evaluated in the whole process. Thus, our method has low memory and computational costs. Since a quadtree structure is formed in this process, we refer to our method as QuadTree Attention, or QuadTree Transformer.
In experiments, we demonstrate the effectiveness of our quadtree transformer in both tasks requiring cross attention, e.g. feature matching and stereo, and tasks only utilizing self-attention, e.g. image classification and object detection. Our method achieves state-of-the-art performance with significantly reduced computation, comparing to relevant efficient transformers (Katharopoulos et al. (2020); Wang et al. (2021c); Liu et al. (2021)). In feature matching, we achieve 61.6 AUC@20∘ in ScanNet (Dai et al., 2017), 4.0 higher than the linear transformer (Katharopoulos et al., 2020) but with similar flops. In stereo matching, we achieve a similar end-point-error as standard transformer, (Li et al., 2021) but with about 50% flops reduction and 40% memory reduction. In image classification, we achieve 84.0% top-1 accuracy in ImageNet (Deng et al., 2009), 5.7% higher than ResNet152 (He et al., 2016) and 1.0% higher than the Swin Transformer-S (Liu et al., 2021). In object detection, our QuadTree Attention + RetinaNet achieves 47.9 AP in COCO (Lin et al., 2014), 1.8 higher than the backbone PVTv2 (Wang et al., 2021b) with fewer flops. In semantic segementation, QuadTree Attention improves the performance by 0.7-2.4%.
Related work
Efficient Transformers. Transformers have shown great success in both natural language processing and computer vision. Due to the quadratic computational complexity, the computation of full attention is unaffordable when dealing with long sequence tokens. Therefore, many works design efficient transformers, aiming to reduce computational complexity (Katharopoulos et al., 2020; Choromanski et al., 2020; Shao et al., 2021; Wang et al., 2020; Lee et al., 2019; Ying et al., 2018). Current efficient transformers can be categorized into three classes. 1) Linear approximate attention (Katharopoulos et al., 2020; Choromanski et al., 2020; Wang et al., 2020; Beltagy et al., 2020; Zaheer et al., 2020) approximates the full attention matrix by linearizing the softmax attention and thus can accelerate the computation by first computing the product of keys and values. 2) Inducing point-based linear transformers (Lee et al., 2019; Ying et al., 2018) use learned inducing points with fixed size to compute attention with input tokens, thus can reduce the computation to linear complexity. However, these linear transformers are shown to have inferior results than standard transformers in different works (Germain et al., 2021; Chen et al., 2021). 3) Sparse attention, including Longformer (Beltagy et al., 2020), Big Bird (Zaheer et al., 2020), etc, attends each query token to part of key and value tokens instead of the entire sequence. Unlike these works, our quadtree attention can quickly skip the irrelevant tokens according to the attention scores at coarse levels. Thus, it achieves less information loss while keeps high efficiency.
Vision Transformers. Transformers have shown extraordinary performance in many vision tasks. ViT (Dosovitskiy et al., 2020) applies transformers to image recognition, demonstrating the superiority of transformers for image classification at a large scale. However, due to the computational complexity of full attention, it is hard to apply transformers in dense prediction tasks, e.g. object detection, semantic segmentation, etc. To address this problem, Swin Transformer (Liu et al., 2021) restricts attention computation in a local window. Focal transformer (Yang et al., 2021) uses two-level windows to increase the ability to capture long-range connection for local attention methods. Pyramid vision transformer (PVT) (Wang et al., 2021c) reduce the computation of global attention methods by downsampling key and value tokens. Although these methods have shown improvements in various tasks, they have drawbacks either in capturing long-range dependencies (Liu et al., 2021) or fine level attention (Wang et al., 2021c). Different from these methods, our method simultaneously capture both local and global attention by computing attention from full image levels to the finest token levels with token pyramids in one single block. Besides, the K-NN transformers (Wang et al., 2021a; Zhao et al., 2019) aggregate messages from top most similar tokens as ours, but they compute the attention scores among all pairs of query and key tokens, and thus still has quadratic complexity.
Beyond self-attention, many tasks can largely benefit from cross attention. Superglue (Sarlin et al., 2020) processes detected local descriptors with self- and cross attention and shows significant improvement in feature matching. Standard transformers can be applied in SuperGlue because only sparse keypoints are considered. SGMNet (Chen et al., 2021) further reduces the computation by attending to seeded matches. LoFTR (Sun et al., 2021) utilizes linear transformer (Katharopoulos et al., 2020) on low-resolution feature maps to generate dense matches. For stereo matching, STTR (Li et al., 2021) applies self- and cross attention along epipolar lines and reduces the memory by gradient checkpointing engineering techniques. However, due to the requirement of processing a large number of points, these works either use linear transformers, which compromise performance, or a standard transformer, which compromises efficiency. In contrast, our transformer with quadtree attention achieves a significant performance boost compared with linear transformer or efficiency improvement compared with standard transformer. Besides, it can be applied to both self-attention and cross attention.
Method
We first briefly review the attention mechanism in transformers in Section 3.1 and then formulate our quadtree attention in Section 3.2.
Vision transformers have shown great success in many tasks. At the heart of a transformer is the attention module, which can capture long-range information between feature embeddings. Given two image embeddings and , the attention module passes information between them. Self-attention is the case when and are the same, while cross attention covers a more general situation when and are different. It first generates the query , key , and value by the following equation,
where , and are learnable parameters. Then, it performs message aggregation by computing the attention scores between query and key as following,
where is the embedding channel dimension. The above process has computational complexity, where is the number of image patches in a vision transformer. This quadratic complexity hinders transformers from being applied to tasks requiring high resolution output. To address this problem, PVT (Wang et al. (2021c)) downsamples and , while Swin Transformer (Liu et al. (2021)) limits the attention computation within local windows.
2 QuadTree Attention
In order to reduce the computational cost of vision transformers, we present QuadTree Attention. As the name implies, we borrow the idea from quadtrees, which are often used to partition a two-dimensional space by recursively subdividing it into four quadrants or regions. Quadtree attention computes attention in a coarse to fine manner. According to the results at the coarse level, irrelevant image regions are skipped quickly at the fine level. This design achieves less information loss while keeping high efficiency.
The same as the regular transformers, we first linearly project and to the query, key, and value tokens. To facilitate fast attention computation, we construct -level pyramids for query , key , and value tokens by downsampling feature maps. For query and key tokens, we use average pooling layers. For value tokens, average pooling is used for cross attention tasks and convolutional-normalization-activation layers with stride 2 are used for self attention tasks if no special statement. As shown in Figure 1, after computing attention scores in the coarse level, for each query token, we select the top key tokens with the highest attention scores. At the fine level, query sub-tokens only need to be evaluated with those key sub-tokens that correspond to one of the selected key tokens at the coarse level. This process is repeated until the finest level. After computing the attention scores, we aggregate messages at all levels, where we design two architectures named as QuadTree-A and QuadTree-B.
QuadTree-A. Considering the -th query token at the finest level, we need to compute its received message from all key tokens. This design assembles the full message by collecting partial messages from different pyramid levels. Specifically,
where indicates the partial message evaluated at level . This partial message assemble messages at the -th level from tokens within the region , which will be defined later. In this way, messages from less related regions are computed from coarse levels, while messages from highly related regions are computed in fine levels. This scheme is illustrated in Figure 2 (b), message is generated by assembling three partial messages that are computed from different image regions with different colors, which collectively cover the entire image space. The green region indicates the most relevant region and is evaluated at the finest level, while the red region is the most irrelevant region and is evaluated at the coarsest level. The region can be defined as , where the image region corresponds to the top tokens at the level . The regions are illustrated in Figure 2 (c). The region covers the entire image.
where is the attention score between the query and key tokens at level . Figure 2 (a) highlights query and key tokens involved in computing with the same color as . Attention scores are computed recursively,
Here, is the score of corresponding parent query and key tokens and . The tentative attention score is evaluated according to Equation 1 among the tokens of the same parent query token. For QuadTree-A, we use average pooling layers to downsample all query, key and value tokens.
QuadTree-B. The attention scores in QuadTree-A are recursively computed from all levels, which makes scores smaller at finer levels and reduces the contributions of fine image features. Besides, fine level scores are also largely affected by the inaccuracy at coarse levels. So we design a different scheme, referred as QuadTree-B in this paper, to address this problem. Specifically, we compute as a weighted average of the partial messages from different levels,
where is a learned weight. As shown in Figure 2 (c), the partial messages here overlap with each other, which are computed as,
where Attention is the attention message computation as Equation 1. Here, and are matrices formed by stacking all keys and values within the region .
Both QuadTree-A and QuadTree-B involve only sparse attention evaluation. Thus, our method largely reduces computational complexity. As analyzed in Appendix A.1, the computational complexity of our quadtree attention is linear to the number of tokens.
Multiscale position encoding. The computation of attention is permutation invariant to tokens, and thus positional information is missed. To address this problem, we adopt the locally-enhanced positional encoding (LePE) (Dong et al., 2021) at each level to design a multiscale position encoding. Specifically, for level , we apply unshared depth-wise convolution layers to value tokens to encode the positional information.
Experiment
We experiment our quadtree transformer with four representative tasks, including feature matching, stereo, image classification, and object detection. The first two tasks require cross attention to fuse information across different images, while the latter two involve only self-attention. We implement our quadtree transformer using PyTorch and CUDA kernels. More implementation details are provided in Appendix B.
Finding feature correspondence (Luo et al., 2019; DeTone et al., 2018) across different images is a precedent problem for many 3D computer vision tasks. It is typically evaluated by the accuracy of the camera pose estimated from the corresponding points. We follow the framework proposed in a recent state-of-the-art work LoFTR (Sun et al., 2021), which consists of a CNN-based feature extractor and a transformer-based matcher. We replace the linear transformer (Katharopoulos et al., 2020) in LoFTR with our quadtree transformer. Besides, we also implement a new version of LoFTR with the spatial reduction (SR) attention (Wang et al., 2021c) for additional comparison.
Setting. We experiment on ScanNet (Dai et al., 2017) with 1,513 scans. In order to accelerate training, we design the LoFTR-lite setting, which uses half of the feature channels of LoFTR and 453 training scans. Ablation studies in section 4.3 are conducted in this setting. We train both LoFTR-lite and LoFTR for 30 epochs with batch size 8. For quadtree transformer, we build pyramids of three levels with the coarsest resolution at pixels. We set the parameter to 8 at the finest level, and double it at coarser levels. For the SR attention, we average pool the value and key tokens to the size to keep similar memory usage and flops as our quadtree attention. More details are included in Appendix B.1.
Results. Table 1 shows the AUC of camera pose errorsCamera pose errors are evaluated as the differences between estimated and ground truth camera orientation and translation direction, both measured in degrees. under (5∘, 10∘, 20∘). We can see that the SR attention achieves similar results with linear transformer. In comparison, both QuadTree-A and QuadTree-B outperform linear transformer and SR attention by a large margin. Quadtree-B generally performs better than Quadtree-A. Quadtree-B has 2.6 and 1.9 improvements in terms of AUC@20∘ over linear transformer on LoFTR-lite and LoFTR respectively. To further enhance the results, we train a model with and leverage a ViT (Dosovitskiy et al., 2020)-like transformer archtecture instead of the original one used in (Sun et al., 2021). This model achieves 4 improvements on AUC@20∘ over (Sun et al., 2021), where the LoFTR model is trained with a batch size of 64 with 64 GPUs, a more preferable setting leading to slightly better results than our linear transformer implementation shown in Table 1.
1.2 Stereo Matching
Stereo matching aims to find corresponding pixels on epipolar lines between two rectified images. The recent work STTR (Li et al., 2021) applies transformers to feature points between epipolar lines and achieves state-of-the-art performance. Note here, both self- and cross attention are applied along epipolar lines, pixels across different lines are not considered in the attention computation. We replace the standard transformer in STTR (Li et al., 2021) with our quadtree transformer.
Setting. We experiment on the Scene Flow FlyingThings3D (Mayer et al., 2016) synthetic dataset, which contains 25,466 images with a resolution of . We build pyramids of four levels to evaluate quadtree attention. While the STTR is applied to features of 1/3 of image resolution, we use feature maps of 1/2 of image resolution. More details about the network are included in Appendix B.2.
Results. We report EPE (End-Point-Error) in non-occluded regions and IOU (Intersection-over-Union) for occlusion estimation in Table 2 as (Li et al., 2021). Computational complexity and memory usage are also reported. Compared with STTR based on the standard transformer, our quadtree transformer achieves similar EPE (0.45 px vs 0.46 px) and higher IOU for occlusion estimation, but with much lower computational and memory costs, with only 52% FLOPs and 63% memory consumption.
2 Self-attention task
This section presents results on image classification and object detection. In the past, convolutional neural networks (CNNs) have dominated these tasks for a long time. Recently, vision transformers (Dosovitskiy et al., 2020; Liu et al., 2021; Wang et al., 2021c) show excellent potential on these problems, thanks to their capability in capturing long-range interactions. To compare our method with these vision transformers on image classification, we use the public codes of PVTv2 (Wang et al., 2021c) and replace all the spatial reduction attention with our quadtree attention. For object detection, we further apply a representative object detection framework, RetinaNet (Lin et al., 2017), which is a widely used single-stage object detector.
Settings. We evaluate image classification on the ImageNet-1K dataset (Deng et al., 2009), which consists of 1.28M training images and 50K validation images from 1,000 categories. We build token pyramids with the coarsest level at a resolution of and set . We crop and resize the input images to pixels and train the model with a mini-batch of 128. All models are trained for 300 epochs from scratch on 8 GPUs. All the other training settings are the same as in (Wang et al., 2021c). We build five different quadtree transformers at different complexity, named as b0, b1, b2, b3, b4. These models are gradually deeper and wider. More configuration details can be found in Appendix. B.3.
Results. We provide the top-1 accuracy of various methods and network settings in Table 3. These results are grouped into five sections, each with several methods of similar network complexity, as indicated by the number of parameters. As shown in Table 3, QuadTree-B outperforms PVTv2 by 0.4%-1.5% in top-1 accuracy with fewer parameters. Swin Transformer-S adopts local attention and is surpassed by our QuadTree-B-b2 by 1.0% in top-1 accuracy. This result proves that global information is important. In general, our quadtree transformer leverages both global information at the coarse level and local information at fine levels, and outperforms both PVTv2 and Swin Transformer.
2.2 Object detection
Settings. We experiment on the COCO dataset. All models are trained on COCO train 2017 (118k images) and evaluated on val 2017 (5k images). We initialize the quadtree backbone with the weights pre-trained on ImageNet. We adopt the same setting as PVTv2, training the model with a batch size of 16 and AdamW optimizer with an initial learning rate of for 12 epochs. We use the standard metric average precision to evaluate our method.
Results. We mainly compare our method with PVTv2, ResNet (He et al., 2016), and ResNeXt (Xie et al., 2017) using detection framework of RetinaNet (Lin et al., 2017), which are state-of-the-art backbones for dense prediction. Table 4 lists the average precision of different methods and their backbone flops for images of resolution of . Benefiting from the coarse to fine mechanism, a small is enough for our method. Thus, the computation can be reduced when using high resolution images. We can see that QuadTree-B achieves higher performance, but with much fewer flops than PVTv2. Our quadtree transformer also outperforms ResNet and ResNeXt. For example, QuadTree-B-b2 outperform ResNet101 and ResNeXt101-32x4d by 7.7 AP and 6.3 AP respectively with about 40% backbone flops reduction. We also show Mask-RCNN results (He et al., 2017) in Appendix. E.
3 Comparison with other attention mechanisms
For a fair comparison with other attention mechanisms, we test these attention mechanisms under the same backbone and training settings. Specifically, we replace the original attention module in PVTv2-b0 with the attention method used in Swin Transformer and Focal Transformer. For more fair comparison, we adopt the same positional encoding LePE (Dong et al., 2021) to PVTv2, Swin and Focal transformer. As shown in Table 5, QuadTree attention obtain consistently better performance than Swin and PVTv2 in both classification task and detection task. Compared with focal attention, our method gets 0.9 higher AP in object detection, which might be because that QuadTree attention can always cover the whole images, while Focal attention only covers of the image in the first stage. More experiments on Swin-like architecture can be found in Appendix E.
For cross attention tasks, we also provide visualization of attention score as shown in Fig.5 in Appendix E. Our method can attend to much more related regions than PVT (Wang et al., 2021b) and Linear attention (Katharopoulos et al., 2020).
Conclusion
We introduce QuadTree Attention to reduce the computational complexity of vision transformers from quadratic to linear. Quadtree transformers build token pyramids and compute attention in a coarse-to-fine manner. At each level, top regions with the highest attention scores are selected, such that in finer level, computation in irrelevant regions can be quickly skipped. Quadtree attention can be applied to cross attention as well as self-attention. It achieves state-of-the-art performance in various tasks including feature matching, stereo, image classification, and object detection.
References
Appendix A Appendix
In this section, we analyze the computational complexity of quadtree attention. Suppose the lengths of the query tokens, key tokens, and value tokens are all . We build token pyramids of levels, the level has a token length of . The flops of computing quadtree attention is,
Here, and are the height and width of the coarsest level of token pyramids. Therefore, is a constant and the computational complexity is . Since is a constant number, the complexity of quadtree attention is linear to the number of tokens.
Appendix B Additional experiments and implementation details
Implementation details. We train and evaluate the model in ScanNet (Dai et al., 2017), where 230M image pairs is sampled for training, with overlapping scores between 0.4 and 0.8. ScanNet provides RGB images, depth maps, and ground truth camera poses on a well-defined training and testing split. Following the same evaluation settings as Sarlin et al. (2020) and Sun et al. (2021), we evaluate our method on the 1,500 testing pairs from (Sarlin et al., 2020). For both trainig and testing, all images and depth maps are resized to 640 × 480. Following (Sun et al., 2021), we compute the camera pose by solving the essential matrix from predicted matches with RANSAC. We report the AUC of the pose error at thresholds (5∘, 10∘, 20∘), where the pose error is defined as the maximum of angular error in rotation and translation. We only replace the coarse level transformer with quadtree attention.
Results of megadepth. We show our results on Megadepth (Li & Snavely, 2018) in Table 6. We can see our method outperforms others by a large margin.
B.2 Stereo matching
Our network is based on the STTR (Li et al., 2021), where we replace the standard transformer with our quadtree transformer. The network consists of a CNN backbone which outputs feature maps of 1/2 image resolution, a quadtree transformer with both self- and cross attention, a regression head with optimal transport layers (Cuturi, 2013), and a context adjust layer to refine the disparity. Six self- and cross attention layers are used with 128 channels. We build pyramids with four levels for quadtree attention, and apply the Sinkhorn algorithm (Cuturi, 2013) for 10 iteration for optimal transport. We follow STTR to train the network, with 15 epochs of AdamW optimizer. OneCycle learning rate scheduler is used with a leaning rate of 6e-4 and a batch size of 8.
B.3 Image classification
This paragraph introduces the details of PVTv2-b0, b1, b2, b3, b4. All these five networks have 4 stages. Each stage is down-sampled from the previous stage by a stride of 2. The feature resolutions for each stage are , , and respectively, where and is the image height and width. For each stage, quadtree transformers are used with a channel number of and head number of . For the network PVTv2-b0, the parameters , , are set to , $MIJMIJMIJMIJ$ respectively.
B.4 Object detection and instance segmentation
We show the object detection and instance segmentation results of Mask-RCNN (He et al., 2017) in Table 7 and Table 8 in different training settings. In Table 7, we train Mask-RCNN for 12 epoch and resize the image to while In Table 8, we train the model for 36 epochs and resize the training images to different scales for data augmentation. We can see that the QuadTree attention obtains consistently better performance than other methods.
Appendix C Training loss
Feature matching. We plot the training loss and validation performance for LoFTR-lite in Figure 3 for different efficient transformers, including spatial reduction (SR) transformer (Wang et al., 2021c), linear transformer (Katharopoulos et al., 2020), our Quadtree-A, and Quadtree-B transformers. We can see quadtree-B transformer obtains consistently lower training loss and higher performance over other three transformers. In addition, it is also noted that the spatial reduction (SR) transformer has lower training but worse AUC@20∘ than QuadTree-A attention, which indicates that it cannot generalize well.
Image classification. We also show traning and validation curve for image classification task with respective to different attentions in Fig. 4. Compared with Swin Transformer (Liu et al., 2021) and PVT (Wang et al., 2021c), the loss of Quadtree attention is consistently lower and the top 1 accuracy is higher.
Appendix D Running time
Currently, we only implement a naive CUDA kernel without many optimizations and it is not as efficient as the well-optimized dense GPU matrix operation. We test the running time of Retinanet under PVTv2-b0 architecture. For PVTv2-b0, The running time is 0.026s to forward one image and for Quadtree-b0, the running time is 0.046s for forwarding once. However, Quadtree-b0 has much lower memory usage than PVTv2-b0. Quadtree-b0 consumes about 339MB while PVTv2-b0 consumes about 574MB for one image.
Appendix E Ablations
QuadTree-A vs QuadTree-B. QuadTree-B architecture consistently outperforms QuadTree-A in feature matching, image classification, and detection experiments. We analyze its reason as shown in Figure 5, where (d) and (e) show the attention score maps of QuadTree-A and QuadTree-B at different levels for the same point in the query image shown in (a). It is clear that the QuadTree-B has more accurate score maps, and is less affected by the inaccuracy in coarse level score estimation. We further visualize the attention scores of spatial reduction (SR) attention (Wang et al., 2021c) and linear transformer (Katharopoulos et al., 2020) in (b) and (c). We can see that SR attention and linear transformer attend the query token on large unrelated regions due to the loss of fine-grained information. In contrast, our quadtree transformer focus on the most relevant area.
Comparison with Swin Transformer and Focal Transformer. We compare with Swin Transformer and Focal Transformer in Table. 9 using the released codes. We replace the corresponding attention in Swin Transformer with Quadtree-B attention. Our method obtains 0.9% higher top 1 accuracy than Swin Transformer and 2.6% higher AP in object detection. Compared with Focal transformer, quadtree attention achieve the same top 1 accuracy in classification with fewer flops, and 0.9% higher AP in object detection.
Multiscale position encoding. We compare our method with or without multiscale position encoding (MPE). For Quadtree-B-b2 model, MPE can bring an improvement of 1.3 on object detection.
Top numbers. Table 12 and Table 12 shows the performance of QuadTree-B architecture with different value of for object detection and feature matching respectively. The performance is improved when becomes larger and saturates quickly. This indicates only a few tokens with high attention scores should be subdivided in the next level for computing attentions.