Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to use 5 second Sig_Length #288

Closed
mthompson89 opened this issue Mar 20, 2024 · 5 comments
Closed

Error when trying to use 5 second Sig_Length #288

mthompson89 opened this issue Mar 20, 2024 · 5 comments

Comments

@mthompson89
Copy link

Hello,
I am using the python script to run BirdNET and would like to extend the segment length (cfg.SIG_LENGTH) to 5 seconds. This seems easy enough in the config.py file by adjusting the variable and the cfg.SIG_MINLEN variable to 5.0 however when I run the analyzer I get an error that just says:

Species list contains 123 species
Found 1 files to analyze
Analyzing example/20220610_050001.WAV
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
WARNING: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#187 is a dynamic-sized tensor).
Error: Cannot analyze audio file example/20220610_050001.WAV.

my first guess was this might be might be a model input size since there is a comment in the config.py file that says:

# We use a sample rate of 48kHz, so the model input size is
# (batch size, 48000 kHz * 3 seconds) = (1, 144000)
# Recordings will be resampled automatically.

and with a 5 second segment length this would be (batch size, 48000 kHz * 5 seconds) = (1, 240000) but I don't know how or if I need to adjust this.

Thanks!

@mthompson89
Copy link
Author

update:
with my config.py file settings not changing, I can run BirdNET_v2.3 without issue however, when I change to v2.4 I get the error saying it can't run.

Here are my config settings that I changed from default:

# We're using 3-second chunks
SIG_LENGTH: float = 5.0

# Define overlap between consecutive chunks <3.0; 0 = no overlap
SIG_OVERLAP: float = 2.0

# Define minimum length of audio chunk for prediction,
# chunks shorter than 3 seconds will be padded with zeros
SIG_MINLEN: float = 5.0

and when I run the model using v2.4 this is the error_log traceback (repeated many times)

Traceback (most recent call last):
  File "c:\patht\BirdNET-Analyzer-main_2-4\BirdNET-Analyzer-main\analyze.py", line 366, in analyzeFile
    p = predict(samples)
        ^^^^^^^^^^^^^^^^
  File "c:\path\BirdNET-Analyzer-main_2-4\BirdNET-Analyzer-main\analyze.py", line 310, in predict
    prediction = model.predict(data)
                 ^^^^^^^^^^^^^^^^^^^
  File "c:\path\BirdNET-Analyzer-main_2-4\BirdNET-Analyzer-main\model.py", line 551, in predict
    INTERPRETER.invoke()
  File "C:\path\Lib\site-packages\tensorflow\lite\python\interpreter.py", line 941, in invoke
    self._interpreter.Invoke()
RuntimeError: tensorflow/lite/kernels/concatenation.cc:202 t->dims->data[d] != t0->dims->data[d] (854 != 856)Node number 92 (CONCATENATION) failed to prepare.

still not sure how to resolve the issue.

@Josef-Haupt
Copy link
Collaborator

BirdNET currently has no variable input size, so changing the sig_length will lead to an error.

@mthompson89
Copy link
Author

@Josef-Haupt is this a new change to v2.4? v2.1, v2.2, and v2.3 were all able to take 5 second Sig_lengths.

@kahst
Copy link
Owner

kahst commented Apr 18, 2024

This is because of the second spectrogram we introduced in V2.4 - both spectrograms use different parameters to arrive at the same resolution, and there are only very few input sizes that lead to the same spectrogram size for both. Unfortunately, 5s is none of them. I believe 3.5s and 2.5s should work, though.

@mthompson89
Copy link
Author

@kahst Thanks for the update and explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants