模型:
fcakyon/timesformer-base-finetuned-k400
TimeSformer模型在 Kinetics-400 上进行了预训练。它由Tong等人在 this repository 的论文中首次提出并发布。
声明:发布TimeSformer模型的团队并未为该模型编写模型卡片,因此此模型卡片由 fcakyon 编写。
您可以使用原始模型来对视频进行分类,将其归为可能的400个Kinetics-400标签之一。
以下是使用此模型对视频进行分类的方法:
from transformers import AutoImageProcessor, TimesformerForVideoClassification import numpy as np import torch video = list(np.random.randn(8, 3, 224, 224)) processor = AutoImageProcessor.from_pretrained("fcakyon/timesformer-base-finetuned-k400") model = TimesformerForVideoClassification.from_pretrained("fcakyon/timesformer-base-finetuned-k400") inputs = processor(video, return_tensors="pt") with torch.no_grad(): outputs = model(**inputs) logits = outputs.logits predicted_class_idx = logits.argmax(-1).item() print("Predicted class:", model.config.id2label[predicted_class_idx])
更多代码示例,请参考 documentation 。
@inproceedings{bertasius2021space, title={Is Space-Time Attention All You Need for Video Understanding?}, author={Bertasius, Gedas and Wang, Heng and Torresani, Lorenzo}, booktitle={International Conference on Machine Learning}, pages={813--824}, year={2021}, organization={PMLR} }