BEiT: BERT Pre-Training of Image Transformers

ICLR 2022  ·  Hangbo Bao, Li Dong, Songhao Piao, Furu Wei ·

We introduce a self-supervised vision representation model BEiT, which stands for Bidirectional Encoder representation from Image Transformers. Following BERT developed in the natural language processing area, we propose a masked image modeling task to pretrain vision Transformers. Specifically, each image has two views in our pre-training, i.e, image patches (such as 16x16 pixels), and visual tokens (i.e., discrete tokens). We first "tokenize" the original image into visual tokens. Then we randomly mask some image patches and fed them into the backbone Transformer. The pre-training objective is to recover the original visual tokens based on the corrupted image patches. After pre-training BEiT, we directly fine-tune the model parameters on downstream tasks by appending task layers upon the pretrained encoder. Experimental results on image classification and semantic segmentation show that our model achieves competitive results with previous pre-training methods. For example, base-size BEiT achieves 83.2% top-1 accuracy on ImageNet-1K, significantly outperforming from-scratch DeiT training (81.8%) with the same setup. Moreover, large-size BEiT obtains 86.3% only using ImageNet-1K, even outperforming ViT-L with supervised pre-training on ImageNet-22K (85.2%). The code and pretrained models are available at

PDF Abstract ICLR 2022 PDF ICLR 2022 Abstract
Task Dataset Model Metric Name Metric Value Global Rank Uses Extra
Training Data
Semantic Segmentation ADE20K BEiT-L (ViT+UperNet) Validation mIoU 57.0 # 29
Semantic Segmentation ADE20K val BEiT-L (ViT+UperNet, ImageNet-22k pretrain) mIoU 57.0 # 19
Image Classification ImageNet BEiT-L (ViT; ImageNet 1k pretrain) Top 1 Accuracy 86.3% # 149
Number of params 86M # 787
Image Classification ImageNet BEiT-L (ViT; ImageNet-22K pretrain) Top 1 Accuracy 88.60% # 41
Number of params 331M # 891
Self-Supervised Image Classification ImageNet (finetuned) BEiT-L (ViT) Number of Params 307M # 13
Top 1 Accuracy 86.3% # 14
Self-Supervised Image Classification ImageNet (finetuned) BEiT-B (ViT) Number of Params 86M # 36
Top 1 Accuracy 84.6% # 29
Image Classification OmniBenchmark BeiT Average Top-1 Accuracy 30.1 # 23
Document Layout Analysis PubLayNet val BEiT-B Text 0.934 # 7
Title 0.866 # 8
List 0.924 # 8
Table 0.973 # 8
Figure 0.957 # 8
Overall 0.931 # 9
Document Image Classification RVL-CDIP BEiT-B Accuracy 91.09% # 26
Parameters 87M # 15