timm documentation

BEiT

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

BEiT

类别: ViT · 代码: timm/models/beit.py · 架构: 7 · 预训练权重: 13(其中 9 个包含 ImageNet-1k 结果)

BEiT 和 BEiT-v2 视觉 Transformer,通过掩码图像建模进行预训练。BEiT 预测被掩码补丁的离散视觉 token,BEiT-v2 使用向量量化视觉分词器作为目标。此处的权重为微调后的分类权重。

论文

用法

请参阅快速入门了解如何加载预训练权重、进行图像预处理和微调,以及查阅特征提取了解如何将模型用作骨干网络。

>>> import timm
>>> model = timm.create_model('beit_base_patch16_224.in22k_ft_in22k_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

模型 API 支持

功能Beit
features_only=True 特征图✓(strides 16, 16, 16)
forward_intermediates()✓
prune_intermediate_layers()✓
任意输入尺寸,无需更改✗
set_input_size()✓
dynamic_img_size=True✗
set_grad_checkpointing()✓
逐层学习率衰减(group_matcher())✓
reset_classifier()✓

✓ 支持,✓ (square) 仅支持方形尺寸,✗ 不支持,– 无需支持(模型本身已接受任意输入尺寸)。通过在每个功能上运行随机初始化的模型(Beit 使用 beit_base_patch16_224,尺寸为 224)进行验证,预期同一类的其他架构表现相同。有关详细信息,请参阅 Model API 页面。

架构

架构参数(M)GMAC输入大小预训练权重
beit_base_patch16_22486.5317.582242
beit_base_patch16_38486.7455.543841
beit_large_patch16_224304.4361.602242
beit_large_patch16_384305.00191.213841
beit_large_patch16_512305.67362.245121
beitv2_base_patch16_22486.5317.582243
beitv2_large_patch16_224304.4361.602243

GMACs 和参数量对应于每种架构的默认输入大小和分类器,数据来自基准测试结果。

预训练权重

Top-1 是 results-imagenet.csv 中在所列评估规模下的 ImageNet-1k 验证准确率,- 表示该权重没有 ImageNet-1k 结果(例如预训练权重或图文权重)。Classes 是预训练分类器的大小,对于没有分类器的权重则为 none。

权重输入大小Top-1(%)评估大小类许可证Hub
beit_base_patch16_224.in22k_ft_in22k224--21841apache-2.0timm
beit_base_patch16_224.in22k_ft_in22k_in1k22485.2382241000apache-2.0timm
beit_base_patch16_384.in22k_ft_in22k_in1k38486.8143841000apache-2.0timm
beit_large_patch16_224.in22k_ft_in22k224--21841apache-2.0timm
beit_large_patch16_224.in22k_ft_in22k_in1k22487.4862241000apache-2.0timm
beit_large_patch16_384.in22k_ft_in22k_in1k38488.3803841000apache-2.0timm
beit_large_patch16_512.in22k_ft_in22k_in1k51288.5765121000apache-2.0timm
beitv2_base_patch16_224.in1k_ft_in1k22485.5962241000apache-2.0timm
beitv2_base_patch16_224.in1k_ft_in22k224--21841apache-2.0timm
beitv2_base_patch16_224.in1k_ft_in22k_in1k22486.4942241000apache-2.0timm
beitv2_large_patch16_224.in1k_ft_in1k22487.4142241000apache-2.0timm
beitv2_large_patch16_224.in1k_ft_in22k224--21841apache-2.0timm
beitv2_large_patch16_224.in1k_ft_in22k_in1k22488.4062241000apache-2.0timm

引用

@inproceedings{beit,
title={{BEiT}: {BERT} Pre-Training of Image Transformers},
author={Hangbo Bao and Li Dong and Songhao Piao and Furu Wei},
booktitle={International Conference on Learning Representations},
year={2022},
url={https://openreview.net/forum?id=p-BhZSz59o4}
}

@article{beitv2,
title={{BEiT v2}: Masked Image Modeling with Vector-Quantized Visual Tokenizers},
author={Zhiliang Peng and Li Dong and Hangbo Bao and Qixiang Ye and Furu Wei},
year={2022},
eprint={2208.06366},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Update on GitHub