Home

Awesome

DaViT: Dual Attention Vision Transformer (ECCV 2022)

PWC

This repo contains the official detection and segmentation implementation of paper "DaViT: Dual Attention Vision Transformer (ECCV 2022)", by Mingyu Ding, Bin Xiao, Noel Codella, Ping Luo, Jingdong Wang, and Lu Yuan. See Introduction.md for an introduction.

The large models for image classification will be released in https://github.com/microsoft/DaViT.

Introduction

teaser

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". (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.

architecture

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.

acc

Getting Started

Python3, PyTorch>=1.8.0, torchvision>=0.7.0 are required for the current codebase.

# An example on CUDA 10.2
pip install torch===1.9.0+cu102 torchvision===0.10.0+cu102 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install thop pyyaml fvcore pillow==8.3.2

Image Classification

Object Detection and Instance Segmentation

Semantic Segmentation

Benchmarking

Image Classification on ImageNet-1K

ModelPretrainResolutionacc@1acc@5#paramsFLOPsCheckpointLog
DaViT-TIN-1K22482.896.228.3M4.5Gdownloadlog
DaViT-SIN-1K22484.296.949.7M8.8Gdownloadlog
DaViT-BIN-1K22484.696.987.9M15.5Gdownloadlog

Object Detection and Instance Segmentation on COCO

Mask R-CNN

BackbonePretrainLr Schd#paramsFLOPsbox mAPmask mAPCheckpointLog
DaViT-TImageNet-1K1x47.8M263G45.041.1downloadlog
DaViT-TImageNet-1K3x47.8M263G47.442.9downloadlog
DaViT-SImageNet-1K1x69.2M351G47.742.9downloadlog
DaViT-SImageNet-1K3x69.2M351G49.544.3downloadlog
DaViT-BImageNet-1K1x107.3M491G48.243.3downloadlog
DaViT-BImageNet-1K3x107.3M491G49.944.6downloadlog

RetinaNet

BackbonePretrainLr Schd#paramsFLOPsbox mAPCheckpointLog
DaViT-TImageNet-1K1x38.5M244G44.0downloadlog
DaViT-TImageNet-1K3x38.5M244G46.5downloadlog
DaViT-SImageNet-1K1x59.9M332G46.0downloadlog
DaViT-SImageNet-1K3x59.9M332G48.2downloadlog
DaViT-BImageNet-1K1x98.5M471G46.7downloadlog
DaViT-BImageNet-1K3x98.5M471G48.7downloadlog

Semantic Segmentation on ADE20K

BackbonePretrainMethodResolutionIters#paramsFLOPsmIoUCheckpointLog
DaViT-TImageNet-1KUPerNet512x512160k60M940G46.3downloadlog
DaViT-SImageNet-1KUPerNet512x512160k81M1030G48.8downloadlog
DaViT-BImageNet-1KUPerNet512x512160k121M1175G49.4downloadlog

Citation

If you find this repo useful to your project, please consider citing it with the following bib:

@inproceedings{ding2022davit,
  title={Davit: Dual attention vision transformers},
  author={Ding, Mingyu and Xiao, Bin and Codella, Noel and Luo, Ping and Wang, Jingdong and Yuan, Lu},
  booktitle={Computer Vision--ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23--27, 2022, Proceedings, Part XXIV},
  pages={74--92},
  year={2022},
  organization={Springer}
}

Acknowledgement

Our codebase is built based on timm, MMDetection, MMSegmentation. We thank the authors for the nicely organized code!