michelecafagna26/hl
Viewer β’ Updated β’ 15k β’ 161 β’ 6
How to use michelecafagna26/git-base-captioning-ft-hl-actions with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "image-to-text" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("image-to-text", model="michelecafagna26/git-base-captioning-ft-hl-actions") # Load model directly
from transformers import AutoProcessor, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("michelecafagna26/git-base-captioning-ft-hl-actions")
model = AutoModelForImageTextToText.from_pretrained("michelecafagna26/git-base-captioning-ft-hl-actions")GIT base trained on the HL dataset for action generation of images
| Cider | SacreBLEU | Rouge-L|
|--------|------------|--------|
| 110.63 | 15.21 | 30.45 |
import requests
from PIL import Image
from transformers import AutoProcessor, AutoModelForCausalLM
processor = AutoProcessor.from_pretrained("git-base-captioning-ft-hl-actions")
model = AutoModelForCausalLM.from_pretrained("git-base-captioning-ft-hl-actions").to("cuda")
img_url = 'https://huggingface.co/proxy/datasets-server.huggingface.co/assets/michelecafagna26/hl/--/default/train/0/image/image.jpg'
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
inputs = processor(raw_image, return_tensors="pt").to("cuda")
pixel_values = inputs.pixel_values
generated_ids = model.generate(pixel_values=pixel_values, max_length=50,
do_sample=True,
top_k=120,
top_p=0.9,
early_stopping=True,
num_return_sequences=1)
processor.batch_decode(generated_ids, skip_special_tokens=True)
>>> "she is holding an umbrella."
@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}
}