Downloads · 30 days
0
mostafahagali/image-captioning-vit-transformer
image-captioning-vit-transformer is a image-to-text model from mostafahagali. Use it when you need a caption or text from an image. It is set up for transformers. The card lists the license as mit.
This repository contains a transformer-based image captioning model trained on the MS COCO dataset.
Downloads · 30 days
0
Access
Public
Updated Feb 15, 2026
Repo size
564 MB
Likes
0
Public
Click a slice to open those files.
.pth564 MB · 100%
From the Hugging Face model README
This repository contains a transformer-based image captioning model trained on the MS COCO dataset.
Try the live demo here: https://huggingface.co/spaces/mostafahagali/vit-image-captioning
best_model.pth: Trained model weightsvocab.pkl: Vocabulary mappingimport torch
import pickle
from image_captioning_model import ImageCaptioningModel
with open("vocab.pkl", "rb") as f:
vocab = pickle.load(f)
model = ImageCaptioningModel(
vocab_size=len(vocab),
pad_id=vocab.word2idx["<pad>"],
use_vit=True
)
state_dict = torch.load("best_model.pth", map_location="cpu")
model.load_state_dict(state_dict)
model.eval()
---
license: mit
---
---
Author: Mostafa Hagali
---