I finally managed to install tensorflow lite incl. opencv on my raspberry pi zero w (v.1.1) with bullseye OS and python3. When I try to run the example recommended on this site for Raspberry PI (called classify.py) but also when I try to run the example label_image.py I get an error message “illegal instruction”, with no further details.
Through the use of print statements in the python files, I manage to narrow it down to the statement
“from tflite_runtime.interpreter import Interpreter”. That is when the error occurs (in the file image_classifier.py)
When I type this import statement manually at a python prompt, I also get the same error message.
I have a suspicion that the PI Zero is just not suitable to run tf lite due to limited processor capabilities? Is that correct? Do I need a more powerful Raspberry PI?
Or is there another explanation (or even better: a solution!) ? How can I debug further?
In the end, my goal is to do some object recognition to control the direction of a small robot.
" import tflite_runtime" does not trigger an error
" import tflite_runtime.interpreter" does trigger the same error as reported in the original post above
so, with some further research. it looks to be an error related to namespaces (but I am not an expert in how to use the import statements)
Could it be because I installed opencv separately before running the tensorflow lite installation instructions (which also seems to install opencv in the setup.sh shell script)?
I’ll start from scratch (again, already spent 3 days …) but I hope someone can shed some light on this issue.
This allows for running TF-Lite models on a RaspberryPi Zero using the Tensorflow-Lite Micro (TFLM) interpreter.
This provides the Python package:tflite_micro_runtime which uses the same API as tflite_runtime. The main difference is tflite_micro_runtime uses the Tensorflow-Lite Micro interpreter instead of the Tensorflow-Lite interpreter.
Using the Tensorflow-Lite Micro (TFLM) interpeter provides ~8x improvement on inference time.
TFLM provides a speedup because it uses the ARM CMSIS NN library which is optimized for ARMv6 processor that RPI0 uses. The RPI0’s ARMv6 processor does not have a GPU or other hardware optimizations so can not leverage any of the features that come with the tflite_runtime library. Thus the tflite_micro_runtime library is faster on the RPI0 but not other Raspberry PIs that do feautre a GPU.