LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference
Ben Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Hervé Jégou, Matthijs Douze
Code Available — Be the first to reproduce this paper.
ReproduceCode
- github.com/rwightman/pytorch-image-modelsOfficialIn paperpytorch★ 36,538
- github.com/facebookresearch/LeViTOfficialIn paperpytorch★ 624
- github.com/huggingface/transformerspytorch★ 158,292
- github.com/gatech-eic/vitcodpytorch★ 130
- github.com/ttt496/vit-pytorchpytorch★ 12
- github.com/ahmedelmahy/myownvitpytorch★ 2
- github.com/conceptofmind/LeViT-flaxjax★ 1
- github.com/mszpc/levit_cmindspore★ 0
- github.com/mindspore-courses/External-Attention-MindSpore/blob/main/model/backbone/LeViT.pymindspore★ 0
- github.com/JoegameZhou/Levitmindspore★ 0
Abstract
We design a family of image classification architectures that optimize the trade-off between accuracy and efficiency in a high-speed regime. Our work exploits recent findings in attention-based architectures, which are competitive on highly parallel processing hardware. We revisit principles from the extensive literature on convolutional neural networks to apply them to transformers, in particular activation maps with decreasing resolutions. We also introduce the attention bias, a new way to integrate positional information in vision transformers. As a result, we propose LeVIT: a hybrid neural network for fast inference image classification. We consider different measures of efficiency on different hardware platforms, so as to best reflect a wide range of application scenarios. Our extensive experiments empirically validate our technical choices and show they are suitable to most architectures. Overall, LeViT significantly outperforms existing convnets and vision transformers with respect to the speed/accuracy tradeoff. For example, at 80% ImageNet top-1 accuracy, LeViT is 5 times faster than EfficientNet on CPU. We release the code at https://github.com/facebookresearch/LeViT
Tasks
Benchmark Results
| Dataset | Model | Metric | Claimed | Verified | Status |
|---|---|---|---|---|---|
| CIFAR-10 | LeViT-192 | Percentage correct | 98.2 | — | Unverified |
| CIFAR-10 | LeViT-128S | Percentage correct | 97.5 | — | Unverified |
| CIFAR-10 | LeViT-128 | Percentage correct | 97.6 | — | Unverified |
| CIFAR-10 | LeViT-384 | Percentage correct | 98 | — | Unverified |
| CIFAR-10 | LeViT-256 | Percentage correct | 98.1 | — | Unverified |
| Flowers-102 | LeViT-128S | Accuracy | 96.8 | — | Unverified |
| Flowers-102 | LeViT-256 | Accuracy | 97.7 | — | Unverified |
| Flowers-102 | LeViT-192 | Accuracy | 97.8 | — | Unverified |
| Flowers-102 | LeViT-384 | Accuracy | 98.3 | — | Unverified |
| ImageNet | LeViT-128S | Top 1 Accuracy | 75.7 | — | Unverified |
| ImageNet | LeViT-384 | Top 1 Accuracy | 82.5 | — | Unverified |
| ImageNet | LeViT-256 | Top 1 Accuracy | 81.6 | — | Unverified |
| ImageNet | LeViT-192 | Top 1 Accuracy | 80 | — | Unverified |
| ImageNet | LeViT-128 | Top 1 Accuracy | 79.6 | — | Unverified |
| ImageNet ReaL | LeViT-128S | Accuracy | 82.6 | — | Unverified |
| ImageNet ReaL | LeViT-384 | Accuracy | 87.5 | — | Unverified |
| ImageNet ReaL | LeViT-256 | Accuracy | 86.9 | — | Unverified |
| ImageNet ReaL | LeViT-192 | Accuracy | 85.8 | — | Unverified |
| ImageNet ReaL | LeViT-128 | Accuracy | 85.6 | — | Unverified |
| ImageNet V2 | LeViT-384 | Top 1 Accuracy | 71.4 | — | Unverified |
| ImageNet V2 | LeViT-128S | Top 1 Accuracy | 63.9 | — | Unverified |
| ImageNet V2 | LeViT-128 | Top 1 Accuracy | 67.5 | — | Unverified |
| ImageNet V2 | LeViT-192 | Top 1 Accuracy | 68.7 | — | Unverified |
| ImageNet V2 | LeViT-256 | Top 1 Accuracy | 69.9 | — | Unverified |
| iNaturalist 2018 | LeViT-128 | Top-1 Accuracy | 54 | — | Unverified |
| iNaturalist 2018 | LeViT-384 | Top-1 Accuracy | 66.9 | — | Unverified |
| iNaturalist 2018 | LeViT-256 | Top-1 Accuracy | 66.2 | — | Unverified |
| iNaturalist 2018 | LeViT-192 | Top-1 Accuracy | 60.4 | — | Unverified |
| iNaturalist 2018 | LeViT-128S | Top-1 Accuracy | 55.2 | — | Unverified |
| iNaturalist 2019 | LeViT-384 | Top-1 Accuracy | 74.3 | — | Unverified |
| iNaturalist 2019 | LeViT-256 | Top-1 Accuracy | 72.3 | — | Unverified |
| iNaturalist 2019 | LeViT-192 | Top-1 Accuracy | 70.8 | — | Unverified |
| iNaturalist 2019 | LeViT-128 | Top-1 Accuracy | 68.4 | — | Unverified |
| iNaturalist 2019 | LeViT-128S | Top-1 Accuracy | 66.5 | — | Unverified |
| Stanford Cars | LeViT-192 | Accuracy | 89.8 | — | Unverified |
| Stanford Cars | LeViT-256 | Accuracy | 88.2 | — | Unverified |
| Stanford Cars | LeViT-128S | Accuracy | 88.4 | — | Unverified |
| Stanford Cars | LeViT-128 | Accuracy | 88.6 | — | Unverified |
| Stanford Cars | LeViT-384 | Accuracy | 89.3 | — | Unverified |