标签:
- 剪辑
- RAG
库名称: open_clip
管道标签: 零样本图像分类
许可证: mit
数据集:
- JianLiao/spectrum-icons
语言:
- 英语
基础模型:
- laion/CLIP-ViT-L-14-laion2B-s32B-b82K
CLIP-ViT-L-14-spectrum-icons-23k 模型卡片
目录
- 模型详情
- 用途
- 训练详情
- 评估
- 致谢
- 引用
- 如何开始使用该模型
模型详情
模型描述
这是一个基于预训练模型 laion/CLIP-ViT-L-14-laion2B-s32B-b82K
进行微调的 CLIP ViT-L/14 模型,该预训练模型来自 LAION,通过使用包含 23,000 个 PNG 图像-文本标题对的自定义数据集 (JianLiao/spectrum-icons) 进行优化,以提升文本到图像和图像到文本检索任务的性能。微调过程利用了 OpenCLIP 库和 NVIDIA GPU,使模型能够更好地处理抽象视觉特征并增强 RAG 性能。
基础模型最初是在 LAION-2B 数据集上训练的,利用自然语言监督来对齐视觉和文本嵌入。此次微调旨在进一步适应特定领域,同时保持模型的泛化能力。
用途
直接使用
- 零样本图像分类。
- 文本到图像和图像到图像检索。
- 在抽象视觉上下文中改善文本-图像对齐。
下游使用
- 针对特定领域的图像-文本检索任务进行微调。
- 集成到需要增强语义搜索的应用中。
训练详情
训练数据
该模型在 23,000 个图像-文本标题对上进行了微调。数据集设计包含多样化和抽象的视觉元素,配以详细的文本描述,以增强模型处理抽象查询和检索任务的能力。
训练过程
微调使用 OpenCLIP 库在配备 6 块 NVIDIA RTX-3090 GPU 的机器上进行。关键超参数包括:
- 学习率:
5e-6
,采用余弦衰减。
- 批量大小:每块 GPU
64
,全局有效批量大小为 384
。
- 训练轮数:
40
。
- 精度:混合精度 (
amp_bf16
) 以提高效率。
- 数据增强:
- 颜色抖动:
(0.2, 0.2, 0.1, 0.0)
,概率为 0.7
。
- 灰度概率:
0.2
。
训练过程中采用了梯度检查点、分布式数据并行 (NCCL) 以及定期评估零样本性能。每轮训练后进行验证。
评估
测试数据、因素与指标
测试数据
模型在从 23,000 个图像-文本对中划分出的验证集上进行了评估。计算了图像到文本和文本到图像检索任务的指标。
指标
- 召回率@K:
- 图像到文本和文本到图像检索的 R@1、R@5、R@10。
- 平均排名和中位数排名:
结果
-
图像到文本检索:
- R@1: ~70.0%
- R@5: ~96.0%
- R@10: ~97.8%
- 平均排名: ~2.24
- 中位数排名: ~1.0
-
文本到图像检索:
- R@1: ~70.3%
- R@5: ~96.4%
- R@10: ~98.1%
- 平均排名: ~2.17
- 中位数排名: ~1.0
结果表明视觉和文本嵌入之间具有强大的对齐能力,在两种检索任务上均表现出色。
致谢
- 预训练基础模型由 LAION 开发,并在 LAION-2B 数据集上训练。
引用
BibTeX:
@inproceedings{cherti2023reproducible,
title={Reproducible scaling laws for contrastive language-image learning},
author={Cherti, Mehdi and Beaumont, Romain and Wightman, Ross and Wortsman, Mitchell and Ilharco, Gabriel and Gordon, Cade and Schuhmann, Christoph and Schmidt, Ludwig and Jitsev, Jenia},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={2818--2829},
year={2023}
}
OpenAI CLIP 论文
@inproceedings{Radford2021LearningTV,
title={Learning Transferable Visual Models From Natural Language Supervision},
author={Alec Radford and Jong Wook Kim and Chris Hallacy and A. Ramesh and Gabriel Goh and Sandhini Agarwal and Girish Sastry and Amanda Askell and Pamela Mishkin and Jack Clark and Gretchen Krueger and Ilya Sutskever},
booktitle={ICML},
year={2021}
}
OpenCLIP 软件
@software{ilharco_gabriel_2021_5143773,
author = {Ilharco, Gabriel and
Wortsman, Mitchell and
Wightman, Ross and
Gordon, Cade and
Carlini, Nicholas and
Taori, Rohan and
Dave, Achal and
Shankar, Vaishaal and
Namkoong, Hongseok and
Miller, John and
Hajishirzi, Hannaneh and
Farhadi, Ali and
Schmidt, Ludwig},
title = {OpenCLIP},
month = jul,
year = 2021,
note = {If you use this software, please cite it as below.},
publisher = {Zenodo},
version = {0.1},
doi = {10.5281/zenodo.5143773},
url = {https://doi.org/10.5281/zenodo.5143773}
}
如何开始使用该模型
安装必要的依赖并加载微调后的模型:
from open_clip import create_model_and_transforms, tokenizer
model, preprocess = create_model_and_transforms(
model_name="hf-hub:JianLiao/CLIP-ViT-L-14-spectrum-icons-20k"
)
tokenizer = tokenizer("ViT-L-14")
text_inputs = tokenizer(["图像的描述", "另一个图像的描述"])
image = preprocess("/path/to/image.png").unsqueeze(0)
with torch.no_grad():
logits_per_image, logits_per_text = model(image, text_inputs)
probs = logits_per_image.softmax(dim=-1).numpy()