Cogflorence 2.1 Large
模型概述
該模型主要用於圖像轉文本任務,能夠生成詳細的圖像描述。通過在大規模圖像數據集上的微調,提升了模型的標註能力。
模型特點
高質量圖像標註
能夠生成詳細且準確的圖像描述,適用於各種主題的圖像。
大規模數據集訓練
在Ejafa/ye-pop數據集的4萬張圖像子集上進行了微調,提升了模型的泛化能力。
凍結視覺編碼器
訓練期間視覺編碼器被凍結,保持了原始模型的視覺特徵提取能力。
模型能力
圖像描述生成
多主題圖像分析
高質量文本輸出
使用案例
圖像標註
詳細圖像描述
為圖像生成詳細的文本描述,適用於內容管理和檢索。
生成包含顏色、形狀、背景等細節的描述文本。
內容管理
自動化圖像標籤
為大量圖像自動生成標籤,提高內容管理效率。
快速生成準確的圖像標籤,減少人工標註工作量。
🚀 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.1-Large", trust_remote_code=True).to(device).eval()
processor = AutoProcessor.from_pretrained("thwri/CogFlorence-2.1-Large", trust_remote_code=True)
# Function to run the model on an example
def run_example(task_prompt, image):
prompt = task_prompt
# Ensure the image is in RGB mode
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)
# {'<MORE_DETAILED_CAPTION>': 'A vivid, close-up photograph of a classic car, specifically a Volkswagen Beetle, parked on a cobblestone street. The car is painted in a striking shade of turquoise, with a glossy finish that reflects the surrounding environment. The vehicle's rounded shape is accentuated by its rounded tires and chrome detailing. The background reveals a weathered yellow wall with a rustic wooden door, adding to the rustic charm of the scene. The sky above is clear, suggesting a sunny day. The overall style of the image is candid, capturing a moment in time without any posed or staged elements.'}
✨ 主要特性
- 基於
microsoft/Florence - 2 - large
模型進行微調,提升了圖像字幕生成能力。 - 使用
Ejafa/ye - pop
數據集的40,000張圖像子集進行訓練,數據豐富多樣。 - 字幕使用
THUDM/cogvlm2 - llama3 - chat - 19B
生成,保證了字幕質量。
📦 安裝指南
本README未提及具體安裝步驟,若有需要可參考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.1-Large", trust_remote_code=True).to(device).eval()
processor = AutoProcessor.from_pretrained("thwri/CogFlorence-2.1-Large", trust_remote_code=True)
# Function to run the model on an example
def run_example(task_prompt, image):
prompt = task_prompt
# Ensure the image is in RGB mode
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)
# {'<MORE_DETAILED_CAPTION>': 'A vivid, close-up photograph of a classic car, specifically a Volkswagen Beetle, parked on a cobblestone street. The car is painted in a striking shade of turquoise, with a glossy finish that reflects the surrounding environment. The vehicle's rounded shape is accentuated by its rounded tires and chrome detailing. The background reveals a weathered yellow wall with a rustic wooden door, adding to the rustic charm of the scene. The sky above is clear, suggesting a sunny day. The overall style of the image is candid, capturing a moment in time without any posed or staged elements.'}
高級用法
本README未提及高級用法相關代碼示例,若有更復雜的使用場景需求,可根據模型的API文檔進一步探索。
📚 詳細文檔
訓練詳情
- 視覺編碼器:訓練期間視覺編碼器被凍結。
- 批量大小:64
- 梯度累積步數:16
- 學習率:5.12e - 05
- 優化器:AdamW
- 調度器:多項式
- 訓練輪數:7.37
數據集
微調過程使用了 Ejafa/ye - pop
數據集的40,000張圖像子集。該數據集包含各種不同主題的圖像,為提高模型的字幕生成能力提供了強大的訓練基礎。
字幕生成
字幕使用 THUDM/cogvlm2 - llama3 - chat - 19B
生成。
🔧 技術細節
本模型在訓練時凍結了視覺編碼器,通過特定的批量大小、梯度累積步數、學習率、優化器和調度器的設置,在 Ejafa/ye - pop
數據集的子集上進行了7.37輪的訓練,以提升模型在圖像字幕生成任務上的性能。同時,使用 THUDM/cogvlm2 - llama3 - chat - 19B
生成字幕,保證了字幕的質量和多樣性。
📄 許可證
本項目採用MIT許可證。
屬性 | 詳情 |
---|---|
模型類型 | 基於 microsoft/Florence - 2 - large 的微調模型 |
訓練數據 | Ejafa/ye - pop 數據集的40,000張圖像子集 |
Clip Vit Large Patch14
CLIP是由OpenAI開發的視覺-語言模型,通過對比學習將圖像和文本映射到共享的嵌入空間,支持零樣本圖像分類
圖像生成文本
C
openai
44.7M
1,710
Clip Vit Base Patch32
CLIP是由OpenAI開發的多模態模型,能夠理解圖像和文本之間的關係,支持零樣本圖像分類任務。
圖像生成文本
C
openai
14.0M
666
Siglip So400m Patch14 384
Apache-2.0
SigLIP是基於WebLi數據集預訓練的視覺語言模型,採用改進的sigmoid損失函數,優化了圖像-文本匹配任務。
圖像生成文本
Transformers

S
google
6.1M
526
Clip Vit Base Patch16
CLIP是由OpenAI開發的多模態模型,通過對比學習將圖像和文本映射到共享的嵌入空間,實現零樣本圖像分類能力。
圖像生成文本
C
openai
4.6M
119
Blip Image Captioning Base
Bsd-3-clause
BLIP是一個先進的視覺-語言預訓練模型,擅長圖像描述生成任務,支持條件式和非條件式文本生成。
圖像生成文本
Transformers

B
Salesforce
2.8M
688
Blip Image Captioning Large
Bsd-3-clause
BLIP是一個統一的視覺-語言預訓練框架,擅長圖像描述生成任務,支持條件式和無條件式圖像描述生成。
圖像生成文本
Transformers

B
Salesforce
2.5M
1,312
Openvla 7b
MIT
OpenVLA 7B是一個基於Open X-Embodiment數據集訓練的開源視覺-語言-動作模型,能夠根據語言指令和攝像頭圖像生成機器人動作。
圖像生成文本
Transformers 英語

O
openvla
1.7M
108
Llava V1.5 7b
LLaVA 是一款開源多模態聊天機器人,基於 LLaMA/Vicuna 微調,支持圖文交互。
圖像生成文本
Transformers

L
liuhaotian
1.4M
448
Vit Gpt2 Image Captioning
Apache-2.0
這是一個基於ViT和GPT2架構的圖像描述生成模型,能夠為輸入圖像生成自然語言描述。
圖像生成文本
Transformers

V
nlpconnect
939.88k
887
Blip2 Opt 2.7b
MIT
BLIP-2是一個視覺語言模型,結合了圖像編碼器和大型語言模型,用於圖像到文本的生成任務。
圖像生成文本
Transformers 英語

B
Salesforce
867.78k
359
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98