🚀 microsoft/Florence-2-large在Ejafa/ye-pop數據集上微調並使用CogVLM2添加字幕
本倉庫包含 microsoft/Florence-2-large
模型的微調版本。該模型在 Ejafa/ye-pop
數據集的40,000張圖像子集上進行了微調,其字幕使用 THUDM/cogvlm2-llama3-chat-19B
生成。
🚀 快速開始
要使用此模型,你可以直接從Hugging Face模型中心加載它:
from transformers import AutoModelForCausalLM, AutoProcessor, AutoConfig
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AutoModelForCausalLM.from_pretrained("thwri/CogFlorence-2.2-Large", trust_remote_code=True).to(device).eval()
processor = AutoProcessor.from_pretrained("thwri/CogFlorence-2.2-Large", trust_remote_code=True)
def run_example(task_prompt, image):
prompt = task_prompt
if image.mode != "RGB":
image = image.convert("RGB")
inputs = processor(text=prompt, images=image, return_tensors="pt").to(device)
generated_ids = model.generate(
input_ids=inputs["input_ids"],
pixel_values=inputs["pixel_values"],
max_new_tokens=1024,
num_beams=3,
do_sample=True
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
parsed_answer = processor.post_process_generation(generated_text, task=task_prompt, image_size=(image.width, image.height))
return parsed_answer
from PIL import Image
import requests
import copy
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)
result = run_example("<MORE_DETAILED_CAPTION>" , image)
print(result)
✨ 主要特性
- 基於
microsoft/Florence-2-large
模型進行微調,提升了圖像字幕生成能力。
- 使用
THUDM/cogvlm2-llama3-chat-19B
生成字幕,並使用 google/gemma-2-9b
進行後處理,去除模糊表述。
📚 詳細文檔
訓練詳情
- 視覺編碼器:訓練期間視覺編碼器被凍結。
- 批量大小:64
- 梯度累積步數:16
- 學習率:5.12e-05
- 優化器:AdamW
- 調度器:多項式
- 訓練輪數:8.36
數據集
微調過程使用了 Ejafa/ye-pop
數據集的40,000張圖像子集。該數據集包含各種不同主題的圖像,為提高模型的字幕生成能力提供了強大的訓練基礎。
字幕生成
字幕使用 THUDM/cogvlm2-llama3-chat-19B
生成,然後使用 google/gemma-2-9b
進行後處理以去除模糊表述。
📄 許可證
本項目採用MIT許可證。
屬性 |
詳情 |
模型類型 |
基於 microsoft/Florence-2-large 微調的圖像到文本模型 |
訓練數據 |
Ejafa/ye-pop 數據集的40,000張圖像子集 |