🚀 rinna/japanese-cloob-vit-b-16
這是由 rinna株式會社 訓練的日語 CLOOB(對比留一法增強) 模型。
你可以查看 japanese-clip 以瞭解其他可用模型。
🚀 快速開始
📦 安裝指南
安裝所需的包:
$ pip install git+https://github.com/rinnakk/japanese-clip.git
💻 使用示例
基礎用法
import io
import requests
from PIL import Image
import torch
import japanese_clip as ja_clip
device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = ja_clip.load("rinna/japanese-cloob-vit-b-16", device=device)
tokenizer = ja_clip.load_tokenizer()
img = 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(img).unsqueeze(0).to(device)
encodings = ja_clip.tokenize(
texts=["犬", "貓", "象"],
max_seq_len=77,
device=device,
tokenizer=tokenizer,
)
with torch.no_grad():
image_features = model.get_image_features(image)
text_features = model.get_text_features(**encodings)
text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
print("Label probs:", text_probs)
🔧 技術細節
模型架構
該模型使用ViT-B/16 Transformer架構作為圖像編碼器,並使用12層的BERT作為文本編碼器。圖像編碼器是從 AugReg vit-base-patch16-224
模型 初始化而來的。
訓練數據
該模型在 CC12M 上進行訓練,其標題已被翻譯成日語。
發佈日期
2022年5月12日
如何引用
@misc{rinna-japanese-cloob-vit-b-16,
title = {rinna/japanese-cloob-vit-b-16},
author = {Shing, Makoto and Zhao, Tianyu and Sawada, Kei},
url = {https://huggingface.co/rinna/japanese-cloob-vit-b-16}
}
@inproceedings{sawada2024release,
title = {Release of Pre-Trained Models for the {J}apanese Language},
author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
month = {5},
year = {2024},
pages = {13898--13905},
url = {https://aclanthology.org/2024.lrec-main.1213},
note = {\url{https://arxiv.org/abs/2404.01657}}
}
📄 許可證
Apache 2.0許可證