journal article·2023-02-03Open access

LGViT: A Local and Global Vision Transformer with Dynamic Contextual Position Bias Using Overlapping Windows

Qian Zhou, Hua Zou, Huanhuan Wu

Applied Sciences· Volume 13· Issue 3

Abstract

Vision Transformers (ViTs) have shown their superiority in various visual tasks for the capability of self-attention mechanisms to model long-range dependencies. Some recent works try to reduce the high cost of vision transformers by limiting the self-attention module in a local window. As a price, the adopted window-based self-attention also reduces the ability to capture the long-range dependencies compared with the original self-attention in transformers. In this paper, we propose a Local and Global Vision Transformer (LGViT) that incorporates overlapping windows and multi-scale dilated pooling to robust the self-attention locally and globally. Our proposed self-attention mechanism is composed of a local self-attention module (LSA) and a global self-attention module (GSA), which are performed on overlapping windows partitioned from the input image. In LSA, the key and value sets are expanded by the surroundings of windows to increase the receptive field. For GSA, the key and value sets are expanded by multi-scale dilated pooling to promote global interactions. Moreover, a dynamic contextual positional encoding module is exploited to add positional information more efficiently and flexibly. We conduct extensive experiments on various visual tasks and the experimental results strongly demonstrate the outperformance of our proposed LGViT to state-of-the-art approaches.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Visual Attention and Saliency Detection · Advanced Neural Network Applications · CCD and CMOS Imaging Sensors

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

School of Computer Science, Wuhan University, Wuhan 430072, China

College of Information Engineering, Tarim University, Alar 843300, China

Funding

Bingtuan Science and Technology Program · Science and Technology Project of Tarim University

References (76)

Show source-provided references
1. Convolutional networks for images, speech, and time series
2. Imagenet classification with deep convolutional neural networks
3. He, K., Zhang, X., Ren, S., and Sun, J. (2016, January 27–30). Deep residual learning for image recognition. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA.10.1109/CVPR.2016.90 ↗
4. Attention is all you need
5. Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., and Gelly, S. (2020, January 26–30). An Image is Worth 16 × 16 Words: Transformers for Image Recognition at Scale. Proceedings of the International Conference on Learning Representations, Addis Ababa, Ethiopia.
6. Touvron, H., Cord, M., Douze, M., Massa, F., Sablayrolles, A., and Jégou, H. (2021, January 13–14). Training data-efficient image transformers & distillation through attention. Proceedings of the International Conference on Machine Learning, PMLR, Virtual.
7. Wu, H., Xiao, B., Codella, N., Liu, M., Dai, X., Yuan, L., and Zhang, L. (2021, January 10–17). Cvt: Introducing convolutions to vision transformers. Proceedings of the IEEE/CVF International Conference on Computer Vision, Montreal, QC, Canada.10.1109/ICCV48922.2021.00009 ↗
8. Liu, Z., Hu, H., Lin, Y., Yao, Z., Xie, Z., Wei, Y., Ning, J., Cao, Y., Zhang, Z., and Dong, L. (2022, January 18–24). Swin transformer v2: Scaling up capacity and resolution. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA.10.1109/CVPR52688.2022.01170 ↗
9. Dong, X., Bao, J., Chen, D., Zhang, W., Yu, N., Yuan, L., Chen, D., and Guo, B. (2022, January 18–24). Cswin transformer: A general vision transformer backbone with cross-shaped windows. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA.10.1109/CVPR52688.2022.01181 ↗
10. He, J., Chen, J.N., Liu, S., Kortylewski, A., Yang, C., Bai, Y., and Wang, C. (March, January 28). Transfg: A transformer architecture for fine-grained recognition. Proceedings of the AAAI Conference on Artificial Intelligence, Vancouver, BC, Canada.
11. Carion, N., Massa, F., Synnaeve, G., Usunier, N., Kirillov, A., and Zagoruyko, S. (2020, January 23–28). End-to-end object detection with transformers. Proceedings of the European Conference on Computer Vision, Glasgow, UK.10.1007/978-3-030-58452-8_13 ↗
12. Temporal-Channel Transformer for 3D Lidar-Based Video Object Detection for Autonomous Driving10.1109/TCSVT.2021.3082763 ↗
13. Sun, P., Tan, M., Wang, W., Liu, C., Xia, F., Leng, Z., and Anguelov, D. (2022, January 23–28). Swformer: Sparse window transformer for 3d object detection in point clouds. Proceedings of the European Conference on Computer Vision, Glasgow, UK.10.1007/978-3-031-20080-9_25 ↗
14. GasHis-Transformer: A multi-scale visual transformer approach for gastric histopathological image detection10.1016/j.patcog.2022.108827 ↗
15. Chen, W., Du, X., Yang, F., Beyer, L., Zhai, X., Lin, T.Y., Chen, H., Li, J., Song, X., and Wang, Z. (2022, January 23–28). A Simple Single-Scale Vision Transformer for Object Detection and Instance Segmentation. Proceedings of the European Conference on Computer Vision, Glasgow, UK.10.1007/978-3-031-20080-9_41 ↗
16. Prangemeier, T., Reich, C., and Koeppl, H. (2020, January 16–19). Attention-based transformers for instance segmentation of cells in microstructures. Proceedings of the 2020 IEEE International Conference on Bioinformatics and Biomedicine (BIBM), Seoul, Republic of Korea.10.1109/BIBM49941.2020.9313305 ↗
17. Zheng, S., Lu, J., Zhao, H., Zhu, X., Luo, Z., Wang, Y., Fu, Y., Feng, J., Xiang, T., and Torr, P.H. (2021, January 20–25). Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Nashville, TN, USA.10.1109/CVPR46437.2021.00681 ↗
18. UNetFormer: A UNet-like transformer for efficient semantic segmentation of remote sensing urban scene imagery10.1016/j.isprsjprs.2022.06.008 ↗
19. Gu, J., Kwon, H., Wang, D., Ye, W., Li, M., Chen, Y.H., Lai, L., Chandra, V., and Pan, D.Z. (2022, January 18–24). Multi-scale high-resolution vision transformer for semantic segmentation. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA.10.1109/CVPR52688.2022.01178 ↗
20. Zhang, W., Huang, Z., Luo, G., Chen, T., Wang, X., Liu, W., Yu, G., and Shen, C. (2022, January 18–24). TopFormer: Token Pyramid Transformer for Mobile Semantic Segmentation. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA.10.1109/CVPR52688.2022.01177 ↗
21. Wang, W., Yao, L., Chen, L., Lin, B., Cai, D., He, X., and Liu, W. (2022, January 25–29). CrossFormer: A Versatile Vision Transformer Hinging on Cross-scale Attention. Proceedings of the International Conference on Learning Representations, ICLR, Virtual.
22. Vaswani, A., Ramachandran, P., Srinivas, A., Parmar, N., Hechtman, B., and Shlens, J. (2021, January 20–25). Scaling local self-attention for parameter efficient visual backbones. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Nashville, TN, USA.10.1109/CVPR46437.2021.01270 ↗
23. Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., and Guo, B. (2021, January 10–17). Swin transformer: Hierarchical vision transformer using shifted windows. Proceedings of the IEEE/CVF International Conference on Computer Vision, Montreal, QC, Canada.10.1109/ICCV48922.2021.00986 ↗
24. Shaw, P., Uszkoreit, J., and Vaswani, A. (2018, January 2–4). Self-Attention with Relative Position Representations. Proceedings of the NAACL-HLT (2), New Orleans, LO, USA.10.18653/v1/N18-2074 ↗
25. Naushad, R., Kaur, T., and Ghaderpour, E. (2021). Deep transfer learning for land use and land cover classification: A comparative study. Sensors, 21.10.3390/s21238083 ↗
26. Yang, F., Yang, H., Fu, J., Lu, H., and Guo, B. (2020, January 14–19). Learning texture transformer network for image super-resolution. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA.10.1109/CVPR42600.2020.00583 ↗
27. Chen, H., Wang, Y., Guo, T., Xu, C., Deng, Y., Liu, Z., Ma, S., Xu, C., Xu, C., and Gao, W. (2021, January 20–25). Pre-trained image processing transformer. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Nashville, TN, USA.10.1109/CVPR46437.2021.01212 ↗
28. Liang, J., Cao, J., Sun, G., Zhang, K., Van Gool, L., and Timofte, R. (2021, January 20–25). SwinIR: Image restoration using swin transformer. Proceedings of the IEEE/CVF International Conference on Computer Vision, Nashville, TN, USA.10.1109/ICCVW54120.2021.00210 ↗
29. Souibgui, M.A., Biswas, S., Jemni, S.K., Kessentini, Y., Fornés, A., Lladós, J., and Pal, U. (2022, January 21–25). DocEnTr: An end-to-end document image enhancement transformer. Proceedings of the 2022 26th International Conference on Pattern Recognition (ICPR), Montreal, QC, Canada.10.1109/ICPR56361.2022.9956101 ↗
30. Boudiaf, A., Guo, Y., Ghimire, A., Werghi, N., De Masi, G., Javed, S., and Dias, J. (2022, January 9–13). Underwater Image Enhancement Using Pre-trained Transformer. Proceedings of the International Conference on Image Analysis and Processing, Trento, Italy.10.1007/978-3-031-06433-3_41 ↗
31. Sun, J., Dong, J., and Lv, Q. (2022, January 4–6). Swin transformer and fusion for underwater image enhancement. Proceedings of the International Workshop on Advanced Imaging Technology (IWAIT) 2022, SPIE, Hong Kong, China.
32. Zhang, X., Han, L., Sobeih, T., Lappin, L., Lee, M.A., Howard, A., and Kisdi, A. (2022). The Self-Supervised Spectral–Spatial Vision Transformer Network for Accurate Prediction of Wheat Nitrogen Status from UAV Imagery. Remote Sens., 14.10.3390/rs14061400 ↗
33. Wang, W., Xie, E., Li, X., Fan, D.P., Song, K., Liang, D., Lu, T., Luo, P., and Shao, L. (2021, January 20–25). Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. Proceedings of the IEEE/CVF International Conference on Computer Vision, Nashville, TN, USA.10.1109/ICCV48922.2021.00061 ↗
34. Simonyan, K., and Zisserman, A. (2015, January 7–9). Very deep convolutional networks for large-scale image recognition. Proceedings of the International Conference on Learning Representations, San Diego, CA, USA.
35. Devlin, J., Chang, M.W., Lee, K., and Toutanova, K. (2019, January 2–7). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of the NAACL-HLT (1), Minneapolis, MN, USA.
36. Radford, A., Narasimhan, K., Salimans, T., and Sutskever, I. (2023, February 01). Improving Language Understanding by Generative Pre-Training. Available online: file:///C:/Users/MDPI/Downloads/radford2018improving.pdf.
37. Wu, K., Peng, H., Chen, M., Fu, J., and Chao, H. (2021, January 11–17). Rethinking and improving relative position encoding for vision transformer. Proceedings of the IEEE/CVF International Conference on Computer Vision, Montreal, QC, Canada.10.1109/ICCV48922.2021.00988 ↗
38. Hrformer: High-resolution vision transformer for dense predict
39. Szegedy, C., Liu, W., Jia, Y., Sermanet, P., Reed, S., Anguelov, D., Erhan, D., Vanhoucke, V., and Rabinovich, A. (2015, January 7–12). Going deeper with convolutions. Proceedings of the IEEE Conference on Ccomputer Vision and Pattern Recognition, Boston, MA, USA.10.1109/CVPR.2015.7298594 ↗
40. Huang, G., Liu, Z., Van Der Maaten, L., and Weinberger, K.Q. (2017, January 21–26). Densely connected convolutional networks. Proceedings of the IEEE Conference onComputer Vision and Pattern Recognition, Honolulu, HI, USA.10.1109/CVPR.2017.243 ↗
41. Tan, M., and Le, Q. (2019, January 9–15). Efficientnet: Rethinking model scaling for convolutional neural networks. Proceedings of the International Conference on Machine Learning. PMLR, Long Beach, CA, USA.
42. Yu, F., and Koltun, V. (2016, January 2–4). Multi-scale context aggregation by dilated convolutions. Proceedings of the International Conference on Learning Representations, San Juan, Puerto Rico.
43. Hu, H., Gu, J., Zhang, Z., Dai, J., and Wei, Y. (2018, January 18–23). Relation networks for object detection. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA.10.1109/CVPR.2018.00378 ↗
44. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
45. Hu, H., Zhang, Z., Xie, Z., and Lin, S. (November, January 27). Local relation networks for image recognition. Proceedings of the IEEE/CVF International Conference on Computer Vision, Seoul, Republic of Korea.
46. Bao, H., Dong, L., Wei, F., Wang, W., Yang, N., Liu, X., Wang, Y., Gao, J., Piao, S., and Zhou, M. (2020, January 13–18). Unilmv2: Pseudo-masked language models for unified language model pre-training. Proceedings of the International Conference on Machine Learning, PMLR, Virtual.
47. Ba, J.L., Kiros, J.R., and Hinton, G.E. (2016). Layer normalization. arXiv.
48. Nair, V., and Hinton, G.E. (2010, January 21–24). Rectified linear units improve restricted boltzmann machines. Proceedings of the ICML, Haifa, Israel.
49. Yang, J., Li, C., Zhang, P., Dai, X., Xiao, B., Yuan, L., and Gao, J. (2021, January 6–14). Focal Attention for Long-Range Interactions in Vision Transformers. Proceedings of the Advances in Neural Information Processing Systems, Virtual.
50. Huang, Z., Ben, Y., Luo, G., Cheng, P., Yu, G., and Fu, B. (2021). Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer. arXiv.
51. Twins: Revisiting the design of spatial attention in vision transformers
52. Deng, J., Dong, W., Socher, R., Li, L.J., Li, K., and Fei-Fei, L. (2009, January 20–25). Imagenet: A large-scale hierarchical image database. Proceedings of the 2009 IEEE Conference on Computer Vision and Pattern Recognition, Miami, FL, USA.10.1109/CVPR.2009.5206848 ↗
53. Lin, T.Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., and Zitnick, C.L. (2014, January 6–12). Microsoft coco: Common objects in context. Proceedings of the European Conference on Computer Vision, Zurich, Switzerland.10.1007/978-3-319-10602-1_48 ↗
54. Semantic understanding of scenes through the ade20k dataset10.1007/s11263-018-1140-0 ↗
55. Kingma, D.P., and Ba, J. (2015, January 7–9). Adam: A Method for Stochastic Optimization. Proceedings of the International Conference on Learning Representations, San Diego, CA, USA.
56. Cubuk, E.D., Zoph, B., Shlens, J., and Le, Q.V. (2020, January 14–19). Randaugment: Practical automated data augmentation with a reduced search space. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, Seattle, WA, USA.10.1109/CVPRW50498.2020.00359 ↗
57. Zhang, H., Cisse, M., Dauphin, Y.N., and Lopez-Paz, D. (May, January 30). mixup: Beyond Empirical Risk Minimization. Proceedings of the International Conference on Learning Representations, Vancouver, BC, Canada.
58. Yun, S., Han, D., Oh, S.J., Chun, S., Choe, J., and Yoo, Y. (November, January 27). Cutmix: Regularization strategy to train strong classifiers with localizable features. Proceedings of the IEEE/CVF International Conference on Computer Vision, Seoul, Republic of Korea.
59. Zhong, Z., Zheng, L., Kang, G., Li, S., and Yang, Y. (2020, January 7–12). Random erasing data augmentation. Proceedings of the AAAI Conference on Artificial Intelligence, New York, NY, USA.
60. Huang, G., Sun, Y., Liu, Z., Sedra, D., and Weinberger, K.Q. (2016, January 11–14). Deep networks with stochastic depth. Proceedings of the European Conference on Computer Vision, Amsterdam, The Netherlands.10.1007/978-3-319-46493-0_39 ↗
61. Zhang, P., Dai, X., Yang, J., Xiao, B., Yuan, L., Zhang, L., and Gao, J. (2021, January 11–17). Multi-scale vision longformer: A new vision transformer for high-resolution image encoding. Proceedings of the IEEE/CVF International Conference on Computer Vision, Montreal, BC, Canada.10.1109/ICCV48922.2021.00299 ↗
62. Radosavovic, I., Kosaraju, R.P., Girshick, R., He, K., and Dollár, P. (2020, January 13–19). Designing network design spaces. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA.10.1109/CVPR42600.2020.01044 ↗
63. Yuan, L., Chen, Y., Wang, T., Yu, W., Shi, Y., Jiang, Z.H., Tay, F.E., Feng, J., and Yan, S. (2021, January 11–17). Tokens-to-token vit: Training vision transformers from scratch on imagenet. Proceedings of the IEEE/CVF International Conference on Computer Vision, Montreal, QC, Canada.10.1109/ICCV48922.2021.00060 ↗
64. Transformer in transformer
65. Chen, C.F.R., Fan, Q., and Panda, R. (2021, January 11–17). Crossvit: Cross-attention multi-scale vision transformer for image classification. Proceedings of the IEEE/CVF International Conference on Computer Vision, Montreal, QC, Canada.10.1109/ICCV48922.2021.00041 ↗
66. Chu, X., Tian, Z., Zhang, B., Wang, X., Wei, X., Xia, H., and Shen, C. (2021). Conditional positional encodings for vision transformers. arXiv.
67. Zhang, Z., Zhang, H., Zhao, L., Chen, T., and Pfister, T. (2021). Aggregating nested transformers. arXiv.
68. Lin, H., Cheng, X., Wu, X., and Shen, D. (2022, January 18–22). Cat: Cross attention in vision transformer. Proceedings of the 2022 IEEE International Conference on Multimedia and Expo (ICME), Taipei, Taiwan.10.1109/ICME52920.2022.9859720 ↗
69. Lin, T.Y., Goyal, P., Girshick, R., He, K., and Dollár, P. (2017, January 22–29). Focal loss for dense object detection. Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy.10.1109/ICCV.2017.324 ↗
70. Chen, K., Wang, J., Pang, J., Cao, Y., Xiong, Y., Li, X., Sun, S., Feng, W., Liu, Z., and Xu, J. (2019). MMDetection: Open mmlab detection toolbox and benchmark. arXiv.
71. Chen, C.F., Panda, R., and Fan, Q. (2021, January 4). RegionViT: Regional-to-Local Attention for Vision Transformers. Proceedings of the International Conference on Learning Representations, Vienna, Austria.
72. Xiao, T., Liu, Y., Zhou, B., Jiang, Y., and Sun, J. (2018, January 8–14). Unified perceptual parsing for scene understanding. Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany.10.1007/978-3-030-01228-1_26 ↗
73. Contributors, M. (2023, February 01). MMSegmentation: OpenMMLab Semantic Segmentation Toolbox and Benchmark. Available online: https://github.com/open-mmlab/mmsegmentation.
74. Wu, C., Wu, F., Qi, T., Huang, Y., and Xie, X. (2021). Fastformer: Additive attention can be all you need. arXiv.
75. Woo, S., Park, J., Lee, J.Y., and Kweon, I.S. (2018, January 8–14). Cbam: Convolutional block attention module. Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany.10.1007/978-3-030-01234-2_1 ↗
76. Selvaraju, R.R., Cogswell, M., Das, A., Vedantam, R., Parikh, D., and Batra, D. (2017, January 22–29). Grad-cam: Visual explanations from deep networks via gradient-based localization. Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy.10.1109/ICCV.2017.74 ↗