joeweiss / birdnetlib

A python api for BirdNET-Lite and BirdNET-Analyzer
https://joeweiss.github.io/birdnetlib/
Apache License 2.0
40 stars 13 forks source link

Added rudimentary feature extraction #74

Closed MJWeldy closed 4 months ago

MJWeldy commented 1 year ago

Hi Joe, My name is Matt Weldy. I am a phd student working with bioacoustics in Oregon. I am currently working on a project using the previous 320 length birdnet embeddings. However, I ran into this lib today and thought I would add in a rudimentary implementation of the embedding extraction. When the analyzer class is initiated feature extraction in enabled with Analyzer(fetch_embeddings = 1). The processed embedding is accessed through recording.features_list or recording.features

Feel free to keep it or toss it as you see fit :)

joeweiss commented 1 year ago

Hi Matt. This looks good, and this functionality was on the todo list #42, so thanks!

This PR will need a test case, preferably one that tests against the commandline embeddings.py script from BirdNET-Analyzer. I'm happy to take a stab at that, or you can if you would prefer.

Also, just FYI, the license for the project is going to change from GPLv3 to Apache 2 (a more permissive license). I'll likely hold off on merging this PR until after the license change, so your code contribution will be under Apache 2.

joeweiss commented 10 months ago

Hey Matt. I'm going to close this for now since the PR is out of date. I still have #42 as an open issue and I'll refer to your PR when I get around to implementing it.

MJWeldy commented 5 months ago

Hi Joe, I am circling back on the embedding extraction PR request. I am currently refactoring a research project to use birdnetlib instead of custom analyzer code. But in order to complete the refactor I need to be able to access the embeddings without a custom classifier. It looks like my original PR was never integrated. Would it be possible to pull it in now? Best, Matt

joeweiss commented 5 months ago

Hey Matt. I'd love to get #42 implemented.

We've had a few updates since August, so I'll need to get this PR up-to-date. It might not need any changes, it just needs to be checked. Would you mind confirming it still works as expected (against the current main branch)?

Also, it needs a test case. I can probably do that in the next day or so.

Thanks!

MJWeldy commented 5 months ago

Hi Joe! It looks like it might work as is. If you could push the new updates and the PR to a new branch I can pull it down and test it. Also, I'll send over a test case this week. Do you have a preference how the test embeddings are passed along (i.e., text, pickle, npz)? Best, Matt

joeweiss commented 5 months ago

Hey Matt.

I decided to add a test case myself, which led to me going ahead and fleshing out the method. Check it out here: https://github.com/joeweiss/birdnetlib/pull/112

For test cases, I've been running the BirdNET-Analyzer command line script, then asserting birdnetlib's output directly against that, rather than using an expected fixture. Usually I'd use a test fixture (npz or text), but the live test helps me catch upstream changes in the main project.

Thanks for checking out the implementation and for providing the original code (and the spark for revisiting it!).

If everything looks good to you, I'll merge that PR and publish it to PyPI.

joeweiss commented 4 months ago

112 merged in.