HyperAIHyperAI

Command Palette

Search for a command to run...

3 months ago

CvT: Introducing Convolutions to Vision Transformers

Haiping Wu Bin Xiao Noel Codella Mengchen Liu Xiyang Dai Lu Yuan Lei Zhang

CvT: Introducing Convolutions to Vision Transformers

Abstract

We present in this paper a new architecture, named Convolutional vision Transformer (CvT), that improves Vision Transformer (ViT) in performance and efficiency by introducing convolutions into ViT to yield the best of both designs. This is accomplished through two primary modifications: a hierarchy of Transformers containing a new convolutional token embedding, and a convolutional Transformer block leveraging a convolutional projection. These changes introduce desirable properties of convolutional neural networks (CNNs) to the ViT architecture (\ie shift, scale, and distortion invariance) while maintaining the merits of Transformers (\ie dynamic attention, global context, and better generalization). We validate CvT by conducting extensive experiments, showing that this approach achieves state-of-the-art performance over other Vision Transformers and ResNets on ImageNet-1k, with fewer parameters and lower FLOPs. In addition, performance gains are maintained when pretrained on larger datasets (\eg ImageNet-22k) and fine-tuned to downstream tasks. Pre-trained on ImageNet-22k, our CvT-W24 obtains a top-1 accuracy of 87.7\% on the ImageNet-1k val set. Finally, our results show that the positional encoding, a crucial component in existing Vision Transformers, can be safely removed in our model, simplifying the design for higher resolution vision tasks. Code will be released at \url{https://github.com/leoxiaobin/CvT}.

Code Repositories

leoxiaobin/CvT
pytorch
Mentioned in GitHub
conceptofmind/CvT-flax
jax
Mentioned in GitHub
ttt496/vit-pytorch
pytorch
Mentioned in GitHub
BR-IDL/PaddleViT
paddle
Mentioned in GitHub
microsoft/CvT
Official
pytorch
Mentioned in GitHub
EMalagoli92/CvT-TensorFlow
tf
Mentioned in GitHub
huggingface/transformers
pytorch
Mentioned in GitHub
SforAiDl/vformer
pytorch
Mentioned in GitHub
ahmedelmahy/myownvit
pytorch
Mentioned in GitHub

Benchmarks

BenchmarkMethodologyMetrics
image-classification-on-cifar-10CvT-W24
Percentage correct: 99.39
image-classification-on-cifar-100CvT-W24
Percentage correct: 94.09
image-classification-on-flowers-102CvT-W24
Accuracy: 99.72
image-classification-on-imagenetCvT-13 (384 res)
GFLOPs: 16.3
Number of params: 20M
Top 1 Accuracy: 83%
image-classification-on-imagenetCvT-21 (384 res, ImageNet-22k pretrain)
GFLOPs: 25
Number of params: 32M
Top 1 Accuracy: 84.9%
image-classification-on-imagenetCvT-13
GFLOPs: 4.5
Top 1 Accuracy: 81.6%
image-classification-on-imagenetCvT-13-NAS
GFLOPs: 4.1
Number of params: 18M
Top 1 Accuracy: 82.2%
image-classification-on-imagenetCvT-W24 (384 res, ImageNet-22k pretrain)
Top 1 Accuracy: 87.7%
image-classification-on-imagenetCvT-21 (384 res)
GFLOPs: 24.9
Top 1 Accuracy: 83.3%
image-classification-on-imagenetCvT-21
GFLOPs: 7.1
Top 1 Accuracy: 82.5%
image-classification-on-imagenet-realCvT-W24 (384 res, ImageNet-22k pretrain)
Accuracy: 90.6%
Number of params: 277M
Top 1 Accuracy: 87.7%
image-classification-on-oxford-iiit-pets-1CvT-W24
Accuracy: 94.73

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing
Get Started

Hyper Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp
CvT: Introducing Convolutions to Vision Transformers | Papers | HyperAI