/ Модель

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

Лицензия
MIT
Опубликована
5 окт 2026

vision2words-decoders

Описание изображенийИзображение → текст3 профессии
0скачиваний за 30 дней1лайквеса обновлены18 окт 2026

Описание модели

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

Vision2Words — учебный набор из трёх моделей, создающих англоязычные подписи к фотографиям с помощью LSTM- и Transformer-декодеров.

Vision2Words decoders — учебная демонстрация трёх моделей для создания подписей к изображениям, обученных Mahdi Sabetkish на Flickr8k. Во всех вариантах используется замороженный ImageNet-предобученный энкодер EfficientNet-B0, который преобразует изображение размером 224×224 в пространственные признаки 7×7. Репозиторий содержит декодер LSTM с Bahdanau-вниманием, четырёхслойный Transformer-декодер и Transformer с дополнением контекста подписями к четырём похожим изображениям из индекса FAISS.

Модель предназначена для создания коротких англоязычных описаний фотографий и демонстрации разных архитектур декодирования, включая retrieval-augmented вариант. Обучение и оценка проводились на Flickr8k; автор приводит метрики на тестовом наборе, но они получены за один запуск и с собственной токенизацией, поэтому напрямую сравнивать их с результатами, использующими официальный COCO-eval PTBTokenizer, нельзя. Модель распространяется по лицензии MIT.

Это портфолио-проект, а не система для промышленного описания изображений. Она может плохо описывать документы, диаграммы и абстрактные изображения; словарь ограничен 2 541 словом, а редкие слова заменяются неизвестным токеном. Для retrieval-декодера полезность зависит от сходства изображения с 6 000 фотографий в индексе; смещение описаний людей не оценивалось.

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

  • создание подписи к бытовой фотографии
  • сравнение LSTM и Transformer для описания изображений
  • демонстрация внимания к пространственным признакам изображения
  • эксперименты с поиском похожих фотографий и их подписями

Ограничения

Обучена только на Flickr8k и может плохо описывать документы, диаграммы, абстрактные и существенно отличающиеся от обучающих фотографии; редкие слова вне словаря из 2 541 слова теряются. Качество retrieval-варианта зависит от релевантности соседей в индексе, а возможные смещения при описании людей не проверялись.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

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

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

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

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

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

Открыть на Hugging Face

Vision2Words decoders

Three image-caption decoders trained on Flickr8k, all reading features from a frozen, ImageNet-pretrained EfficientNet-B0 encoder (never fine-tuned): an LSTM with Bahdanau attention over the encoder's 7x7 spatial feature grid, a Transformer decoder attending over the same grid, and a retrieval-augmented Transformer that also attends over the captions of the most similar training images. Files in this repo: lstm_attention.pt, transformer.pt, transformer_rag.pt, vocab.json, and the retrieval index under retrieval/.

Architecture

  • Encoder: EfficientNet-B0 (torchvision, ImageNet weights), frozen. 224x224 input, ImageNet normalization. Produces a 7x7x1280 spatial grid.
  • Decoder A (lstm_attention.pt): Bahdanau additive attention over the 49 spatial tokens, projected down to a 256-d context vector before the LSTM cell to control parameter count; embed 256, hidden 512.
  • Decoder B (transformer.pt): 4-layer Transformer decoder, d_model 512, 8 heads, sinusoidal positional encoding, causal self-attention plus cross-attention into the same 49 spatial tokens.
  • Decoder C (transformer_rag.pt): Decoder B's architecture, with the captions of the 4 nearest training images (one each) appended to its cross-attention memory after the 49 image tokens. The retrieved tokens share the word embedding, get their own positional and segment embeddings, and pass through one Transformer encoder layer.
  • Retrieval index (retrieval/): an exact cosine-similarity FAISS index (IndexFlatIP on L2-normalised vectors) over the pooled 1280-d features of the 6,000 training images, with their captions. Only the training split is indexed, and an image never retrieves itself during training, so no evaluation image's reference captions can reach the decoder.

Training data

Flickr8k: 8,091 photographs, 5 human-written captions each. Standard 6,000 / 1,000 / 1,000 train/val/test split. Vocabulary: 2,541 words appearing at least 5 times in the training captions; everything else maps to <UNK>.

Metrics (test split, 1,000 images)

DecoderDecodingBLEU-1BLEU-2BLEU-3BLEU-4CIDEr
LSTM + attentiongreedy0.6010.4160.2770.1820.464
LSTM + attentionbeam (k=3)0.6100.4300.2980.2020.525
Transformergreedy0.5880.4030.2700.1810.460
Transformerbeam (k=3)0.5990.4200.2900.1980.502
Transformer + retrievalgreedy0.5860.4060.2730.1810.477
Transformer + retrievalbeam (k=3)0.6000.4210.2920.2000.531

Decoder C evaluated with every test image given another image's neighbours scores CIDEr 0.446 (greedy) and 0.483 (beam), below Decoder B, so its gain comes from retrieved captions that match the image. Each number is from a single training run.

Tokenization for these metrics is our own (lowercase, punctuation stripped), not the official COCO-eval PTBTokenizer, which needs a Java runtime. For comparing these two models against each other that doesn't matter; it does mean these numbers aren't directly comparable to numbers reported against the official tokenizer.

The attention-LSTM edges out the Transformer here, which is a reasonable outcome rather than a surprising one: at Flickr8k's scale (6,000 training images), the Transformer's extra parameters (20M vs 6M) have less chance to pay off than they would on a larger dataset like COCO or Flickr30k.

Intended use

A portfolio / teaching demonstration of three captioning decoders, one of them retrieval-augmented, on a small, well-known dataset -- not a production captioning system. To try them interactively, run the Gradio demo built on these weights:

docker run --rm -p 7860:7860 mahdisabetkish/vision2words-app

and open http://localhost:7860. Source and training code: https://github.com/mahdisabetkish/Vision2Words

Limitations

  • Trained on Flickr8k only: everyday scenes, people, and animals. It will describe other kinds of images (documents, diagrams, abstract art) poorly or not at all.
  • Greedy decoding on the Transformer decoder can fall into a repetition loop (e.g. repeating the same word); beam search (the demo's default) avoids this reliably. This is a known property of greedy decoding with Transformer language models, not specific to this checkpoint.
  • Vocabulary is capped at 2,541 words; anything rarer becomes <UNK>.
  • Decoder C can only borrow from what is in its index: 6,000 Flickr8k photographs. For an image unlike any of them, the retrieved captions are misleading rather than helpful.
  • Not evaluated for bias in how it describes people (age, gender presentation, skin tone, etc.) -- Flickr8k's caption distribution reflects its original annotators and is not demographically audited here.

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

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

GPU в ailist

Универсальный рантайм

Нельзя запустить

В репозитории нет config.json: не понять архитектуру модели.

Ревизия весов
81fb7fc

0 моделей