Commit
·
e78573e
1
Parent(s):
36746ff
Upload 7 files
Browse files- .gitattributes +0 -1
- README.md +115 -0
- added_tokens.json +1 -0
- config.json +37 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- vocab.txt +0 -0
.gitattributes
CHANGED
|
@@ -25,7 +25,6 @@
|
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 28 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,118 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- michelecafagna26/hl
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
metrics:
|
| 8 |
+
- sacrebleu
|
| 9 |
+
- rouge
|
| 10 |
+
- meteor
|
| 11 |
+
- spice
|
| 12 |
+
- cider
|
| 13 |
+
|
| 14 |
+
library_name: pytorch
|
| 15 |
+
tags:
|
| 16 |
+
- pytorch
|
| 17 |
+
- image-to-text
|
| 18 |
---
|
| 19 |
+
|
| 20 |
+
# Model Card: VinVL for Captioning 🖼️
|
| 21 |
+
|
| 22 |
+
[Microsoft's VinVL](https://github.com/microsoft/Oscar) base fine-tuned on [HL dataset](https://arxiv.org/abs/2302.12189?context=cs.CL) for **rationale description generation** downstream task.
|
| 23 |
+
|
| 24 |
+
# Model fine-tuning 🏋️
|
| 25 |
+
|
| 26 |
+
The model has been finetuned for 10 epochs on the scenes captions of the [HL dataset](https://arxiv.org/abs/2302.12189?context=cs.CL) (available on 🤗 HUB: [michelecafagna26/hl](https://huggingface.co/datasets/michelecafagna26/hl))
|
| 27 |
+
|
| 28 |
+
# Test set metrics 📈
|
| 29 |
+
|
| 30 |
+
Obtained with beam size 5 and max length 20
|
| 31 |
+
|
| 32 |
+
| Bleu-1 | Bleu-2 | Bleu-3 | Bleu-4 | METEOR | ROUGE-L | CIDEr | SPICE |
|
| 33 |
+
|--------|--------|--------|--------|--------|---------|-------|-------|
|
| 34 |
+
| 0.55 | 0.38 | 0.23 | 0.15 | 0.17 | 0.44 | 0.44 | 0.10 |
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
# Usage and Installation:
|
| 38 |
+
|
| 39 |
+
More info about how to install and use this model can be found here: [michelecafagna26/VinVL
|
| 40 |
+
](https://github.com/michelecafagna26/VinVL)
|
| 41 |
+
|
| 42 |
+
# Feature extraction ⛏️
|
| 43 |
+
|
| 44 |
+
This model has a separate Visualbackbone used to extract features.
|
| 45 |
+
More info about:
|
| 46 |
+
- the model: [michelecafagna26/vinvl_vg_x152c4](https://huggingface.co/michelecafagna26/vinvl_vg_x152c4)
|
| 47 |
+
- the usage: [michelecafagna26/vinvl-visualbackbone](https://github.com/michelecafagna26/vinvl-visualbackbone)
|
| 48 |
+
|
| 49 |
+
# Quick start: 🚀
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from transformers.pytorch_transformers import BertConfig, BertTokenizer
|
| 53 |
+
from oscar.modeling.modeling_bert import BertForImageCaptioning
|
| 54 |
+
from oscar.wrappers import OscarTensorizer
|
| 55 |
+
|
| 56 |
+
ckpt = "path/to/the/checkpoint"
|
| 57 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 58 |
+
|
| 59 |
+
# original code
|
| 60 |
+
config = BertConfig.from_pretrained(ckpt)
|
| 61 |
+
tokenizer = BertTokenizer.from_pretrained(ckpt)
|
| 62 |
+
model = BertForImageCaptioning.from_pretrained(ckpt, config=config).to(device)
|
| 63 |
+
|
| 64 |
+
# This takes care of the preprocessing
|
| 65 |
+
tensorizer = OscarTensorizer(tokenizer=tokenizer, device=device)
|
| 66 |
+
|
| 67 |
+
# numpy-arrays with shape (1, num_boxes, feat_size)
|
| 68 |
+
# feat_size is 2054 by default in VinVL
|
| 69 |
+
visual_features = torch.from_numpy(feat_obj).to(device).unsqueeze(0)
|
| 70 |
+
|
| 71 |
+
# labels are usually extracted by the features extractor
|
| 72 |
+
labels = [['boat', 'boat', 'boat', 'bottom', 'bush', 'coat', 'deck', 'deck', 'deck', 'dock', 'hair', 'jacket']]
|
| 73 |
+
|
| 74 |
+
inputs = tensorizer.encode(visual_features, labels=labels)
|
| 75 |
+
outputs = model(**inputs)
|
| 76 |
+
|
| 77 |
+
pred = tensorizer.decode(outputs)
|
| 78 |
+
|
| 79 |
+
# the output looks like this:
|
| 80 |
+
# pred = {0: [{'caption': 'he is on leisure', 'conf': 0.7070220112800598]}
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
# Citations 🧾
|
| 84 |
+
|
| 85 |
+
HL Dataset paper:
|
| 86 |
+
|
| 87 |
+
```BibTeX
|
| 88 |
+
@inproceedings{cafagna2023hl,
|
| 89 |
+
title={{HL} {D}ataset: {V}isually-grounded {D}escription of {S}cenes, {A}ctions and
|
| 90 |
+
{R}ationales},
|
| 91 |
+
author={Cafagna, Michele and van Deemter, Kees and Gatt, Albert},
|
| 92 |
+
booktitle={Proceedings of the 16th International Natural Language Generation Conference (INLG'23)},
|
| 93 |
+
address = {Prague, Czech Republic},
|
| 94 |
+
year={2023}
|
| 95 |
+
}
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
Please consider citing the original project and the VinVL paper
|
| 99 |
+
|
| 100 |
+
```BibTeX
|
| 101 |
+
|
| 102 |
+
@misc{han2021image,
|
| 103 |
+
title={Image Scene Graph Generation (SGG) Benchmark},
|
| 104 |
+
author={Xiaotian Han and Jianwei Yang and Houdong Hu and Lei Zhang and Jianfeng Gao and Pengchuan Zhang},
|
| 105 |
+
year={2021},
|
| 106 |
+
eprint={2107.12604},
|
| 107 |
+
archivePrefix={arXiv},
|
| 108 |
+
primaryClass={cs.CV}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
@inproceedings{zhang2021vinvl,
|
| 112 |
+
title={Vinvl: Revisiting visual representations in vision-language models},
|
| 113 |
+
author={Zhang, Pengchuan and Li, Xiujun and Hu, Xiaowei and Yang, Jianwei and Zhang, Lei and Wang, Lijuan and Choi, Yejin and Gao, Jianfeng},
|
| 114 |
+
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
|
| 115 |
+
pages={5579--5588},
|
| 116 |
+
year={2021}
|
| 117 |
+
}
|
| 118 |
+
```
|
added_tokens.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{}
|
config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"BertForMaskedLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"drop_worst_after": 20000,
|
| 7 |
+
"drop_worst_ratio": 0.2,
|
| 8 |
+
"finetuning_task": "image_captioning",
|
| 9 |
+
"freeze_embedding": true,
|
| 10 |
+
"hidden_act": "gelu",
|
| 11 |
+
"hidden_dropout_prob": 0.1,
|
| 12 |
+
"hidden_size": 768,
|
| 13 |
+
"img_feature_dim": 2054,
|
| 14 |
+
"img_feature_type": "frcnn",
|
| 15 |
+
"img_layer_norm_eps": 1e-12,
|
| 16 |
+
"initializer_range": 0.02,
|
| 17 |
+
"intermediate_size": 3072,
|
| 18 |
+
"is_bert": true,
|
| 19 |
+
"label_smoothing": 0.1,
|
| 20 |
+
"language_model_type": "MLM",
|
| 21 |
+
"layer_norm_eps": 1e-12,
|
| 22 |
+
"loss_type": "sfmx",
|
| 23 |
+
"max_position_embeddings": 512,
|
| 24 |
+
"model_type": "bert",
|
| 25 |
+
"num_attention_heads": 12,
|
| 26 |
+
"num_contrast_classes": 3,
|
| 27 |
+
"num_hidden_layers": 12,
|
| 28 |
+
"num_labels": 2,
|
| 29 |
+
"output_attentions": false,
|
| 30 |
+
"output_hidden_states": false,
|
| 31 |
+
"pad_token_id": 0,
|
| 32 |
+
"tie_weights": true,
|
| 33 |
+
"torchscript": false,
|
| 34 |
+
"type_vocab_size": 2,
|
| 35 |
+
"use_img_layernorm": 0,
|
| 36 |
+
"vocab_size": 30522
|
| 37 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5d647a6608c0058687c3737f8aa98f2232e0374b3375076d4e7ca84103fa992
|
| 3 |
+
size 446817260
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|