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