🚀 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},
}