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