Different output audio features for the same input audio waveform
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 213
- PR merge metrics
- No merged PRs in 30d
Description
Hi authors,
Thank you for sharing and maintaining the code!
I found out that for the same audio input, the model generates different audio features depending on the method of input data.
Specifically, the audio feature generated from feeding one input audio into the model is different from the features generated by aggregating the same audio into a batch and feeding the batched audio into the model.
An example is provided below.
`
from datasets import load_dataset
from transformers import AutoProcessor, ClapModel
dataset = load_dataset("ashraq/esc50")
audio_sample = dataset["train"]["audio"][0]["array"]
model = ClapModel.from_pretrained("laion/clap-htsat-fused")
processor = AutoProcessor.from_pretrained("laion/clap-htsat-fused")
model.eval()
with torch.no_grad():
inputs = processor(audios=[audio_sample, audio_sample, audio_sample], return_tensors="pt", padding=True)
audio_features_1 = model.get_audio_features(**inputs)
feat_diff = audio_features_1[0] - audio_features_1[1]
print('audio_features_1[0] == audio_features_1[1]?', torch.all(torch.abs(feat_diff) <= 1e-3))
feat_diff = audio_features_1[0] - audio_features_1[2]
print('audio_features_1[0] == audio_features_1[2]?', torch.all(torch.abs(feat_diff) <= 1e-3))
feat_diff = audio_features_1[1] - audio_features_1[2]
print('audio_features_1[1] == audio_features_1[2]?', torch.all(torch.abs(feat_diff) <= 1e-3))
print('-'*30)
inputs_2 = processor(audios=audio_sample, return_tensors="pt", padding=True)
audio_features_2 = model.get_audio_features(**inputs_2)
feat_diff = audio_features_1[0] - audio_features_2
print('audio_features_1[0] == audio_features_2?', torch.all(torch.abs(feat_diff) <= 1e-3))
feat_diff = audio_features_1[1] - audio_features_2
print('audio_features_1[1] == audio_features_2?', torch.all(torch.abs(feat_diff) <= 1e-3))
feat_diff = audio_features_1[2] - audio_features_2
print('audio_features_1[2] == audio_features_2?', torch.all(torch.abs(feat_diff) <= 1e-3))
`
`
audio_features_1[0] == audio_features_1[1]? tensor(True)
audio_features_1[0] == audio_features_1[2]? tensor(False)
audio_features_1[1] == audio_features_1[2]? tensor(False)
------------------------------
It is strongly recommended to pass the `sampling_rate` argument to this function. Failing to do so can result in silent errors
that might be hard to debug.
audio_features_1[0] == audio_features_2? tensor(False)
audio_features_1[1] == audio_features_2? tensor(False)
audio_features_1[2] == audio_features_2? tensor(True)
`
Could you please check out this problem?
Thank you!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided reproduction with the ESC-50 sample and compare the outputs from batched and single-audio calls. Start by inspecting the processor's padding and batching behavior together with ClapModel.get_audio_features. Done means identical input waveforms produce consistent audio features regardless of whether they are processed individually or in a batch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- audio-video-rtc, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100