Rethinking Vision Transformers for MobileNet Size and Speed

Yanyu Li, Ju Hu, Yang Wen, Georgios Evangelidis, Kamyar Salahi +3 more
12/15/2022
cs.CVcs.AIcs.LG

Official code: snap-research/EfficientFormer (1,116 stars, PyTorch, last commit 2023-08-13). 1 more implementation below.

Abstract

With the success of Vision Transformers (ViTs) in computer vision tasks, recent arts try to optimize the performance and complexity of ViTs to enable efficient deployment on mobile devices. Multiple approaches are proposed to accelerate attention mechanism, improve inefficient designs, or incorporate mobile-friendly lightweight convolutions to form hybrid architectures. However, ViT and its variants still have higher latency or considerably more parameters than lightweight CNNs, even true for the years-old MobileNet. In practice, latency and size are both crucial for efficient deployment on resource-constraint hardware. In this work, we investigate a central question, can transformer models run as fast as MobileNet and maintain a similar size? We revisit the design choices of ViTs and propose a novel supernet with low latency and high parameter efficiency. We further introduce a novel fine-grained joint search strategy for transformer models that can find efficient architectures by optimizing latency and number of parameters simultaneously. The proposed models, EfficientFormerV2, achieve 3.5% higher top-1 accuracy than MobileNetV2 on ImageNet-1K with similar latency and parameters. This work demonstrate that properly designed and optimized vision transformers can achieve high performance even with MobileNet-level size and speed.

View on arXivView PDF

Code Implementations(2)

PyTorch

EfficientFormerV2 [ICCV 2023] & EfficientFormer [NeurIPs 2022]

1,11695Shell, PythonJun 2, 20223 years agoNOASSERTION
deep-learningdetectionefficient-inferenceefficient-neural-networksimagenet+5 more
PyTorchApache-2.0

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more

36,9405,171MDX, ShellFeb 2, 20195 months agoApache-2.0
augmixconvnextdistributed-trainingefficientnetimage-classification+15 more

Similar Papers

Cite this paper

@article{li2022rethinking,
  title  = {Rethinking Vision Transformers for MobileNet Size and Speed},
  author = {Yanyu Li and Ju Hu and Yang Wen and Georgios Evangelidis and Kamyar Salahi and Yanzhi Wang and Sergey Tulyakov and Jian Ren},
  year   = {2022},
  eprint = {2212.08059},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2212.08059}
}

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/2212.08059.svg)](https://codeofpaper.com/paper/2212.08059)

Discussion