Raspberry Pi运行TensorFlow Lite Python object detection example

原帖地址:

https://github.com/figosoar/examples/tree/master/lite/examples/object_detection/raspberry_pi

但初学者可能会遇到各种环境问题,比如Python,pip问题

如果python3.5,系统可能提升无法装pip,需要升级到python3.7

curl -O https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz

tar -xf Python-3.7.3.tar.xz

cd Python-3.7.3

./configure --with-ssl

make

sudo make altinstall

这里一定要带上编译参数--with-ssl,该参数是编译python是加入SSL,如果没有在使用pip3时会报错SSL有问题

altinstall意思是不覆盖原来系统中的python版本。如果覆盖会出现终端打不开等一些问题。

安装pip

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py   # 下载安装脚本
$ sudo python get-pip.py    # 运行安装脚本

修改setup.sh中

python3 -m pip install -r requirements.txt

改为

python -m pip install -r requirements.txt

setup.sh中tflite模型和推理文件需要科学下载后,拷贝到服务器中来

scp D:\test\efficientdet_lite0_edgetpu_metadata.tflite  username@ipaddress:/home/username/dev

然后分别给其改名字,分别改成 efficientdet_lite0.tflite, efficientdet_lite0_edgetpu.tflite

接下来运行案例,会报下面的问题,以及提示没有tensorflow

ImportError: libGL.so.1: cannot open shared object file: No such file or directory
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

解决方法

sudo apt install libgl1-mesa-glx
sudo apt-get install libatlas-base-dev

还会出现类似问题

ModuleNotFoundError: No module named 'tensorflow'

可以使用类似上一步的解决方法,也可以尝试安装tflite_interpreter。

参见:

https://blog.csdn.net/weixin_29924243/article/details/113646743

https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python

Python pip 安装与使用 | 菜鸟教程

猜你喜欢

转载自blog.csdn.net/figosoar/article/details/120969873