đ Data2Vec-Vision (base-sized model, fine-tuned on ImageNet-1k)
A BEiT model pre-trained self-supervised and fine-tuned on ImageNet-1k for image classification.
đ Quick Start
The Data2Vec-Vision model is a BEiT model pre-trained in a self-supervised manner and fine-tuned on ImageNet-1k. It can be used for image classification tasks.
⨠Features
- Self-supervised Pre-training: The model is pre-trained in a self-supervised fashion, enabling it to learn general features from unlabeled data.
- Fine-tuned on ImageNet-1k: Fine-tuned on ImageNet-1k, which contains 1.2 million images and 1000 classes, making it suitable for image classification tasks.
- Same Learning Method across Modalities: Based on the data2vec framework, it uses the same learning method for speech, NLP, and computer vision.
đģ Usage Examples
Basic Usage
from transformers import BeitFeatureExtractor, Data2VecVisionForImageClassification
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
feature_extractor = BeitFeatureExtractor.from_pretrained('facebook/data2vec-vision-base-ft1k')
model = Data2VecVisionForImageClassification.from_pretrained('facebook/data2vec-vision-base-ft1k')
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])
Currently, both the feature extractor and model support PyTorch.
đ Documentation
Pre-Training method

For more information, please take a look at the official paper.
Abstract
While the general idea of self-supervised learning is identical across modalities, the actual algorithms and objectives differ widely because
they were developed with a single modality in
mind. To get us closer to general self-supervised
learning, we present data2vec, a framework that
uses the same learning method for either speech,
NLP or computer vision. The core idea is to predict latent representations of the full input data
based on a masked view of the input in a selfdistillation setup using a standard Transformer architecture. Instead of predicting modality-specific
targets such as words, visual tokens or units of
human speech which are local in nature, data2vec
predicts contextualized latent representations that
contain information from the entire input. Experiments on the major benchmarks of speech
recognition, image classification, and natural language understanding demonstrate a new state of
the art or competitive performance to predominant approaches.
Intended uses & limitations
You can use the raw model for image classification. See the model hub to look for
fine-tuned versions on a task that interests you.
Training data
The BEiT model was pretrained and fine-tuned on ImageNet-1k, a dataset consisting of 1.2 million images and 1k classes.
Training procedure
Preprocessing
The exact details of preprocessing of images during training/validation can be found here.
Images are resized/rescaled to the same resolution (224x224) and normalized across the RGB channels with mean (0.5, 0.5, 0.5) and standard deviation (0.5, 0.5, 0.5).
Pretraining
For all pre-training related hyperparameters, we refer to the original paper and the original codebase
Evaluation results
For evaluation results on several image classification benchmarks, we refer to tables 1 of the original paper. Note that for fine-tuning, the best results are obtained with a higher resolution. Of course, increasing the model size will result in better performance.
We evaluated the model on ImageNet1K
and got top-1 accuracy = 83.97 while in the original paper it was reported top-1 accuracy = 84.2.
If you want to reproduce our evaluation process you can use This Colab Notebook
BibTeX entry and citation info
@misc{https://doi.org/10.48550/arxiv.2202.03555,
doi = {10.48550/ARXIV.2202.03555},
url = {https://arxiv.org/abs/2202.03555},
author = {Baevski, Alexei and Hsu, Wei-Ning and Xu, Qiantong and Babu, Arun and Gu, Jiatao and Auli, Michael},
keywords = {Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {data2vec: A General Framework for Self-supervised Learning in Speech, Vision and Language},
publisher = {arXiv},
year = {2022},
copyright = {arXiv.org perpetual, non-exclusive license}
}
đ License
This model is released under the Apache-2.0 license.
Property |
Details |
Model Type |
Data2Vec-Vision (base-sized model, fine-tuned on ImageNet-1k) |
Training Data |
ImageNet-1k (1.2 million images, 1000 classes) |
Tags |
image-classification, vision |