🚀 VideoMAE(基础大小模型,仅预训练)
VideoMAE是一个在Kinetics - 400数据集上以自监督方式预训练1600个轮次的模型。它由Tong等人在论文VideoMAE: Masked Autoencoders are Data - Efficient Learners for Self - Supervised Video Pre - Training中提出,并首次在[此仓库](https://github.com/MCG - NJU/VideoMAE)发布。
免责声明:发布VideoMAE的团队未为此模型编写模型卡片,此模型卡片由Hugging Face团队编写。
🚀 快速开始
本模型主要用于视频领域的相关任务,通过自监督预训练学习视频的内在表示,可用于下游任务的特征提取。以下将详细介绍其使用方法和相关特性。
✨ 主要特性
模型架构
VideoMAE是Masked Autoencoders (MAE)在视频领域的扩展。其架构与标准的视觉变换器(Vision Transformer,ViT)非常相似,顶部有一个解码器,用于预测掩码块的像素值。
输入处理
视频以固定大小的块序列(分辨率为16x16)的形式输入到模型中,这些块会进行线性嵌入。同时,会在序列开头添加一个[CLS]标记,用于分类任务。在将序列输入到Transformer编码器层之前,还会添加固定的正弦/余弦位置嵌入。
预训练优势
通过预训练,模型学习到视频的内在表示,可用于提取对下游任务有用的特征。例如,如果你有一个带标签的视频数据集,可以在预训练的编码器顶部放置一个线性层,训练一个标准的分类器。通常会在[CLS]标记顶部放置一个线性层,因为该标记的最后隐藏状态可视为整个视频的表示。
📚 详细文档
预期用途和限制
你可以使用原始模型来预测视频掩码块的像素值,但它主要用于在下游任务上进行微调。你可以查看模型中心,寻找针对你感兴趣任务的微调版本。
使用方法
以下是如何使用此模型预测随机掩码块的像素值:
from transformers import VideoMAEImageProcessor, VideoMAEForPreTraining
import numpy as np
import torch
num_frames = 16
video = list(np.random.randn(16, 3, 224, 224))
processor = VideoMAEImageProcessor.from_pretrained("MCG-NJU/videomae-base")
model = VideoMAEForPreTraining.from_pretrained("MCG-NJU/videomae-base")
pixel_values = processor(video, return_tensors="pt").pixel_values
num_patches_per_frame = (model.config.image_size // model.config.patch_size) ** 2
seq_length = (num_frames // model.config.tubelet_size) * num_patches_per_frame
bool_masked_pos = torch.randint(0, 2, (1, seq_length)).bool()
outputs = model(pixel_values, bool_masked_pos=bool_masked_pos)
loss = outputs.loss
更多代码示例,请参考文档。
📄 许可证
本模型采用CC - BY - NC - 4.0许可证。
BibTeX引用
misc{https://doi.org/10.48550/arxiv.2203.12602,
doi = {10.48550/ARXIV.2203.12602},
url = {https://arxiv.org/abs/2203.12602},
author = {Tong, Zhan and Song, Yibing and Wang, Jue and Wang, Limin},
keywords = {Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {VideoMAE: Masked Autoencoders are Data-Efficient Learners for Self-Supervised Video Pre-Training},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}