/ Модель

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

Параметры
113 млн
Лицензия
MIT
Архитектура
vit · dense
Опубликована
9 июл 2023

dog-breeds-multiclass-image-classification-with-vit

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

Дообученный ViT классифицирует фотографии собак по 120 породам из набора Stanford Dogs.

533скачиваний за 30 дней9лайковвеса обновлены15 июл 2023

Бенчмарки

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

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

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

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

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

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

Модель wesleyacheng/dog-breeds-multiclass-image-classification-with-vit — дообученный Vision Transformer ViT-Base от Google, созданный автором на основе ноутбука Kaggle. Она классифицирует изображения собак по 120 породам из набора Stanford Dogs. Архитектура разбивает изображение на патчи 16×16 и обрабатывает их механизмом self-attention; исходная модель предварительно обучена на ImageNet-21k с разрешением 224×224. Размер модели — 113,2 млн параметров.

Модель предназначена для определения породы собаки на фотографии, если порода входит в обучающий набор. В описанной оценке достигнуты точность top-1 84,0% и macro F1 83,0%; top-3 точность составила 97,1%, top-5 — 98,7%. Модель не предназначена для классификации других животных или пород, отсутствующих среди 120 классов. Репозиторий распространяется по лицензии MIT.

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

  • определение породы собаки по фотографии
  • сортировка фотографий собак по породам
  • получение трёх наиболее вероятных пород для снимка собаки

Ограничения

Модель рассчитана только на изображения собак и различает породы, представленные в 120 классах Stanford Dogs. В оценке на тестовом наборе точность top-1 составила 84,0%, поэтому предсказание может быть ошибочным.

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

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

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

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

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

Открыть на Hugging Face

Model made by notebook first posted in my Kaggle.

Model Motivation

Recently, someone asked me if you can classify dog images into their respective dog breeds instead just differentiating from cats vs dogs like my last notebook. I say YES!

Due to the complexity of the problem, we will be using the most advanced computer vision architecture released in the 2020 Google paper, the Vision Transformer.

The difference between the Vision Transformer and the traditional Convolutional Neural Network (CNN) is how it treats an image. In Vision Transformers, we take the input as a patch of the original image, say 16 x 16, and feed in into the Transformer as a sequence with positional embeddings and self-attention, while in the Convolutional Neural Network (CNN), we use the same patch of original image as an input, but use convolutions and pooling layers as inductive biases. What this means is that Vision Transformer can use it's judgement to attend any particular patch of the image in a global fashion using it's self-attention mechanism without having us to guide the neural network like a CNN with local centering/cropping/bounding box our images to help its convolutions.

This allows the Vision Transformer architecture to be more flexible and scalable in nature, allowing us to create foundation models in computer vision, similar to the NLP foundational models like BERT and GPT, with pre-training self-supervised/supervised on massive amount of image data that would generalize to different computer vision tasks such as image classification, recognition, segmentation, etc. This cross-pollination helps us move closer towards the goal of Artificial General Intelligence.

One thing about Vision Transformers are it has weaker inductive biases compared to Convolutional Neural Networks that enables it's scalability and flexibility. This feature/bug depending on who you ask will require most well-performing pre-trained models to require more data despite having less parameters compared to it's CNN counterparts.

Luckily, in this model, we will use a Vision Transformer from Google hosted at HuggingFace pre-trained on the ImageNet-21k dataset (14 million images, 21k classes) with 16x16 patches, 224x224 resolution to bypass that data limitation. We will be fine-tuning this model to our "small" dog breeds dataset of around 20 thousand images from the Stanford Dogs dataset imported by Jessica Li into Kaggle to classify dog images into 120 types of dog breeds!

Model Description

This model is finetuned using the Google Vision Transformer (vit-base-patch16-224-in21k) on the Stanford Dogs dataset in Kaggle to classify dog images into 120 types of dog breeds.

Intended Uses & Limitations

You can use this finetuned model to classify images of dogs only and dog breeds that are in the dataset.

How to Use

from transformers import AutoImageProcessor, AutoModelForImageClassification
import PIL
import requests

url = "https://upload.wikimedia.org/wikipedia/commons/5/55/Beagle_600.jpg"
image = PIL.Image.open(requests.get(url, stream=True).raw)

image_processor = AutoImageProcessor.from_pretrained("wesleyacheng/dog-breeds-multiclass-image-classification-with-vit")
model = AutoModelForImageClassification.from_pretrained("wesleyacheng/dog-breeds-multiclass-image-classification-with-vit")

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

outputs = model(**inputs)
logits = outputs.logits

# model predicts one of the 120 Stanford dog breeds classes
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])

Model Training Metrics

EpochTop-1 AccuracyTop-3 AccuracyTop-5 AccuracyMacro F1
179.8%95.1%97.5%77.2%
283.8%96.7%98.2%81.9%
384.8%96.7%98.3%83.4%

Model Evaluation Metrics

Top-1 AccuracyTop-3 AccuracyTop-5 AccuracyMacro F1
84.0%97.1%98.7%83.0%

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

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

GPU в ailist

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

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

Подбираем GPU…

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

0 моделей