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 related to 'tflite_runtime.interpreter' when executing BirdNET-Analyzer on Windows server #441

Open
Joerg-Albrecht opened this issue Sep 5, 2024 · 5 comments

Comments

@Joerg-Albrecht
Copy link

Describe the bug
I installed BirdNET-Analyzer on a Windows server and wanted to make a test run but ran into problems (see error message below). It seems to be related to the import of tflite_runtime.interpreter in the script model.py.

Any help regarding the solution to the problem would be great.

To Reproduce
I tried to start the birdNET-Analyzer.exe for windows as described in the Readme, using the following command:

C:\Users\AlbrechtJo\AppData\Local\Programs\BirdNET-Analyzer>BirdNET-Analyzer.exe --i example/ --o example/ --slist example/ --min_conf 0.5 --threads 4

I get the following error message:

Traceback (most recent call last):
  File "model.py", line 25, in <module>
ModuleNotFoundError: No module named 'tflite_runtime'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "analyze.py", line 17, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "model.py", line 27, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "tensorflow\__init__.py", line 45, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "tensorflow\python\tf2.py", line 21, in <module>
ImportError: DLL load failed while importing _pywrap_tf2: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.
[PYI-12736:ERROR] Failed to execute script 'analyze' due to unhandled exception!

A similar error occurred when I tried to run BirdNET-Analyzer using the cloned github repository.

Expected behavior
I expected BirdNET to analyze the example files but I got the following error message.

Desktop (please complete the following information):

  • OS: Windows Server 2022 Datacenter

  • Version 21H2

  • Python version 3.12.1

Package                 Version
----------------------- ------------
absl-py                 2.1.0
astunparse              1.6.3
audioread               3.0.1
certifi                 2024.8.30
cffi                    1.17.1
charset-normalizer      3.3.2
contourpy               1.3.0
cycler                  0.12.1
decorator               5.1.1
flatbuffers             24.3.25
fonttools               4.53.1
gast                    0.6.0
google-pasta            0.2.0
grpcio                  1.66.1
h5py                    3.11.0
idna                    3.8
joblib                  1.4.2
keras                   3.5.0
kiwisolver              1.4.7
lazy_loader             0.4
libclang                18.1.1
librosa                 0.10.2.post1
llvmlite                0.43.0
Markdown                3.7
markdown-it-py          3.0.0
MarkupSafe              2.1.5
matplotlib              3.9.2
mdurl                   0.1.2
ml-dtypes               0.3.2
msgpack                 1.0.8
namex                   0.0.8
numba                   0.60.0
numpy                   1.26.4
opt-einsum              3.3.0
optree                  0.12.1
packaging               24.1
pillow                  10.4.0
pip                     24.2
platformdirs            4.2.2
pooch                   1.8.2
protobuf                4.25.4
pycparser               2.22
pydub                   0.25.1
Pygments                2.18.0
pyparsing               3.1.4
python-dateutil         2.9.0.post0
requests                2.32.3
resampy                 0.4.3
rich                    13.8.0
scikit-learn            1.5.1
scipy                   1.14.1
setuptools              74.1.2
six                     1.16.0
soundfile               0.12.1
soxr                    0.5.0.post1
tensorboard             2.17.1
tensorboard-data-server 0.7.2
tensorflow              2.17.0
tensorflow-intel        2.17.0
termcolor               2.4.0
tflite                  2.10.0
threadpoolctl           3.5.0
typing_extensions       4.12.2
urllib3                 2.2.2
watchdog                2.1.9
Werkzeug                3.0.4
wheel                   0.44.0
wrapt                   1.16.0

Additional context
Add any other context about the problem here.

@max-mauermann
Copy link
Collaborator

Hi,
Could you try to install
librosa==0.9.2
and
tensorflow==2.15.0
as this is what we have in our requirements.txt and might already solve your issue.

@Joerg-Albrecht
Copy link
Author

Thank you for the suggestion. In the first try I couldn't install tensorflow==2.15.0, because it is not supported by python 3.12, which runs on the windows machine.

Following your suggestion I tried it with python 3.11, which supports librosa==0.9.2 and tensorflow==2.15.0. However, I still encounter the error. Here is what I tried and the error message:

M:\Telearbeit\RoamingProfileData\AppData\BirdNET-Analyzer>py -3.11 analyze.py --i example/ --o example/ --slist example/ --min_conf 0.5 --threads 4
Traceback (most recent call last):
  File "M:\Telearbeit\RoamingProfileData\AppData\BirdNET-Analyzer\model.py", line 25, in <module>
    import tflite_runtime.interpreter as tflite  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'tflite_runtime'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "M:\Telearbeit\RoamingProfileData\AppData\BirdNET-Analyzer\analyze.py", line 17, in <module>
    import model
  File "M:\Telearbeit\RoamingProfileData\AppData\BirdNET-Analyzer\model.py", line 27, in <module>
    from tensorflow import lite as tflite
  File "\\srvhlugfaswi001\AlbrechtJo\Telearbeit\RoamingProfileData\AppData\Python\Python311\site-packages\tensorflow\__init__.py", line 45, in <module>
    from tensorflow.python import tf2 as _tf2
  File "\\srvhlugfaswi001\AlbrechtJo\Telearbeit\RoamingProfileData\AppData\Python\Python311\site-packages\tensorflow\python\tf2.py", line 21, in <module>
    from tensorflow.python.platform import _pywrap_tf2
ImportError: DLL load failed while importing _pywrap_tf2: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.

The problem seems to be the call to tflite_runtime.

@Josef-Haupt
Copy link
Collaborator

I'm not familiar mit the switch py -3.11.
Please type py --version to check your python version. Looks to me like it's still the same problem.

@Joerg-Albrecht
Copy link
Author

I have both versions of python (3.11 and 3.12) installed. The command py -3.11 is a shorthand in pylauncher to run a specific version of python. Maybe I need to create a virtual environment.

@FuryBart
Copy link

@Joerg-Albrecht
It may be the same issue I am having. I have not been able to fix it yet.

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

6 participants
@FuryBart @Josef-Haupt @max-mauermann @Joerg-Albrecht and others