Views
No views yet
| Model | Avg Retrieval | Video Frames used |
|---|---|---|
pe-av-small-16-frame | 45.2 | 16 frames |
pe-av-base-16-frame | 47.0 | 16 frames |
pe-av-large-16-frame | 48.2 | 16 frames |
pe-av-small | 48.1 | all frames |
pe-av-base | 50.2 | all frames |
pe-av-large | 51.6 | all frames |
-16-frame variants sample exactly 16 frames (evenly spaced apart) from each video, while the base variants support variable-length videos.transformers as well as perception_models librariesperception_models Usage1import torch
2from core.audio_visual_encoder import PEAudioVisual, PEAudioVisualTransform
3
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
6# Load model and transform
7model = PEAudioVisual.from_config("pe-av-large", pretrained=True).to(device)
8transform = PEAudioVisualTransform.from_config("pe-av-large")
9
10video_files = ["video1.mp4", "video2.mp4"]
11descriptions = ["description1", "description2"]
12audio_files = ["audio1.wav", "audio2.wav"]
13
14# Process inputs and get embeddings
15inputs = transform(videos=video_files, text=descriptions, audio=audio_files).to(device)
16
17with torch.inference_mode(), torch.autocast(device.type, dtype=torch.bfloat16):
18 outputs = model(**inputs)
19
20# Access different embeddings
21audio_embeds = outputs.audio_embeds # Audio-only embeddings
22visual_embeds = outputs.visual_embeds # Video-only embeddings
23audio_visual_embeds = outputs.audio_visual_embeds # Joint audio-visual embeddings
24audio_text_embeds = outputs.audio_text_embeds # Text embeddings aligned to audio
25visual_text_embeds = outputs.visual_text_embeds # Text embeddings aligned to video
26audio_visual_text_embeds = outputs.audio_visual_text_embeds # Text embeddings aligned to audio-visual
27audio_plus_text_embeds = outputs.audio_plus_text_embeds # Joint audio and text embedding
28visual_plus_text_embeds = outputs.visual_plus_text_embeds # Joint video and text embedding
29
30# Compute the dot product to get their similarities
31audio_visual_similarity = audio_embeds @ visual_embeds.T
32# When computing similarity against text embeddings, use the
33# appropriate text embedding based on the other modality
34audio_text_similarity = audio_embeds @ audio_text_embeds.T
35video_text_similarity = visual_embeds @ visual_text_embeds.Tforward method. The corresponding embeddings in output will be None. For example:1inputs = transform(videos=video_files, text=descriptions).to(device)
2
3with torch.inference_mode(), torch.autocast(device.type, dtype=torch.bfloat16):
4 outputs = model(**inputs)
5
6audio_embeds = outputs.audio_embeds # None
7visual_embeds = outputs.visual_embeds # available
8audio_visual_embeds = outputs.audio_visual_embeds # None
9audio_visual_text_embeds = outputs.audio_visual_text_embeds # None
10audio_text_embeds = outputs.audio_text_embeds # None
11visual_text_embeds = outputs.visual_text_embeds # available
12audio_plus_text_embeds = outputs.audio_plus_text_embeds # None
13visual_plus_text_embeds = outputs.visual_plus_text_embeds # Available1def encode_video_text(self, input_ids, attention_mask=None)
2def encode_audio_text(self, input_ids, attention_mask=None)
3def encode_audio_video_text(self, input_ids, attention_mask=None)
4def encode_audio(self, input_values, padding_mask=None, input_features=None)
5def encode_video(self, pixel_values_videos, padding_mask_videos=None, pe_features=None)
6def encode_audio_video(
7 self,
8 input_values,
9 pixel_values_videos,
10 padding_mask=None,
11 padding_mask_videos=None,
12 pe_features=None, # optionally re-use pre-computed PE features
13 input_features=None, # Optionally re-use pre-computed audio codec features
14)
15def encode_audio_plus_text(
16 self,
17 input_ids,
18 input_values,
19 attention_mask=None,
20 padding_mask=None,
21 input_features=None # Optionally re-use pre-computed audio codec features
22)
23def encode_video_plus_text(
24 self,
25 input_ids,
26 pixel_values_videos,
27 attention_mask=None,
28 padding_mask_videos=None,
29 pe_features=None, # optionally re-use pre-computed PE features
30)transformers Usage1from transformers import PeAudioVideoModel, PeAudioVideoProcessor
2import torch
3
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5model = PeAudioVideoModel.from_pretrained("facebook/pe-av-large")
6processor = PeAudioVideoProcessor.from_pretrained("facebook/pe-av-large")
7
8model = model.to(device)
9
10video_files = ["video1.mp4", "video2.mp4"]
11descriptions = ["description1", "description2"]
12audio_files = ["audio1.wav", "audio2.wav"]
13
14# Process inputs and get embeddings
15inputs = processor(
16 videos=video_files, text=descriptions, audio=audio_files, return_tensors="pt", padding=True
17)
18
19with torch.inference_mode(), torch.autocast(device.type, dtype=torch.bfloat16):
20 outputs = model(**inputs.to(device), return_loss=True)
21
22audio_embeds = outputs.audio_embeds # Audio-only embeddings
23video_embeds = outputs.video_embeds # Video-only embeddings
24audio_video_embeds = outputs.audio_video_embeds # Joint audio-video embeddings
25text_audio_video_embeds = outputs.audio_video_text_embeds # Text embeddings aligned to audio-video
26text_audio_embeds = outputs.text_audio_embeds # Text embeddings aligned to audio
27text_video_embeds = outputs.text_video_embeds # Text embeddings aligned to video
28audio_plus_text_embeds = outputs.audio_plus_text_embeds # Joint audio and text embedding
29video_plus_text_embeds = outputs.video_plus_text_embeds # Joint video and text embedding
30
31# For classification, you can use the logits_* fields of the output
32audio_text_preds = outputs.logits_audio_text.sigmoid()
33
34# The overall loss is also available in the output (requires passing return_loss=True)
35loss = outputs.loss
361def get_text_audio_embeds(self, input_ids, attention_mask=None)
2
3def get_text_video_embeds(self, input_ids, attention_mask=None)
4
5def get_text_audio_video_embeds(self, input_ids, attention_mask=None)
6
7def get_audio_embeds(self, input_values, padding_mask=None)
8
9def get_video_embeds(self, pixel_values_videos, padding_mask_videos=None)
10
11def get_audio_video_embeds(
12 self,
13 input_values: torch.Tensor,
14 pixel_values_videos: torch.Tensor,
15 padding_mask: Optional[torch.Tensor] = None,
16 padding_mask_videos: Optional[torch.Tensor] = None,
17 return_audio_embeds: bool = False,
18 return_video_embeds: bool = False,
19)
20
21def get_audio_plus_text_embeds(
22 self,
23 input_ids: torch.Tensor,
24 input_values: torch.Tensor,
25 attention_mask: Optional[torch.Tensor] = None,
26 padding_mask: Optional[torch.Tensor] = None,
27)
28
29def get_video_plus_text_embeds(
30 self,
31 input_ids: torch.Tensor,
32 pixel_values_videos: torch.Tensor,
33 attention_mask: Optional[torch.Tensor] = None,
34 padding_mask_videos: Optional[torch.Tensor] = None,
35)
361@misc{vyas2025pushingfrontieraudiovisualperception,
2 title={Pushing the Frontier of Audiovisual Perception with Large-Scale Multimodal Correspondence Learning},
3 author={Apoorv Vyas and Heng-Jui Chang and Cheng-Fu Yang and Po-Yao Huang and Luya Gao and Julius Richter and Sanyuan Chen and Matt Le and Piotr Dollár and Christoph Feichtenhofer and Ann Lee and Wei-Ning Hsu},
4 year={2025},
5 eprint={2512.19687},
6 archivePrefix={arXiv},
7 primaryClass={cs.SD},
8 url={https://arxiv.org/abs/2512.19687},
9}