Japanese Clip Vit B 32 Roberta Base
日语版本的CLIP模型,能够将日语文本和图像映射到相同的嵌入空间,适用于零样本图像分类、文本-图像检索等任务。
下载量 384
发布时间 : 12/20/2023
模型简介
该模型是一个日语版本的CLIP(对比性语言-图像预训练模型),基于ViT-B/32图像编码器和Roberta Base文本编码器,专为日语优化。
模型特点
日语优化
专门针对日语文本和图像进行优化,在日语任务中表现优于通用多语言CLIP模型。
双模态嵌入
能够将图像和文本映射到同一嵌入空间,实现跨模态检索和比较。
零样本学习
无需特定任务训练即可执行图像分类和检索任务。
模型能力
零样本图像分类
文本-图像检索
图像特征提取
文本特征提取
跨模态相似度计算
使用案例
电子商务
产品图像搜索
通过日语文本描述搜索相关产品图像
提高搜索准确性和用户体验
内容管理
图像自动标注
为图像自动生成日语标签
减少人工标注成本
🚀 recruit-jp/japanese-clip-vit-b-32-roberta-base
本项目是一个面向日语的对比语言 - 图像预训练模型,能够将日语文本和图像映射到同一嵌入空间,可用于零样本图像分类、文本 - 图像检索、图像特征提取等任务。
🚀 快速开始
安装依赖
pip install pillow requests transformers torch torchvision sentencepiece
运行示例代码
import io
import requests
import torch
import torchvision
from PIL import Image
from transformers import AutoTokenizer, AutoModel
model_name = "recruit-jp/japanese-clip-vit-b-32-roberta-base"
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name, trust_remote_code=True).to(device)
def _convert_to_rgb(image):
return image.convert('RGB')
preprocess = torchvision.transforms.Compose([
torchvision.transforms.Resize(size=224, interpolation=torchvision.transforms.InterpolationMode.BICUBIC, max_size=None),
torchvision.transforms.CenterCrop(size=(224, 224)),
_convert_to_rgb,
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(mean=[0.48145466, 0.4578275, 0.40821073], std=[0.26862954, 0.26130258, 0.27577711])
])
def tokenize(tokenizer, texts):
texts = ["[CLS]" + text for text in texts]
encodings = [
# NOTE: the maximum token length that can be fed into this model is 77
tokenizer(text, max_length=77, padding="max_length", truncation=True, add_special_tokens=False)["input_ids"]
for text in texts
]
return torch.LongTensor(encodings)
# Run!
image = Image.open(
io.BytesIO(
requests.get(
'https://images.pexels.com/photos/2253275/pexels-photo-2253275.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260'
).content
)
)
image = preprocess(image).unsqueeze(0).to(device)
text = tokenize(tokenizer, texts=["犬", "猫", "象"]).to(device)
with torch.inference_mode():
image_features = model.get_image_features(image)
image_features /= image_features.norm(dim=-1, keepdim=True)
text_features = model.get_text_features(input_ids=text)
text_features /= text_features.norm(dim=-1, keepdim=True)
probs = image_features @ text_features.T
print("Label probs:", probs.cpu().numpy()[0])
✨ 主要特性
- 语言适配:专为日语设计,使用日语子集的 LAION2B-multi 数据集进行训练。
- 多任务支持:可用于零样本图像分类、文本 - 图像检索、图像特征提取等多种任务。
- 模型架构:图像编码器采用 laion/CLIP-ViT-B-32-laion2B-s34B-b79K,文本编码器采用 rinna/japanese-roberta-base。
📦 安装指南
安装所需的 Python 包:
pip install pillow requests transformers torch torchvision sentencepiece
💻 使用示例
基础用法
import io
import requests
import torch
import torchvision
from PIL import Image
from transformers import AutoTokenizer, AutoModel
model_name = "recruit-jp/japanese-clip-vit-b-32-roberta-base"
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name, trust_remote_code=True).to(device)
def _convert_to_rgb(image):
return image.convert('RGB')
preprocess = torchvision.transforms.Compose([
torchvision.transforms.Resize(size=224, interpolation=torchvision.transforms.InterpolationMode.BICUBIC, max_size=None),
torchvision.transforms.CenterCrop(size=(224, 224)),
_convert_to_rgb,
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(mean=[0.48145466, 0.4578275, 0.40821073], std=[0.26862954, 0.26130258, 0.27577711])
])
def tokenize(tokenizer, texts):
texts = ["[CLS]" + text for text in texts]
encodings = [
# NOTE: the maximum token length that can be fed into this model is 77
tokenizer(text, max_length=77, padding="max_length", truncation=True, add_special_tokens=False)["input_ids"]
for text in texts
]
return torch.LongTensor(encodings)
# Run!
image = Image.open(
io.BytesIO(
requests.get(
'https://images.pexels.com/photos/2253275/pexels-photo-2253275.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260'
).content
)
)
image = preprocess(image).unsqueeze(0).to(device)
text = tokenize(tokenizer, texts=["犬", "猫", "象"]).to(device)
with torch.inference_mode():
image_features = model.get_image_features(image)
image_features /= image_features.norm(dim=-1, keepdim=True)
text_features = model.get_text_features(input_ids=text)
text_features /= text_features.norm(dim=-1, keepdim=True)
probs = image_features @ text_features.T
print("Label probs:", probs.cpu().numpy()[0])
📚 详细文档
模型概述
- 开发者:Recruit Co., Ltd.
- 模型类型:对比语言 - 图像预训练模型
- 支持语言:日语
- 许可证:CC-BY-4.0
更多详细信息请参考技术博客文章。
模型性能
在以下数据集上进行了模型性能评估。由于 ImageNet V2 和 Food101 是英语语境下的数据集,在评估前将类别标签翻译成了日语。
模型 | ImageNet V2 | Food101 | ETLC - 平假名 | ETLC - 片假名 | STAIR Captions 图像到文本 | STAIR Captions 文本到图像 | jafood101 | jaflower30 | jafacility20 | jalandmark10 |
---|---|---|---|---|---|---|---|---|---|---|
laion/CLIP-ViT-H-14-frozen-xlm-roberta-large-laion5B-s13B-b90k | 0.471 | 0.742 | 0.055 | 0.029 | 0.462 | 0.223 | 0.709 | 0.869 | 0.820 | 0.899 |
laion/CLIP-ViT-B-32-xlm-roberta-base-laion5B-s13B-b90k | 0.326 | 0.508 | 0.162 | 0.061 | 0.372 | 0.169 | 0.609 | 0.709 | 0.749 | 0.846 |
rinna/japanese-clip-vit-b-16 | 0.435 | 0.491 | 0.014 | 0.024 | 0.089 | 0.034 | 0.308 | 0.592 | 0.406 | 0.656 |
stabilityai/japanese-stable-clip-vit-l-16 | 0.481 | 0.460 | 0.013 | 0.023 | - | - | 0.413 | 0.689 | 0.677 | 0.752 |
recruit-jp/japanese-clip-vit-b-32-roberta-base | 0.175 | 0.301 | 0.030 | 0.038 | 0.191 | 0.102 | 0.524 | 0.592 | 0.676 | 0.797 |
训练数据集
该模型使用 LAION2B-multi 数据集的日语子集的 1.28 亿个图像 - 文本对进行训练。
免责声明
Recruit Co., Ltd. 对本模型使用的结果不进行准确性、有用性、确定性、合法性的确认,也不提供任何保证和补偿。对于因使用本模型而给用户造成的损害以及与第三方之间的纠纷,Recruit Co., Ltd. 不承担任何责任。
📄 许可证
本模型采用 CC-BY-4.0 许可证。
Clip Vit Large Patch14 336
基于Vision Transformer架构的大规模视觉语言预训练模型,支持图像与文本的跨模态理解
文本生成图像
Transformers

C
openai
5.9M
241
Fashion Clip
MIT
FashionCLIP是基于CLIP开发的视觉语言模型,专门针对时尚领域进行微调,能够生成通用产品表征。
文本生成图像
Transformers 英语

F
patrickjohncyh
3.8M
222
Gemma 3 1b It
Gemma 3是Google推出的轻量级先进开放模型系列,基于与Gemini模型相同的研究和技术构建。该模型是多模态模型,能够处理文本和图像输入并生成文本输出。
文本生成图像
Transformers

G
google
2.1M
347
Blip Vqa Base
Bsd-3-clause
BLIP是一个统一的视觉语言预训练框架,擅长视觉问答任务,通过语言-图像联合训练实现多模态理解与生成能力
文本生成图像
Transformers

B
Salesforce
1.9M
154
CLIP ViT H 14 Laion2b S32b B79k
MIT
基于OpenCLIP框架在LAION-2B英文数据集上训练的视觉-语言模型,支持零样本图像分类和跨模态检索任务
文本生成图像
Safetensors
C
laion
1.8M
368
CLIP ViT B 32 Laion2b S34b B79k
MIT
基于OpenCLIP框架在LAION-2B英语子集上训练的视觉-语言模型,支持零样本图像分类和跨模态检索
文本生成图像
Safetensors
C
laion
1.1M
112
Pickscore V1
PickScore v1 是一个针对文本生成图像的评分函数,可用于预测人类偏好、评估模型性能和图像排序等任务。
文本生成图像
Transformers

P
yuvalkirstain
1.1M
44
Owlv2 Base Patch16 Ensemble
Apache-2.0
OWLv2是一种零样本文本条件目标检测模型,可通过文本查询在图像中定位对象。
文本生成图像
Transformers

O
google
932.80k
99
Llama 3.2 11B Vision Instruct
Llama 3.2 是 Meta 发布的多语言多模态大型语言模型,支持图像文本到文本的转换任务,具备强大的跨模态理解能力。
文本生成图像
Transformers 支持多种语言

L
meta-llama
784.19k
1,424
Owlvit Base Patch32
Apache-2.0
OWL-ViT是一个零样本文本条件目标检测模型,可以通过文本查询搜索图像中的对象,无需特定类别的训练数据。
文本生成图像
Transformers

O
google
764.95k
129
精选推荐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