xclip base patch32 16 frames
简介
核心亮点
- 支持视频-文本跨模态对齐,实现精准视频检索
- 通过时空建模捕捉动态特征,突破单帧识别限制
- 基于 MIT 协议开源,方便企业级快速部署集成
- 适配 16 帧输入,在性能与推理速度间取得平衡
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("microsoft/xclip-base-patch32-16-frames")
tokenizer = AutoTokenizer.from_pretrained("microsoft/xclip-base-patch32-16-frames")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download microsoft/xclip-base-patch32-16-frames
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download microsoft/xclip-base-patch32-16-frames config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('microsoft/xclip-base-patch32-16-frames')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/microsoft/xclip-base-patch32-16-frames
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/microsoft/xclip-base-patch32-16-frames
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('microsoft/xclip-base-patch32-16-frames')
tokenizer = AutoTokenizer.from_pretrained('microsoft/xclip-base-patch32-16-frames')
模型下载
我们推荐使用命令行或者 ModelScope SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 ModelScope:
pip install modelscope
命令行下载
下载完整模型库
modelscope download --model microsoft/xclip-base-patch32-16-frames
下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model microsoft/xclip-base-patch32-16-frames README.md --local_dir ./dir
SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('microsoft/xclip-base-patch32-16-frames')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://www.modelscope.cn/microsoft/xclip-base-patch32-16-frames.git
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/microsoft/xclip-base-patch32-16-frames.git
ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。
Notebook 快速开发
下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
p = pipeline('text-generation', 'microsoft/xclip-base-patch32-16-frames')
完整文档
---
language: en
license: mit
tags:
- vision
- video-classification
model-index:
- name: nielsr/xclip-base-patch32-16-frames
results:
- task:
type: video-classification
dataset:
name: Kinetics 400
type: kinetics-400
metrics:
- type: top-1 accuracy
value: 81.1
- type: top-5 accuracy
value: 95.5
---
X-CLIP (base-sized model)
X-CLIP model (base-sized, patch resolution of 32) trained fully-supervised on Kinetics-400. It was introduced in the paper Expanding Language-Image Pretrained Models for General Video Recognition by Ni et al. and first released in this repository.
This model was trained using 16 frames per video, at a resolution of 224x224.
Disclaimer: The team releasing X-CLIP did not write a model card for this model so this model card has been written by the Hugging Face team.
Model description
X-CLIP is a minimal extension of CLIP for general video-language understanding. The model is trained in a contrastive way on (video, text) pairs.
This allows the model to be used for tasks like zero-shot, few-shot or fully supervised video classification and video-text retrieval.
Intended uses & limitations
You can use the raw model for determining how well text goes with a given video. See the model hub to look for
fine-tuned versions on a task that interests you.
How to use
For code examples, we refer to the documentation.
Training data
This model was trained on Kinetics-400.
Preprocessing
The exact details of preprocessing during training can be found here.
The exact details of preprocessing during validation can be found here.
During validation, one resizes the shorter edge of each frame, after which center cropping is performed to a fixed-size resolution (like 224x224). Next, frames are normalized across the RGB channels with the ImageNet mean and standard deviation.
Evaluation results
This model achieves a top-1 accuracy of 81.1% and a top-5 accuracy of 95.5%.