Edit model card

Model Card: VinVL for Captioning πŸ–ΌοΈ

Microsoft's VinVL base fine-tuned on HL dataset for rationale description generation downstream task.

Model fine-tuning πŸ‹οΈβ€

The model has been finetuned for 10 epochs on the rationale captions of the HL dataset (available on πŸ€— HUB: michelecafagna26/hl)

Test set metrics πŸ“ˆ

Obtained with beam size 5 and max length 20

Bleu-1 Bleu-2 Bleu-3 Bleu-4 METEOR ROUGE-L CIDEr SPICE
0.55 0.38 0.23 0.15 0.17 0.44 0.44 0.10

Usage and Installation:

More info about how to install and use this model can be found here: michelecafagna26/VinVL

Feature extraction ⛏️

This model has a separate Visualbackbone used to extract features. More info about:

Quick start: πŸš€

from transformers.pytorch_transformers import BertConfig, BertTokenizer
from oscar.modeling.modeling_bert import BertForImageCaptioning
from oscar.wrappers import OscarTensorizer

ckpt = "path/to/the/checkpoint"
device = "cuda" if torch.cuda.is_available() else "cpu"

# original code
config = BertConfig.from_pretrained(ckpt)
tokenizer = BertTokenizer.from_pretrained(ckpt)
model = BertForImageCaptioning.from_pretrained(ckpt, config=config).to(device)

# This takes care of the preprocessing
tensorizer = OscarTensorizer(tokenizer=tokenizer, device=device)

# numpy-arrays with shape (1, num_boxes, feat_size)
# feat_size is 2054 by default in VinVL
visual_features = torch.from_numpy(feat_obj).to(device).unsqueeze(0)

# labels are usually extracted by the features extractor
labels = [['boat', 'boat', 'boat', 'bottom', 'bush', 'coat', 'deck', 'deck', 'deck', 'dock', 'hair', 'jacket']]

inputs = tensorizer.encode(visual_features, labels=labels)
outputs = model(**inputs)

pred = tensorizer.decode(outputs)

# the output looks like this:
# pred = {0: [{'caption': 'he is on leisure', 'conf': 0.7070220112800598]}

Citations 🧾

HL Dataset paper:

@inproceedings{cafagna2023hl,
  title={{HL} {D}ataset: {V}isually-grounded {D}escription of {S}cenes, {A}ctions and
{R}ationales},
  author={Cafagna, Michele and van Deemter, Kees and Gatt, Albert},
  booktitle={Proceedings of the 16th International Natural Language Generation Conference (INLG'23)},
address = {Prague, Czech Republic},
  year={2023}
}

Please consider citing the original project and the VinVL paper


@misc{han2021image,
      title={Image Scene Graph Generation (SGG) Benchmark}, 
      author={Xiaotian Han and Jianwei Yang and Houdong Hu and Lei Zhang and Jianfeng Gao and Pengchuan Zhang},
      year={2021},
      eprint={2107.12604},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

@inproceedings{zhang2021vinvl,
  title={Vinvl: Revisiting visual representations in vision-language models},
  author={Zhang, Pengchuan and Li, Xiujun and Hu, Xiaowei and Yang, Jianwei and Zhang, Lei and Wang, Lijuan and Choi, Yejin and Gao, Jianfeng},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={5579--5588},
  year={2021}
}
Downloads last month
8
Inference Examples
Inference API (serverless) does not yet support pytorch models for this pipeline type.

Dataset used to train michelecafagna26/vinvl-base-finetuned-hl-rationales-image-captioning