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

IndexError: list index out of range #10

Closed
NoxTheXelor opened this issue May 10, 2023 · 2 comments · Fixed by #11
Closed

IndexError: list index out of range #10

NoxTheXelor opened this issue May 10, 2023 · 2 comments · Fixed by #11
Assignees
Labels
bug Something isn't working

Comments

@NoxTheXelor
Copy link

NoxTheXelor commented May 10, 2023

Hello,
I was using the batdetect2 api (the 1.0.4) on a raspberry pi with high frequence microphone.
It worked very well (thanks to your work) few hours, but I encountered this error

File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
  self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run 
   self._target (self._args, **self._kwargs)
File "/usr/local/bin/server.py", line 178, in handle_client 
   results = api.process_file(file_path) ["pred_dict"]
File "/home/bird/BirdNET-Pi/scripts/batdetect2/api.py", line 262, in process_file 
   return du.process_file(
File "/home/bird/BirdNET-Pi/scripts/batdetect2/utils/detector_utils.py", line 785,  in process_file 
   predictions, spec_feats, cnn_feats, spec_slices = _merge_results( 
 File "/home/bird/BirdNET-Pi/scripts/batdetect2/utils/detector_utils.py", line 157, in _merge_results( 
    predictions_m=predictions[0]
IndexError: list index out of range

I only used this line
results = api.process_file(file_path) ["pred_dict"]
in my code

I have not dived in the concerned code yet so I don't have any other info but don't hesitate to ask.
Could you give it a look ?
I joind a picture of the error as the code above is the result of a image to text and may contains error.
Thanks in advance
1683751572362

@mbsantiago mbsantiago self-assigned this May 11, 2023
@mbsantiago mbsantiago added the bug Something isn't working label May 11, 2023
@NoxTheXelor NoxTheXelor reopened this May 11, 2023
@mbsantiago mbsantiago linked a pull request May 11, 2023 that will close this issue
mbsantiago added a commit that referenced this issue May 11, 2023
fix: the case of no detections is now handled better
@mbsantiago
Copy link
Collaborator

Hi @NoxTheXelor!

Thanks for filing this issue. I have looked into it, and it seems that the problem was caused by the code not handling situations where the model did not produce any detections. I have fixed this issue and released a new version, 1.0.5. Please upgrade to the latest version and let me know if the issue has been resolved.

In my testing, I tried creating scenarios where the model did not output any detections by running it on random noise and silent recordings, but the model was still able to find bat calls (albeit with a low probability). However, the only way I was able to replicate the issue you reported was by running the API on an empty WAV file with zero samples. This suggests that there may be an issue with the recordings made on your device. Thought it might be useful info.

Again, thanks for your interest in batdetect2, happy to hear what you are using it for.

Cheers, Santiago

@NoxTheXelor
Copy link
Author

Thanks for the quick reply, I'll run a new instance soon and update you.
For my thesis I'm working on a bat version of BirdNET-Pi (https://github.com/mcguirepr89/BirdNET-Pi). I tried different ai model but yours gave the best processing speed so thanks again for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants