Vicinity Vision Transformer

Weixuan Sun, Zhen Qin, Hui Deng, Jianyuan Wang, Yi Zhang +5 more
6/21/2022
cs.CV
transformer-attention

Official code: OpenNLPLab/Vicinity-Vision-Transformer (23 stars, Python, Apache-2.0, PyTorch, last commit 2023-06-15).

Abstract

Vision transformers have shown great success on numerous computer vision tasks. However, its central component, softmax attention, prohibits vision transformers from scaling up to high-resolution images, due to both the computational complexity and memory footprint being quadratic.

Show full abstract

Although linear attention was introduced in natural language processing (NLP) tasks to mitigate a similar issue, directly applying existing linear attention to vision transformers may not lead to satisfactory results. We investigate this problem and find that computer vision tasks focus more on local information compared with NLP tasks. Based on this observation, we present a Vicinity Attention that introduces a locality bias to vision transformers with linear complexity. Specifically, for each image patch, we adjust its attention weight based on its 2D Manhattan distance measured by its neighbouring patches. In this case, the neighbouring patches will receive stronger attention than far-away patches. Moreover, since our Vicinity Attention requires the token length to be much larger than the feature dimension to show its efficiency advantages, we further propose a new Vicinity Vision Transformer (VVT) structure to reduce the feature dimension without degenerating the accuracy. We perform extensive experiments on the CIFAR100, ImageNet1K, and ADE20K datasets to validate the effectiveness of our method. Our method has a slower growth rate of GFlops than previous transformer-based and convolution-based networks when the input resolution increases. In particular, our approach achieves state-of-the-art image classification accuracy with 50% fewer parameters than previous methods.

View on arXivView PDF

Code Implementations(1)

PyTorchApache-2.0

[TPAMI 2023] This is an official implementation for "Vicinity Vision Transformer".

232Python, ShellJun 17, 20223 years agoApache-2.0
backboneimagenetpytorchtransformervision-transformer

Similar Papers

Cite this paper

@article{sun2022vicinity,
  title  = {Vicinity Vision Transformer},
  author = {Weixuan Sun and Zhen Qin and Hui Deng and Jianyuan Wang and Yi Zhang and Kaihao Zhang and Nick Barnes and Stan Birchfield and Lingpeng Kong and Yiran Zhong},
  year   = {2022},
  eprint = {2206.10552},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2206.10552}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2206.10552.svg)](https://codeofpaper.com/paper/2206.10552)

Discussion