I am trying to run the below TensorFlow demo on my Raspberry Pi. https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/raspberry_pi
I recently re-imaged my Raspberry Pi in order to upgrade to the Bullseye Raspberry Pi operating system (in order to solve this problem).
Based on one of TensorFlow's YouTube tutorials (link below), I tried to install the necessary Python libraries using the commands: pip install tflite-support pip install opencv-python
Both of those commands result in a bunch of "Requirement already satisfied: ..." messages, which I take it is a green light to proceed to the next step (perhaps I had already recently installed these packages).
The next commands are as follows, where the setup script is said to install required dependencies and download the tflite models:
cd examples/lite/examples/object_detection/raspberry_pi
sh setup.sh
These seem to run fine, again giving me a bunch of "Requirement already satisfied: ..." messages and a line that says "Successfully installed argparse-1.4.0". There do not appear to be any errors at this point.
Finally, the error, when I try to run the program itself. Here is the full command and output. It would appear that it wants me to have GLIBCXX_3.4.29, and as I show below I believe I only have GLIBCXX_3.4.28.
andrew@raspberrypi:~/Projects/examples/lite/examples/object_detection/raspberry_pi $ python3 detect.py \
> --model efficientdet_lite0.tflite
Traceback (most recent call last):
File "/home/andrew/Projects/examples/lite/examples/object_detection/raspberry_pi/detect.py", line 20, in <module>
from tflite_support.task import core
File "/home/andrew/.local/lib/python3.9/site-packages/tflite_support/__init__.py", line 48, in <module>
from tensorflow_lite_support.metadata.python import metadata
File "/home/andrew/.local/lib/python3.9/site-packages/tensorflow_lite_support/metadata/python/metadata.py", line 30, in <module>
from tensorflow_lite_support.metadata.cc.python import _pywrap_metadata_version
ImportError: /lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/andrew/.local/lib/python3.9/site-packages/tensorflow_lite_support/metadata/cc/python/_pywrap_metadata_version.so)
And I believe that it is correct that I do not have GLIBCXX_3.4.29, as I have confirmed based on the following command / output:
andrew@raspberrypi:~/Projects/examples/lite/examples/object_detection/raspberry_pi $ strings /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_DEBUG_MESSAGE_LENGTH
A few specific questions:
Thanks everyone!
Link to YouTube tutorial (the point indicating how to install necessary packages): https://www.youtube.com/watch?v=Lyh84KMqUPI&t=230s
(Note: I had previously tried to install a newer version of GCC from source code but ran into issues and decided to reconsider whether it was necessary. Like I said above, I am surprised the tutorial from TensorFlow seems to leave out this sticky little complication.)
I found a solution. It's maybe not 100% satisfying, but the solution is to downgrade the version of tflite_support
package to 0.4.3, which I guess doesn't use GLIBCXX_3.4.29.
There's a thread on exactly this issue on a Raspberry Pi forum: https://forums.raspberrypi.com/viewtopic.php?t=353534
Also explained here at Stack Overflow: How to resolve 'ImportError: /lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.29' not found ' in raspberry pi Bullseye
I now have the object classification demo below working (boxes objects it recognizes) on my pi. It's gets a lot of objects wrong, but it's at least running and boxing objects with some success. =) https://github.com/raspberrypi/picamera2/tree/main/examples/tensorflow (real_time_with_labels.py)