Skip to content

Latest commit

 

History

History
 
 

poolformer

PoolFormer

MetaFormer is Actually What You Need for Vision

Introduction

Official Repo

Code Snippet

Abstract

Transformers have shown great potential in computer vision tasks. A common belief is their attention-based token mixer module contributes most to their competence. However, recent works show the attention-based module in transformers can be replaced by spatial MLPs and the resulted models still perform quite well. Based on this observation, we hypothesize that the general architecture of the transformers, instead of the specific token mixer module, is more essential to the model's performance. To verify this, we deliberately replace the attention module in transformers with an embarrassingly simple spatial pooling operator to conduct only the most basic token mixing. Surprisingly, we observe that the derived model, termed as PoolFormer, achieves competitive performance on multiple computer vision tasks. For example, on ImageNet-1K, PoolFormer achieves 82.1% top-1 accuracy, surpassing well-tuned vision transformer/MLP-like baselines DeiT-B/ResMLP-B24 by 0.3%/1.1% accuracy with 35%/52% fewer parameters and 48%/60% fewer MACs. The effectiveness of PoolFormer verifies our hypothesis and urges us to initiate the concept of "MetaFormer", a general architecture abstracted from transformers without specifying the token mixer. Based on the extensive experiments, we argue that MetaFormer is the key player in achieving superior results for recent transformer and MLP-like models on vision tasks. This work calls for more future research dedicated to improving MetaFormer instead of focusing on the token mixer modules. Additionally, our proposed PoolFormer could serve as a starting baseline for future MetaFormer architecture design. Code is available at this https URL

Citation

@inproceedings{yu2022metaformer,
  title={Metaformer is actually what you need for vision},
  author={Yu, Weihao and Luo, Mi and Zhou, Pan and Si, Chenyang and Zhou, Yichen and Wang, Xinchao and Feng, Jiashi and Yan, Shuicheng},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={10819--10829},
  year={2022}
}

Usage

  • PoolFormer backbone needs to install MMClassification first, which has abundant backbones for downstream tasks.
pip install mmcls>=0.23.0

Results and models

ADE20K

Method Backbone Crop Size pretrain Batch Size Lr schd Mem (GB) Inf time (fps) mIoU mIoU(ms+flip) mIoU* mIoU*(ms+flip) config download
FPN PoolFormer-S12 512x512 ImageNet-1K 32 40000 4.17 23.48 36.68 38.22 37.07 38.44 config model | log
FPN PoolFormer-S24 512x512 ImageNet-1K 32 40000 5.47 15.74 40.12 40.97 40.36 41.08 config model | log
FPN PoolFormer-S36 512x512 ImageNet-1K 32 40000 6.77 11.34 41.61 42.61 41.81 42.72 config model | log
FPN PoolFormer-M36 512x512 ImageNet-1K 32 40000 8.59 8.97 41.95 43.24 42.35 43.34 config model | log
FPN PoolFormer-M48 512x512 ImageNet-1K 32 40000 10.48 6.69 42.43 43.60 42.76 43.57 config model | log

Note:

  • We replace AlignedResize in original PoolFormer implementation to Resize + ResizeToMultiple.

  • mIoU with * is collected when Resize + ResizeToMultiple is adopted in test_pipeline, so do mIoU in logs.