Views
No views yet
| Model | Parameters |
|---|---|
pe-a-frame-small | 450M |
pe-a-frame-base | 560M |
pe-a-frame-large | 1.4B |
1import torch
2from core.audio_visual_encoder import PEAudioFrame, PEAudioFrameTransform
3
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
6# Load model and transform
7model = PEAudioFrame.from_config("pe-a-frame-large", pretrained=True).to(device)
8transform = PEAudioFrameTransform.from_config("pe-a-frame-large")
9
10# Define audio file and event descriptions
11audio_file = "office_conversation.wav"
12descriptions = ["a person talking", "keyboard typing", "phone ringing"]
13
14# Process inputs
15inputs = transform(audio=[audio_file], text=descriptions).to(device)
16
17# Run inference
18with torch.inference_mode():
19 outputs = model(**inputs, return_spans=True)
20
21# Print detected time spans for each event
22for description, spans in zip(descriptions, outputs.spans):
23 if spans:
24 span_str = ", ".join([f"({start:.2f}s, {end:.2f}s)" for start, end in spans])
25 print(f'"{description}": [{span_str}]')
26 else:
27 print(f'"{description}": No events detected')"a person talking": [(2.34s, 5.67s), (8.90s, 12.45s)]
"keyboard typing": [(1.20s, 3.40s), (6.78s, 9.12s)]
"phone ringing": No events detected1import torch
2from core.audio_visual_encoder import PEAudioFrame, PEAudioFrameTransform
3
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5model = PEAudioFrame.from_config("pe-a-frame-large", pretrained=True).to(device)
6transform = PEAudioFrameTransform.from_config("pe-a-frame-large")
7
8# Process multiple audio files with different descriptions
9audio_files = ["meeting.wav", "street.wav", "kitchen.wav"]
10descriptions = [
11 "people discussing in a meeting",
12 "cars passing by",
13 "water running from a faucet"
14]
15
16inputs = transform(audio=audio_files, text=descriptions).to(device)
17
18with torch.inference_mode():
19 outputs = model(**inputs, return_spans=True)
20
21# Each audio-text pair gets its own span predictions
22for audio, description, spans in zip(audio_files, descriptions, outputs.spans):
23 if spans:
24 span_str = ", ".join([f"({start:.2f}s, {end:.2f}s)" for start, end in spans])
25 print(f'"{description}": [{span_str}] in {audio}')
26 else:
27 print(f'"{description}": No events detected in {audio}')threshold parameter controls sensitivity for event detection. Lower values detect more events (higher recall), while higher values are more selective (higher precision):1# High sensitivity - detect more events (may include false positives)
2outputs_sensitive = model(**inputs, threshold=0.2)1inputs = transform(audio=[audio_file], text=descriptions).to(device)
2
3with torch.inference_mode():
4 outputs = model(**inputs, return_spans=False)
5
6# Access embeddings
7audio_embeds = outputs.audio_embeds # Shape: [batch_size, num_frames, embed_dim]
8text_embeds = outputs.text_embeds # Shape: [batch_size, embed_dim]
9
10# Compute similarity between audio frames and text
11# audio_embeds is frame-level, so you can see which frames match the description
12similarities = torch.einsum("btd,bd->bt", audio_embeds, text_embeds)
13# similarities shape: [batch_size, num_frames]1model = PeAudioFrameLevelModel.from_pretrained("facebook/pe-a-frame-large")
2processor = PeAudioProcessor.from_pretrained("facebook/pe-a-frame-large")
3
4inputs = transform(audio=[audio_file], text=descriptions, return_tensors="pt").to(device)
5
6with torch.inference_mode():
7 outputs = model(**inputs)
8
9# Access embeddings
10audio_embeds = outputs.audio_embeds # Shape: [batch_size, num_frames, embed_dim]
11text_embeds = outputs.text_audio_embeds # Shape: [batch_size, embed_dim]
12
13# Compute similarity between audio frames and text
14# audio_embeds is frame-level, so you can see which frames match the description
15similarities = torch.einsum("btd,bd->bt", audio_embeds, text_embeds)
16# similarities shape: [batch_size, num_frames]1@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}