🚀 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}
}