clip vit large patch14 336
简介
CLIP ViT-L/14@336 是 OpenAI 推出的经典视觉-语言预训练模型。它通过海量图文对学习,将图像和文本映射到同一个向量空间,从而实现精准的跨模态检索。相比标准版,该模型将输入分辨率提升至 336x336,显著增强了对图像细节的感知能力。对于开发者而言,它不仅是构建以图搜图、自动打标签系统的核心组件,更是目前许多主流 AIGC 流程(如 Stable Diffusion 的文本编码器)的基础,上手难度低,生态适配极佳。
核心亮点
- 高分辨率输入,图像细节捕捉能力更强
- 强大的零样本分类与跨模态检索能力
- 广泛应用于 AIGC 模型的文本引导端
- Apache-2.0 协议,商业化部署无压力
使用方法
安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("openai/clip-vit-large-patch14-336")
tokenizer = AutoTokenizer.from_pretrained("openai/clip-vit-large-patch14-336")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
操作指引
pip install -U huggingface_hub
命令行下载
下载完整模型库
下载完整模型库
huggingface-cli download openai/clip-vit-large-patch14-336
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download openai/clip-vit-large-patch14-336 config.json --local-dir ./dir
SDK 下载
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('openai/clip-vit-large-patch14-336')
Git 下载
请确保 lfs 已经被正确安装
Git 下载
git lfs install
git clone https://huggingface.co/openai/clip-vit-large-patch14-336
如果您希望跳过 lfs 大文件下载,可以使用如下命令
跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/openai/clip-vit-large-patch14-336
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
安装 Transformers
pip install -U transformers torch
模型加载和推理
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('openai/clip-vit-large-patch14-336')
tokenizer = AutoTokenizer.from_pretrained('openai/clip-vit-large-patch14-336')
完整文档
来源: HuggingFace
---
tags:
- generated_from_keras_callback
widget:
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/cat-dog-music.png
candidate_labels: playing music, playing sports
example_title: Cat & Dog
model-index:
- name: clip-vit-large-patch14-336
results: []
---
<!-- This model card has been generated automatically according to the information Keras had access to. You should
probably proofread and complete it, then remove this comment. -->
clip-vit-large-patch14-336
This model was trained from scratch on an unknown dataset.
It achieves the following results on the evaluation set:
Model description
More information needed
Intended uses & limitations
More information needed
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- optimizer: None
- training_precision: float32
Training results
Framework versions
- Transformers 4.21.3
- TensorFlow 2.8.2
- Tokenizers 0.12.1