BiT模型由Alexander Kolesnikov、Lucas Beyer、翟晓华、Joan Puigcerver、Jessica Yung、Sylvain Gelly和Neil Houlsby在论文《大规模迁移学习(BiT):通用视觉表示学习》中提出。该模型通过扩展类ResNet架构(特别是ResNetv2)的预训练方案,实现了迁移学习性能的显著提升。
免责声明:ResNet原团队未提供本模型的模型卡片,本文档由Hugging Face团队撰写。
论文摘要如下:
预训练表示的迁移能够提升深度神经网络在视觉任务中的样本效率并简化超参数调优。我们重新审视了在大规模监督数据集上预训练并在目标任务上微调的范式,通过扩大预训练规模并提出名为Big Transfer(BiT)的简洁方案。通过组合多个精心选择的组件并采用直观的迁移启发式方法,我们在超过20个数据集上实现了强劲性能。BiT在极其广泛的数据规模范围内都表现优异——从每类1个样本到总数100万个样本。在ILSVRC-2012上达到87.5%的top-1准确率,CIFAR-10上达到99.4%,视觉任务自适应基准(VTAB)的19项任务上达到76.3%。在小数据集上,BiT以每类10个样本在ILSVRC-2012获得76.8%的准确率,在CIFAR-10上以每类10个样本获得97.0%的准确率。我们详细分析了实现高性能迁移的关键组件。
该原始模型可用于图像分类任务。请访问模型中心查找您感兴趣任务的微调版本。
以下示例展示如何将COCO 2017数据集中的图像分类为1000个ImageNet类别之一:
from transformers import BitImageProcessor, BitForImageClassification
import torch
from datasets import load_dataset
dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0]
feature_extractor = BitImageProcessor.from_pretrained("google/bit-50")
model = BitForImageClassification.from_pretrained("google/bit-50")
inputs = feature_extractor(image, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
# model predicts one of the 1000 ImageNet classes
predicted_label = logits.argmax(-1).item()
print(model.config.id2label[predicted_label
>>> tabby, tabby cat如需更多代码示例,请参阅官方文档。
@misc{https://doi.org/10.48550/arxiv.1912.11370,
doi = {10.48550/ARXIV.1912.11370},
url = {https://arxiv.org/abs/1912.11370},
author = {Kolesnikov, Alexander and Beyer, Lucas and Zhai, Xiaohua and Puigcerver, Joan and Yung, Jessica and Gelly, Sylvain and Houlsby, Neil},
keywords = {Computer Vision and Pattern Recognition (cs.CV), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Big Transfer (BiT): General Visual Representation Learning},
publisher = {arXiv},
year = {2019},
copyright = {arXiv.org perpetual, non-exclusive license}
}