Views
No views yet
1from transformers import VideoMAEImageProcessor, VideoMAEForVideoClassification
2import torch
3import numpy as np
4
5# Load model and processor
6processor = VideoMAEImageProcessor.from_pretrained("AnnaelleMyriam/videomaev2-finetuned-finebio")
7model = VideoMAEForVideoClassification.from_pretrained("AnnaelleMyriam/videomaev2-finetuned-finebio")
8
9# Prepare video frames (list of PIL images or numpy arrays)
10# Shape: (num_frames, height, width, channels)
11video = np.random.randn(16, 224, 224, 3)
12
13# Process inputs
14inputs = processor(list(video), return_tensors="pt")
15
16# Forward pass
17with torch.no_grad():
18 outputs = model(**inputs)
19 logits = outputs.logits
20
21# Get predictions
22predicted_class_idx = logits.argmax(-1).item()
23print(f"Predicted class: {predicted_class_idx}")1@article{wang2023videomaev2,
2 title={VideoMAE V2: Scaling Video Masked Autoencoders with Dual Masking},
3 author={Wang, Limin and Huang, Bingkun and Zhao, Zhiyu and Tong, Zhan and He, Yinan and Wang, Yi and Wang, Yali and Qiao, Yu},
4 journal={arXiv preprint arXiv:2303.16727},
5 year={2023}
6}