🚀 NLLB - CLIP - SigLIP模型
NLLB - CLIP - SigLIP模型結合了NLLB模型的文本編碼器和SigLIP模型的圖像編碼器,能將模型能力拓展至Flores - 200中的201種語言。該模型在Crossmodal - 3600數據集上達到了最先進水平,尤其在低資源語言上表現出色。你可以在論文中瞭解該模型的更多細節。
🚀 快速開始
本模型集成於OpenCLIP中,你可以像使用其他模型一樣使用它。點擊下方按鈕在Colab中打開示例:
📦 安裝指南
首先,你需要安裝open_clip_torch
庫:
!pip install -U open_clip_torch
💻 使用示例
基礎用法
from open_clip import create_model_from_pretrained, get_tokenizer
from PIL import Image
import requests
import torch
model, transform = create_model_from_pretrained("nllb-clip-large-siglip", "v1", device="cuda")
tokenizer = get_tokenizer("nllb-clip-large-siglip")
class_options = ["бабочка", "butterfly", "kat"]
class_langs = ["rus_Cyrl", "eng_Latn", "afr_Latn"]
text_inputs = []
for i in range(len(class_options)):
tokenizer.set_language(class_langs[i])
text_inputs.append(tokenizer(class_options[i]))
text_inputs = torch.stack(text_inputs).squeeze(1).to("cuda")
image_path = "https://huggingface.co/spaces/jjourney1125/swin2sr/resolve/main/samples/butterfly.jpg"
image = Image.open(requests.get(image_path, stream=True).raw)
image_inputs = transform(image).unsqueeze(0).to("cuda")
with torch.inference_mode():
logits_per_image, logits_per_text = model.get_logits(image_inputs, text_inputs)
print(logits_per_image.softmax(dim=-1))
📚 詳細文檔
模型概述
NLLB - CLIP - SigLIP模型結合了NLLB的文本編碼器和SigLIP的圖像編碼器,將模型能力拓展到201種語言。它在Crossmodal - 3600數據集上表現出色,尤其在低資源語言上。
版本對比
此版本比標準版本性能更好,你可以在這裡和這裡查看結果。
注意:該模型還有更好的版本可供使用!
📄 許可證
本模型採用CC - BY - NC - 4.0許可證。
致謝
感謝ML Collective提供Google Cloud計算資源,用於訓練與OpenCLIP兼容的NLLB - CLIP版本。