ARM-software / armnn

Arm NN ML Software. The code here is a read-only mirror of https://review.mlplatform.org/admin/repos/ml/armnn
https://developer.arm.com/products/processors/machine-learning/arm-nn
MIT License
1.17k stars 310 forks source link

PyArmNN's ASR example error #590

Closed sdavejones closed 2 years ago

sdavejones commented 2 years ago

I followed the instructions [1] to test ASR example on RPi4 (Ubuntu 20.04). The version of ArmNN is 21.08. I cannot run run_audio_file.py:

$ python3 run_audio_file.py --audio_file_path tests/testdata/quick_brown_fox_16000khz.wav --model_file_path tflite_int8/wav2letter_int8.tflite --labels_file_path tests/testdata/wav2letter_labels.txt --preferred_backends CpuAcc CpuRef

Your ArmNN library instance does not support Onnx models parser functionality. Skipped IOnnxParser import. Traceback (most recent call last): File "run_audio_file.py", line 94, in main(args) File "run_audio_file.py", line 59, in main network = ArmnnNetworkExecutor(model.path, args.preferred_backends) File "/home/ubuntu/armnn-21.08/python/pyarmnn/examples/speech_recognition/../common/network_executor.py", line 94, in init self.network_id, self.runtime, self.input_binding_info, self.output_binding_info = create_network(model_file, File "/home/ubuntu/armnn-21.08/python/pyarmnn/examples/speech_recognition/../common/network_executor.py", line 36, in create_network network = parser.CreateNetworkFromBinaryFile(model_file) File "/usr/lib/python3/dist-packages/pyarmnn/_generated/pyarmnn_tfliteparser.py", line 711, in CreateNetworkFromBinaryFile return _pyarmnn_tfliteparser.ITfLiteParser_CreateNetworkFromBinaryFile(self, graphFile) RuntimeError: Buffer doesn't conform to the expected Tensorflow Lite flatbuffers format. size:133 at function LoadModelFromBinary [/build/armnn-9SkJA0/armnn-21.08/src/armnnTfLiteParser/TfLiteParser.cpp:3609]

Any idea? Thanks.

[1] https://developer.arm.com/documentation/102603/2108/Introduction?lang=en

MikeJKelly commented 2 years ago

Hi @sdavejones

it looks like your version of armnn was not compiled with OnnxParser support. Can you confirm that you followed the guide and installed it using:

sudo apt install software-properties-common
sudo add-apt-repository ppa:armnn/ppa
sudo apt update
sudo apt-get install -y python3-pyarmnn armnn-latest-cpu armnn-latest-ref

Does your version of armnn have a file called libarmnnOnnxParser.so?

Best regards, Mike

sdavejones commented 2 years ago

Hi @sdavejones

it looks like your version of armnn was not compiled with OnnxParser support. Can you confirm that you followed the guide and installed it using:

sudo apt install software-properties-common
sudo add-apt-repository ppa:armnn/ppa
sudo apt update
sudo apt-get install -y python3-pyarmnn armnn-latest-cpu armnn-latest-ref

Does your version of armnn have a file called libarmnnOnnxParser.so?

Best regards, Mike

sdavejones commented 2 years ago

Hi @MikeJKelly

I've already install the latest version.

$ sudo apt-get install -y python3-pyarmnn armnn-latest-cpu armnn-latest-ref Reading package lists... Done Building dependency tree Reading state information... Done armnn-latest-cpu is already the newest version (21.08-3). armnn-latest-ref is already the newest version (21.08-3). python3-pyarmnn is already the newest version (21.08-3). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

No, I don't have the libarmnnOnnxParser.so library.

$ find / -name "libarmnn.so" -print ./usr/lib/aarch64-linux-gnu/libarmnnDeserializer.so.26.0 ./usr/lib/aarch64-linux-gnu/libarmnnSerializer.so.26.0 ./usr/lib/aarch64-linux-gnu/libarmnn.so.26 ./usr/lib/aarch64-linux-gnu/libarmnnDeserializer.so.26 ./usr/lib/aarch64-linux-gnu/libarmnnSerializer.so.26 ./usr/lib/aarch64-linux-gnu/libarmnnAclCommon.so.26 ./usr/lib/aarch64-linux-gnu/libarmnn.so.26.0 ./usr/lib/aarch64-linux-gnu/libarmnnAclCommon.so.26.0 ./usr/lib/aarch64-linux-gnu/libarmnnTfLiteParser.so.24.2 ./usr/lib/aarch64-linux-gnu/libarmnnTfLiteParser.so.24 ./usr/lib/aarch64-linux-gnu/libarmnnDeserializer.so ./usr/lib/aarch64-linux-gnu/libarmnnSerializer.so ./usr/lib/aarch64-linux-gnu/libarmnn.so

Could you check if the upstream package has missed out that file? Thanks.

MikeJKelly commented 2 years ago

Hi @sdavejones

Sorry for the delay, I think the best thing to do is to try:

sudo apt install software-properties-common
sudo add-apt-repository ppa:armnn/ppa
sudo apt update
sudo apt-get install -y python3-pyarmnn armnn-latest-all

That should download all available armnn libraries for the platform. Please let me know if this works and I'll see if I can get the guide updated.

EDIT: Sorry, @FrancisMurtagh-arm just pointed out that the missing ONNX parser is a red herring as you are trying to run on a TFLite file and so you don't need the ONNX parser (pyarmnn always gives a warning about the ONNX parser being missing regardless of if it's being used). I'll run through the example here and see if I can figure out why it's giving that error.

Best regards, Mike

MikeJKelly commented 2 years ago

Hi @sdavejones

can you check the size of your tflite_int8/wav2letter_int8.tflite file, it should be about 24MB.

RuntimeError: Buffer doesn't conform to the expected Tensorflow Lite flatbuffers format. size:133 at function LoadModelFromBinary [/build/armnn-9SkJA0/armnn-21.08/src/armnnTfLiteParser/TfLiteParser.cpp:3609]

If it's 133 bytes like this error says then the wav2letter_int8.tflite file only contains the Git LFS (Large File Storage) header and does not contain the actual model. If you open it in an editor then the LFS header will look something like this:

version https://git-lfs.github.com/spec/v1
oid sha256:81ed9280856ca6b2b3db3f822ec7375fd71f89b9c3c7903409d5e7857caf11a7
size 23815520

If your ML-Zoo only contains the headers then you might have missed the section on installing git-lfs at: https://developer.arm.com/documentation/102603/2108/Device-specific-installation/Install-on-Raspberry-Pi

You have to run the following command before you clone the ML-Zoo.

sudo apt-get install git git-lfs
git lfs install --skip-repo

If you can't run those commands for whatever reason you can download the tflite model file directly from: https://github.com/ARM-software/ML-zoo/blob/master/models/speech_recognition/wav2letter/tflite_int8/wav2letter_int8.tflite

Best regards, Mike

MikeJKelly commented 2 years ago

I believe this issue has been resolved. If you have require further help then please reopen this ticket or open another one.