/ Модель

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

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

deit-base-distilled-patch16-224

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

Дистиллированная модель DeiT-base классифицирует изображения по 1 000 классам ImageNet-1k.

20 021скачиваний за 30 дней36лайковвеса обновлены13 июл 2022

Бенчмарки

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

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

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

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

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

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

facebook/deit-base-distilled-patch16-224 — базовая модель DeiT, разработанная командой DeiT и представленная в работе о data-efficient vision transformers и дистилляции через attention. Веса конвертированы из репозитория timm; модель содержит около 113,2 млн параметров и использует архитектуру Vision Transformer с патчами 16×16 и отдельным токеном дистилляции, обучаемым с помощью CNN-учителя.

Модель предназначена для классификации изображений на 1 000 классов ImageNet-1k. Она принимает RGB-изображения, подготовленные для разрешения 224×224, и выдаёт оценки классов; при обучении использовалась дистилляция. В README приведены результаты ImageNet для семейства DeiT: для DeiT-base указана точность top-1 81,8% и top-5 95,6%.

Модель доступна под лицензией Apache-2.0. Для других задач и наборов классов потребуется подходящая дообученная версия или дополнительная настройка; README отмечает, что более высокое разрешение 384×384 может давать лучшие результаты при fine-tuning.

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

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

Ограничения

Модель ориентирована на 1 000 классов ImageNet-1k и сама по себе не предназначена для произвольных наборов меток или других задач без дополнительной настройки. Для инференса изображения нужно подготовить в соответствии с ожидаемой обработкой DeiT.

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

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

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

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

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

Открыть на Hugging Face

Distilled Data-efficient Image Transformer (base-sized model)

Distilled 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 a distilled Vision Transformer (ViT). It uses a distillation token, besides the class token, to effectively learn from a teacher (CNN) during both pre-training and fine-tuning. The distillation token is learned through backpropagation, by interacting with the class ([CLS]) and patch tokens through the self-attention layers.

Images are presented to the model as a sequence of fixed-size patches (resolution 16x16), which are linearly embedded.

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 distilled ViT model, you can plug it into DeiTModel, DeiTForImageClassification or DeiTForImageClassificationWithTeacher. 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, DeiTForImageClassificationWithTeacher
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-base-distilled-patch16-224')
model = DeiTForImageClassificationWithTeacher.from_pretrained('facebook/deit-base-distilled-patch16-224')

inputs = feature_extractor(images=image, return_tensors="pt")

# forward pass
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

This model was pretrained and fine-tuned with distillation 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…

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

0 моделей