MAE¶
摘要¶
This paper shows that masked autoencoders (MAE) are scalable self-supervised learners for computer vision. Our MAE approach is simple: we mask random patches of the input image and reconstruct the missing pixels. It is based on two core designs. First, we develop an asymmetric encoder-decoder architecture, with an encoder that operates only on the visible subset of patches (without mask tokens), along with a lightweight decoder that reconstructs the original image from the latent representation and mask tokens. Second, we find that masking a high proportion of the input image, e.g., 75%, yields a nontrivial and meaningful self-supervisory task. Coupling these two designs enables us to train large models efficiently and effectively: we accelerate training (by 3× or more) and improve accuracy. Our scalable approach allows for learning high-capacity models that generalize well: e.g., a vanilla ViT-Huge model achieves the best accuracy (87.8%) among methods that use only ImageNet-1K data. Transfer performance in downstream tasks outperforms supervised pretraining and shows promising scaling behavior.

使用方式¶
from mmpretrain import inference_model
predict = inference_model('vit-base-p16_mae-300e-pre_8xb128-coslr-100e_in1k', 'demo/bird.JPEG')
print(predict['pred_class'])
print(predict['pred_score'])
import torch
from mmpretrain import get_model
model = get_model('mae_vit-base-p16_8xb512-amp-coslr-300e_in1k', pretrained=True)
inputs = torch.rand(1, 3, 224, 224)
out = model(inputs)
print(type(out))
# To extract features.
feats = model.extract_feat(inputs)
print(type(feats))
Prepare your dataset according to the docs.
训练:
python tools/train.py configs/mae/mae_vit-base-p16_8xb512-amp-coslr-300e_in1k.py
测试:
python tools/test.py configs/mae/benchmarks/vit-base-p16_8xb128-coslr-100e_in1k.py None
Models and results¶
Pretrained models¶
模型 |
Params (M) |
Flops (G) |
配置文件 |
下载 |
---|---|---|---|---|
|
111.91 |
17.58 |
||
|
111.91 |
17.58 |
||
|
111.91 |
17.58 |
||
|
111.91 |
17.58 |
||
|
329.54 |
61.60 |
||
|
329.54 |
61.60 |
||
|
329.54 |
61.60 |
||
|
657.07 |
167.40 |
Image Classification on ImageNet-1k¶
模型 |
预训练 |
Params (M) |
Flops (G) |
Top-1 (%) |
配置文件 |
下载 |
---|---|---|---|---|---|---|
|
86.57 |
17.58 |
83.10 |
N/A |
||
|
86.57 |
17.58 |
83.30 |
N/A |
||
|
86.57 |
17.58 |
83.30 |
N/A |
||
|
86.57 |
17.58 |
83.50 |
|||
|
86.57 |
17.58 |
60.80 |
N/A |
||
|
86.57 |
17.58 |
62.50 |
N/A |
||
|
86.57 |
17.58 |
65.10 |
N/A |
||
|
86.57 |
17.58 |
67.10 |
N/A |
||
|
304.32 |
61.60 |
85.20 |
N/A |
||
|
304.32 |
61.60 |
85.40 |
N/A |
||
|
304.32 |
61.60 |
85.70 |
N/A |
||
|
304.33 |
61.60 |
70.70 |
N/A |
||
|
304.33 |
61.60 |
73.70 |
N/A |
||
|
304.33 |
61.60 |
75.50 |
N/A |
||
|
632.04 |
167.40 |
86.90 |
|||
|
633.03 |
732.13 |
87.30 |
引用¶
@article{He2021MaskedAA,
title={Masked Autoencoders Are Scalable Vision Learners},
author={Kaiming He and Xinlei Chen and Saining Xie and Yanghao Li and
Piotr Doll'ar and Ross B. Girshick},
journal={arXiv},
year={2021}
}