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 "mmpretrain>=1.0.0rc7"

Results and models

ADE20K

Method Backbone Crop Size pretrain Batch Size Lr schd Mem (GB) Inf time (fps) Device mIoU mIoU(ms+flip) mIoU* mIoU*(ms+flip) config download
FPN PoolFormer-S12 512x512 ImageNet-1K 32 40000 4.17 23.48 V100 36.68 - 37.07 - config model | log
FPN PoolFormer-S24 512x512 ImageNet-1K 32 40000 5.47 15.74 V100 40.12 - 40.36 - config model | log
FPN PoolFormer-S36 512x512 ImageNet-1K 32 40000 6.77 11.34 V100 41.61 - 41.81 - config model | log
FPN PoolFormer-M36 512x512 ImageNet-1K 32 40000 8.59 8.97 V100 41.95 - 42.35 - config model | log
FPN PoolFormer-M48 512x512 ImageNet-1K 32 40000 10.48 6.69 V100 42.43 - 42.76 - 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.

  • The Test Time Augmentation i.e., "ms+flip" in MMSegmentation v1.x is developing, stay tuned!