Mattk70 / Chirpity-Electron

AI powered audio analyser for bird call visualisation, detection and cataloguing
https://chirpity.mattkirkland.co.uk
36 stars 2 forks source link

Allow custom model import #48

Open Mattk70 opened 9 months ago

Mattk70 commented 9 months ago

Make it possible to use custom models, trained using BirdNET analyzer's train.py.

nishantnnb commented 9 months ago

Yes, pls allow using custom model trained with Birdnet.

Thanks.

Mattk70 commented 9 months ago

Yes, pls allow using custom model trained with Birdnet.

Thanks.

Do you have such a model? If you shared it, I could see what it would take to integrate it.

nishantnnb commented 9 months ago

Thank you for the reply.

I have a small sample model file (tflite) and labels file (txt) trained for 5 birds in birdnet analyzer.

1) tflite model (Pls rename the file extension from .txt to .tflite >>> 5_Demo_birds.tflite 5_Demo_birds.txt

2) Labels file (to be used as it is with txt extension >>> 5_Demo_birds_Labels.txt 5_Demo_birds_Labels.txt

Regards, Nishant

PS: Kindly let me know if any issues in using above model. I also have another model trained for about 200 birds.

Mattk70 commented 9 months ago

Thank you for the reply.

I have a small sample model file (tflite) and labels file (txt) trained for 5 birds in birdnet analyzer.

  1. tflite model (Pls rename the file extension from .txt to .tflite >>> 5_Demo_birds.tflite 5_Demo_birds.txt
  2. Labels file (to be used as it is with txt extension >>> 5_Demo_birds_Labels.txt 5_Demo_birds_Labels.txt

Regards, Nishant

PS: Kindly let me know if any issues in using above model. I also have another model trained for about 200 birds.

Thanks Nishant. I don't suppose you have or could save your model in "Raven" format? Looking at @Kahst's code, this appears to save a native tensorflow Keras model, which would be much easier to incorporate into Chirpity, which itself uses TFJS models.

nishantnnb commented 9 months ago

Hi, Retrained the same input files in Birdnet & saved the model in Raven format. The zip file contains different files & folders which got written in the Model output directory.
I have never used the model output in Raven format before. Hope the contains in the zip file helps.

Regards, Nishant

CustomClassifier.zip

Mattk70 commented 9 months ago

Hi, Retrained the same input files in Birdnet & saved the model in Raven format. The zip file contains different files & folders which got written in the Model output directory. I have never used the model output in Raven format before. Hope the contains in the zip file helps.

Regards, Nishant

CustomClassifier.zip

Thanks for this. I've had a quick look and not had muck luck. This might take a while, don't hold your breath!

Mattk70 commented 6 months ago

I made progress on this, and as a proof of concept, have managed to load a Raven format BirdNET custom classifier model into Chirpity without any conversion needed. However, as things stand, there's still quite a few obstacles to overcome before this could be added to a release. Parsing labels shouldn't be difficult, but a custom classifier would also need its own database (because the classes won't correspond to the existing models). On top of that, the lists would most likely need to be one of "everything", "custom" as the others couldn't be relied upon.