🚀 ViT - H - 14 - CLIPA - datacomp1B模型卡片
這是一個CLIPA - v2模型,可用於零樣本圖像分類等任務,在圖像和文本的對比學習方面表現出色。
🚀 快速開始
此模型可用於零樣本圖像分類任務,通過結合圖像和文本特徵實現對圖像的分類。以下是使用OpenCLIP庫調用該模型的示例代碼。
✨ 主要特性
- 模型類型:對比圖像 - 文本、零樣本圖像分類。
- 原始代碼庫:https://github.com/UCSC - VLAA/CLIPA
- 訓練數據集:mlfoundations/datacomp_1b
- 相關論文:
- CLIPA - v2: Scaling CLIP Training with 81.1% Zero - shot ImageNet Accuracy within a $10,000 Budget; An Extra $4,000 Unlocks 81.8% Accuracy:https://arxiv.org/abs/2306.15658
- An Inverse Scaling Law for CLIP Training:https://arxiv.org/abs/2305.07017
📦 安裝指南
文檔未提及安裝步驟,暫不提供。
💻 使用示例
基礎用法
import torch
import torch.nn.functional as F
from urllib.request import urlopen
from PIL import Image
from open_clip import create_model_from_pretrained, get_tokenizer
model, preprocess = create_model_from_pretrained('hf - hub:ViT - H - 14 - CLIPA')
tokenizer = get_tokenizer('hf - hub:ViT - H - 14 - CLIPA')
image = Image.open(urlopen(
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets - task - guide.png'
))
image = preprocess(image).unsqueeze(0)
text = tokenizer(["a diagram", "a dog", "a cat", "a beignet"], context_length=model.context_length)
with torch.no_grad(), torch.cuda.amp.autocast():
image_features = model.encode_image(image)
text_features = model.encode_text(text)
image_features = F.normalize(image_features, dim=-1)
text_features = F.normalize(text_features, dim=-1)
text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
print("Label probs:", text_probs)
📚 詳細文檔
模型詳情
屬性 |
詳情 |
模型類型 |
對比圖像 - 文本、零樣本圖像分類 |
原始代碼庫 |
https://github.com/UCSC - VLAA/CLIPA |
訓練數據 |
mlfoundations/datacomp_1b |
相關論文 |
- CLIPA - v2: Scaling CLIP Training with 81.1% Zero - shot ImageNet Accuracy within a $10,000 Budget; An Extra $4,000 Unlocks 81.8% Accuracy:https://arxiv.org/abs/2306.15658 - An Inverse Scaling Law for CLIP Training:https://arxiv.org/abs/2305.07017 |
📄 許可證
本模型使用的許可證為apache - 2.0。
📚 引用
@article{li2023clipav2,
title={CLIPA - v2: Scaling CLIP Training with 81.1% Zero - shot ImageNet Accuracy within a $10,000 Budget; An Extra $4,000 Unlocks 81.8% Accuracy},
author={Xianhang Li and Zeyu Wang and Cihang Xie},
journal={arXiv preprint arXiv:2306.15658},
year={2023},
}
@inproceedings{li2023clipa,
title={An Inverse Scaling Law for CLIP Training},
author={Xianhang Li and Zeyu Wang and Cihang Xie},
booktitle={NeurIPS},
year={2023},
}