Open rhine3 opened 7 months ago
This probably stems from a rounding or floating point issue when loading audio in Audio.from_file https://github.com/kitzeslab/opensoundscape/blob/a04ef97d2edd9d882401763a4c4e97f425ed9b00/opensoundscape/audio.py#L307-L308
A quick patch for this that Sam and I worked out is to modify the preprocessor of the loaded model, for example:
from opensoundscape.preprocess.actions import AudioTrim
birdnet = torch.hub.load('kitzeslab/bioacoustics-model-zoo', 'BirdNET', trust_repo=True)
pre = birdnet.preprocessor
pre.insert_action(
action_index = 'extend_audio',
after_key = 'load_audio',
action = AudioTrim(extend=True)
)
When calling
m.predict(..., overlap_fraction=0.4)
, certain values of overlap_fraction raise a ValueError due to dimension mismatch. The dimension is one less than it should be in my testing. Probably a rounding error somewhere?This is while running BirdNET from the model zoo, e.g.
m.predict(["../../data/wildtrax_oven/recordings_alloven_wav/100032.wav"], overlap_fraction=0.66) # returns dataframe of per-class scores
Fractions that work: 0.24, 0.25, 0.5, 0.75
Fractions that don't work: 0.1, 0.66, 0.9
Full traceback: