/ Модель

Характеристики

Параметры
7,1 млн
Лицензия
Apache 2.0
Архитектура
vit · dense
Опубликована
2 мар 2022

deit-tiny-patch16-224

Классификация изображенийИзображение → label3 профессии

Компактная модель DeiT на базе Vision Transformer для классификации изображений по 1 000 классам ImageNet.

184 тыс.скачиваний за 30 дней17лайковвеса обновлены13 июл 2022

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

facebook/deit-tiny-patch16-224 — компактная модель Data-efficient Image Transformer (DeiT), представленная авторами DeiT и опубликованная на Hugging Face; веса конвертированы из репозитория timm. Это Vision Transformer с примерно 7,1 млн параметров, дообученный для классификации изображений ImageNet-1k на разрешении 224×224 пикселя. Модель разбивает изображение на патчи 16×16 и обрабатывает их трансформерным энкодером.

Модель предназначена для отнесения изображений к одному из 1 000 классов ImageNet, а также может служить визуальным энкодером для последующего обучения классификатора на размеченных данных. Для инференса изображения масштабируются, центрально обрезаются до 224×224 и нормализуются по статистикам ImageNet. В отчёте указаны точности 72,2% top-1 и 91,1% top-5 на ImageNet.

Модель принимает изображения и выдаёт оценки классов. Для тонкой настройки наилучшие результаты могут требовать разрешения 384×384; увеличение размера модели обычно повышает качество. Лицензия репозитория — Apache-2.0.

Сценарии применения

  • классификация изображений ImageNet
  • распознавание объектов на фотографиях
  • извлечение признаков изображений для последующего классификатора
  • тонкая настройка классификатора на размеченном наборе изображений

Ограничения

Модель обучена на 1 000 классах ImageNet-1k, поэтому её классификация ограничена этой таксономией без дополнительной тонкой настройки. Для тонкой настройки README отмечает преимущество разрешения 384×384.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Data-efficient Image Transformer (tiny-sized model)

Data-efficient Image Transformer (DeiT) model pre-trained and fine-tuned on ImageNet-1k (1 million images, 1,000 classes) at resolution 224x224. It was first introduced in the paper Training data-efficient image transformers & distillation through attention by Touvron et al. and first released in this repository. However, the weights were converted from the timm repository by Ross Wightman.

Disclaimer: The team releasing DeiT did not write a model card for this model so this model card has been written by the Hugging Face team.

Model description

This model is actually a more efficiently trained Vision Transformer (ViT).

The Vision Transformer (ViT) is a transformer encoder model (BERT-like) pre-trained and fine-tuned on a large collection of images in a supervised fashion, namely ImageNet-1k, at a resolution of 224x224 pixels.

Images are presented to the model as a sequence of fixed-size patches (resolution 16x16), which are linearly embedded. One also adds a [CLS] token to the beginning of a sequence to use it for classification tasks. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder.

By pre-training the model, it learns an inner representation of images that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled images for instance, you can train a standard classifier by placing a linear layer on top of the pre-trained encoder. One typically places a linear layer on top of the [CLS] token, as the last hidden state of this token can be seen as a representation of an entire image.

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.

How to use

Since this model is a more efficiently trained ViT model, you can plug it into ViTModel or ViTForImageClassification. Note that the model expects the data to be prepared using DeiTFeatureExtractor. Here we use AutoFeatureExtractor, which will automatically use the appropriate feature extractor given the model name.

Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:

from transformers import AutoFeatureExtractor, ViTForImageClassification
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 = AutoFeatureExtractor.from_pretrained('facebook/deit-tiny-patch16-224')
model = ViTForImageClassification.from_pretrained('facebook/deit-tiny-patch16-224')
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
# model predicts one of the 1000 ImageNet classes
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. Tensorflow and JAX/FLAX are coming soon.

Training data

The ViT model was pretrained on ImageNet-1k, a dataset consisting of 1 million images and 1k classes.

Training procedure

Preprocessing

The exact details of preprocessing of images during training/validation can be found here.

At inference time, images are resized/rescaled to the same resolution (256x256), center-cropped at 224x224 and normalized across the RGB channels with the ImageNet mean and standard deviation.

Pretraining

The model was trained on a single 8-GPU node for 3 days. Training resolution is 224. For all hyperparameters (such as batch size and learning rate) we refer to table 9 of the original paper.

Evaluation results

ModelImageNet top-1 accuracyImageNet top-5 accuracy# paramsURL
DeiT-tiny72.291.15Mhttps://huggingface.co/facebook/deit-tiny-patch16-224
DeiT-small79.995.022Mhttps://huggingface.co/facebook/deit-small-patch16-224
DeiT-base81.895.686Mhttps://huggingface.co/facebook/deit-base-patch16-224
DeiT-tiny distilled74.591.96Mhttps://huggingface.co/facebook/deit-tiny-distilled-patch16-224
DeiT-small distilled81.295.422Mhttps://huggingface.co/facebook/deit-small-distilled-patch16-224
DeiT-base distilled83.496.587Mhttps://huggingface.co/facebook/deit-base-distilled-patch16-224
DeiT-base 38482.996.287Mhttps://huggingface.co/facebook/deit-base-patch16-384
DeiT-base distilled 384 (1000 epochs)85.297.288Mhttps://huggingface.co/facebook/deit-base-distilled-patch16-384

Note that for fine-tuning, the best results are obtained with a higher resolution (384x384). Of course, increasing the model size will result in better performance.

BibTeX entry and citation info

@misc{touvron2021training,
      title={Training data-efficient image transformers & distillation through attention}, 
      author={Hugo Touvron and Matthieu Cord and Matthijs Douze and Francisco Massa and Alexandre Sablayrolles and Hervé Jégou},
      year={2021},
      eprint={2012.12877},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
@misc{wu2020visual,
      title={Visual Transformers: Token-based Image Representation and Processing for Computer Vision}, 
      author={Bichen Wu and Chenfeng Xu and Xiaoliang Dai and Alvin Wan and Peizhao Zhang and Zhicheng Yan and Masayoshi Tomizuka and Joseph Gonzalez and Kurt Keutzer and Peter Vajda},
      year={2020},
      eprint={2006.03677},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
@inproceedings{deng2009imagenet,
  title={Imagenet: A large-scale hierarchical image database},
  author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Li, Kai and Fei-Fei, Li},
  booktitle={2009 IEEE conference on computer vision and pattern recognition},
  pages={248--255},
  year={2009},
  organization={Ieee}
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · image-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
ViTForImageClassification
Ревизия весов
b3428f1

0 моделей