Views
No views yet
pip install -U git+https://github.com/huggingface/transformers1from transformers import AutoVideoProcessor, AutoModel
2
3hf_repo = "facebook/vjepa2-vith-fpc64-256"
4
5model = AutoModel.from_pretrained(hf_repo)
6processor = AutoVideoProcessor.from_pretrained(hf_repo)1import torch
2from torchcodec.decoders import VideoDecoder
3import numpy as np
4
5video_url = "https://huggingface.co/datasets/nateraw/kinetics-mini/resolve/main/val/archery/-Qz25rXdMjE_000014_000024.mp4"
6vr = VideoDecoder(video_url)
7frame_idx = np.arange(0, 64) # choosing some frames. here, you can define more complex sampling strategy
8video = vr.get_frames_at(indices=frame_idx).data # T x C x H x W
9video = processor(video, return_tensors="pt").to(model.device)
10with torch.no_grad():
11 video_embeddings = model.get_vision_features(**video)
12
13print(video_embeddings.shape)1from transformers.image_utils import load_image
2
3image = load_image("https://huggingface.co/datasets/merve/coco/resolve/main/val2017/000000000285.jpg")
4pixel_values = processor(image, return_tensors="pt").to(model.device)["pixel_values_videos"]
5pixel_values = pixel_values.repeat(1, 16, 1, 1, 1) # repeating image 16 times
6
7with torch.no_grad():
8 image_embeddings = model.get_vision_features(pixel_values)
9
10print(image_embeddings.shape)@techreport{assran2025vjepa2,
title={V-JEPA~2: Self-Supervised Video Models Enable Understanding, Prediction and Planning},
author={Assran, Mahmoud and Bardes, Adrien and Fan, David and Garrido, Quentin and Howes, Russell and
Komeili, Mojtaba and Muckley, Matthew and Rizvi, Ammar and Roberts, Claire and Sinha, Koustuv and Zholus, Artem and
Arnaud, Sergio and Gejji, Abha and Martin, Ada and Robert Hogan, Francois and Dugas, Daniel and
Bojanowski, Piotr and Khalidov, Vasil and Labatut, Patrick and Massa, Francisco and Szafraniec, Marc and
Krishnakumar, Kapil and Li, Yong and Ma, Xiaodong and Chandar, Sarath and Meier, Franziska and LeCun, Yann and
Rabbat, Michael and Ballas, Nicolas},
institution={FAIR at Meta},
year={2025}
}