🚀 NLLB - CLIP - SigLIP模型
NLLB - CLIP - SigLIP模型结合了文本编码器和图像编码器的优势,将模型能力拓展到201种语言,在低资源语言上表现出色,为跨语言图像分类等任务带来了新的解决方案。
🚀 快速开始
NLLB - CLIP - SigLIP模型结合了来自 [NLLB模型](https://huggingface.co/facebook/nllb - 200 - distilled - 600M) 的文本编码器和来自 [SigLIP](https://huggingface.co/timm/ViT - B - 16 - SigLIP - 384) 模型的图像编码器。这使我们能够将模型能力扩展到Flores - 200的201种语言。NLLB - CLIP在 [Crossmodal - 3600](https://google.github.io/crossmodal - 3600/) 数据集上达到了最先进水平,在低资源语言上表现出色。你可以在 论文 中找到关于该模型的更多详细信息。
此版本比 [标准](https://huggingface.co/visheratin/nllb - clip - base - oc) 版本表现更好。你可以在 这里 和 [这里](https://github.com/gregor - ge/Babel - ImageNet/blob/main/evaluation_scripts/results_analysis.ipynb) 查看结果。
注意:此模型还有一个 [更好的版本](https://huggingface.co/visheratin/nllb - siglip - mrl - base) 可供使用!
📦 安装指南
此模型已集成到OpenCLIP中,你可以像使用其他模型一样使用它。首先,安装所需的库:
!pip install -U open_clip_torch
💻 使用示例
基础用法
你可以点击下面的按钮在Colab中打开示例代码:
以下是使用该模型的示例代码:
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-base-siglip", "v1", device="cuda")
tokenizer = get_tokenizer("nllb-clip-base-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))
📄 许可证
本模型使用的许可证为 cc - by - nc - 4.0
。
🔗 相关信息表格
属性 |
详情 |
模型类型 |
NLLB - CLIP - SigLIP |
训练数据 |
visheratin/laion - coco - nllb |
新版本 |
visheratin/mexma - siglip2 |
标签 |
clip |
库名称 |
open_clip |
任务类型 |
zero - shot - image - classification |
🙏 致谢
感谢 ML Collective 提供Google Cloud计算资源,用于训练与OpenCLIP兼容的NLLB - CLIP版本。