🚀 BLIP-base:针对图像高级动作描述进行微调的图像字幕模型
本项目基于 BLIP 基础模型,在 HL 数据集 上进行微调,专门用于图像动作描述生成。该模型能够为图像生成高质量的动作描述,在图像字幕领域具有重要应用价值。
🚀 快速开始
代码示例
import requests
from PIL import Image
from transformers import BlipProcessor, BlipForConditionalGeneration
processor = BlipProcessor.from_pretrained("michelecafagna26/blip-base-captioning-ft-hl-actions")
model = BlipForConditionalGeneration.from_pretrained("michelecafagna26/blip-base-captioning-ft-hl-actions").to("cuda")
img_url = 'https://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."
✨ 主要特性
- 微调优化:在 HL 数据集上进行了 6 个轮次的训练,针对图像动作生成任务进行了精细调整。
- 高效训练:采用学习率为 5e−5 的 Adam 优化器,并使用半精度(fp16)训练,提高训练效率。
🔧 技术细节
模型微调 🏋️
- 训练轮次:6 个轮次
- 学习率:5e−5
- 优化器:Adam 优化器
- 精度设置:半精度(fp16)
测试集指标 🧾
指标 |
数值 |
Cider |
123.07 |
SacreBLEU |
17.16 |
Rouge-L |
32.16 |
📄 许可证
本模型采用 Apache-2.0 许可证。
📚 详细文档
BibTex 引用信息
@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}
}