Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- vision
|
5 |
+
- image-classification
|
6 |
+
datasets:
|
7 |
+
- imagenet-1k
|
8 |
+
---
|
9 |
+
|
10 |
+
# Big Transfer (BiT)
|
11 |
+
|
12 |
+
The BiT model was proposed in [Big Transfer (BiT): General Visual Representation Learning](https://arxiv.org/abs/1912.11370) by Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, Neil Houlsby.
|
13 |
+
BiT is a simple recipe for scaling up pre-training of [ResNet](resnet)-like architectures (specifically, ResNetv2). The method results in significant improvements for transfer learning.
|
14 |
+
|
15 |
+
|
16 |
+
Disclaimer: The team releasing ResNet did not write a model card for this model so this model card has been written by the Hugging Face team.
|
17 |
+
|
18 |
+
## Model description
|
19 |
+
|
20 |
+
The abstract from the paper is the following:
|
21 |
+
|
22 |
+
*Transfer of pre-trained representations improves sample efficiency and simplifies hyperparameter tuning when training deep neural networks for vision. We revisit the paradigm of pre-training on large supervised datasets and fine-tuning the model on a target task. We scale up pre-training, and propose a simple recipe that we call Big Transfer (BiT). By combining a few carefully selected components, and transferring using a simple heuristic, we achieve strong performance on over 20 datasets. BiT performs well across a surprisingly wide range of data regimes -- from 1 example per class to 1M total examples. BiT achieves 87.5% top-1 accuracy on ILSVRC-2012, 99.4% on CIFAR-10, and 76.3% on the 19 task Visual Task Adaptation Benchmark (VTAB). On small datasets, BiT attains 76.8% on ILSVRC-2012 with 10 examples per class, and 97.0% on CIFAR-10 with 10 examples per class. We conduct detailed analysis of the main components that lead to high transfer performance.*
|
23 |
+
|
24 |
+

|
25 |
+
|
26 |
+
## Intended uses & limitations
|
27 |
+
|
28 |
+
You can use the raw model for image classification. See the [model hub](https://huggingface.co/models?search=bit) to look for
|
29 |
+
fine-tuned versions on a task that interests you.
|
30 |
+
|
31 |
+
### How to use
|
32 |
+
|
33 |
+
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
34 |
+
|
35 |
+
```python
|
36 |
+
from transformers import AutoFeatureExtractor, BiTForImageClassification
|
37 |
+
import torch
|
38 |
+
from datasets import load_dataset
|
39 |
+
|
40 |
+
dataset = load_dataset("huggingface/cats-image")
|
41 |
+
image = dataset["test"]["image"][0]
|
42 |
+
|
43 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
|
44 |
+
model = BiTForImageClassification.from_pretrained("google/bit-50")
|
45 |
+
|
46 |
+
inputs = feature_extractor(image, return_tensors="pt")
|
47 |
+
|
48 |
+
with torch.no_grad():
|
49 |
+
logits = model(**inputs).logits
|
50 |
+
|
51 |
+
# model predicts one of the 1000 ImageNet classes
|
52 |
+
predicted_label = logits.argmax(-1).item()
|
53 |
+
print(model.config.id2label[predicted_label])
|
54 |
+
```
|
55 |
+
|
56 |
+
For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/main/en/model_doc/bit).
|
57 |
+
|
58 |
+
### BibTeX entry and citation info
|
59 |
+
|
60 |
+
```bibtex
|
61 |
+
@misc{https://doi.org/10.48550/arxiv.1912.11370,
|
62 |
+
doi = {10.48550/ARXIV.1912.11370},
|
63 |
+
|
64 |
+
url = {https://arxiv.org/abs/1912.11370},
|
65 |
+
|
66 |
+
author = {Kolesnikov, Alexander and Beyer, Lucas and Zhai, Xiaohua and Puigcerver, Joan and Yung, Jessica and Gelly, Sylvain and Houlsby, Neil},
|
67 |
+
|
68 |
+
keywords = {Computer Vision and Pattern Recognition (cs.CV), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
69 |
+
|
70 |
+
title = {Big Transfer (BiT): General Visual Representation Learning},
|
71 |
+
|
72 |
+
publisher = {arXiv},
|
73 |
+
|
74 |
+
year = {2019},
|
75 |
+
|
76 |
+
copyright = {arXiv.org perpetual, non-exclusive license}
|
77 |
+
}
|
78 |
+
|
79 |
+
```
|