Error running example "Deploy Semantic Segmentation Application Using TensorFlow Lite..."

Hi,
I am trying to run the MATLAB example "Deploy Semantic Segmentation Application Using TensorFlow Lite" but encountered errors. The example was opened by
openExample('deeplearning_shared/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample')
I am using a Raspberry pi 4b, flashed with image mathworks_raspbian_DL_R22.2.0. Everything worked fine (the MEX file was generated on the host computer, and Raspberry pi was connected successfully) until code line 28, when attempting to generate a PIL MEX function:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,'single')
where the code returns error messages. The first few lines of the error message reads:
---------------------------------------
Error executing command "touch -c /home/pi/MATLAB_ws/R2024b/C/Users/phn/Documents/MATLAB/Examples/R2024b/deeplearning_shared/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/pi/MATLAB_ws/R2024b" LINUX_TARGET_LIBS_MACRO="" -C /home/pi/MATLAB_ws/R2024b/C/Users/phn/Documents/MATLAB/Examples/R2024b/deeplearning_shared/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict". Details:
STDERR: In file included from /home/pi/MATLAB_ws/R2024b/C/Program_Files/MATLAB/R2024b/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/pi/MATLAB_ws/R2024b/C/Program_Files/MATLAB/R2024b/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16:10: fatal error: kernels/register.h: No such file or directory
#include "kernels/register.h"
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs....
---------------------------------------
The complete error message is attached.
Could anyone let me know how to fix this? Seems that the file kernels/register.h is missing, but I'm not sure how to fix this. Installing kernel headers on Raspberry Pi through "sudo apt install linux-headers-rpi" did not solve the problem.
Thank you!

 Respuesta aceptada

Hi @Peng,
By looking at the error, it seems like the Third-Party Prerequisite "TFLite library on the target ARM® hardware" is not properly installed.
Please refer to the below links which mentions the Third-Party Prerequisites required for running the example mentioned in the question.
For properly installing "TensorFlow Lite", please look into the below "MATLAB Answers" link.
If you have already installed it, please try reinstalling the library.
Hope you find this information helpful!

3 comentarios

I really appreciate your reply! The links are very useful. I didn't realize that Tensorflow lite needed to be installed on the windows computer.
I am trying to build the TFLite library on windows and encountered some errors where Bazel couldn't find the VC build tools (see detailed error message at the end). At this point this has become a Bazel problem and is not a MATLAB issue anymore, so I will seek help from the Bazel community.
In case anyone knowns how to resolve this, here is the error I encountered when I tried to run the bazel build command (bazel build -c opt //tensorflow/lite:tensorflowlite.dll):
"Visual C++ build tools seems to be installed at C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC
But Bazel can't find the following tools:
VCVARSALL.BAT, cl.exe, link.exe, lib.exe, ml64.exe
for x64 target architecture"
Thank you!
I somehow found a solution to my own problem. It was indeed a compatibility issue between VC and Bazel. When I reinstalled Bazel with version 6.3.0, the error disappeared and I could build tensorflow lite with Bazel without error. Older or newer version of Bazel did not work for me.
Good to know that the issue is resolved now! Thanks for sharing the update.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2024b

Preguntada:

el 8 de En. de 2025

Comentada:

el 20 de En. de 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by