Raspberry Pi 3B +上的Tensorflow Lite Python绑定

Sudhar San

我正在尝试使用Tensorflow Lite Python解释器在树莓派3B +中进行对象检测

from tensorflow.contrib.lite.python import interpreter as interpreter_wrapper

但是当我运行这条线时 interpreter=interpreter_wrapper.Interpreter(model_path="mobilenet.tflite")

我收到此错误:

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
interpreter = interpreter_wrapper.Interpreter(model_path="mobilenet.tflite")
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/lite/python/interpreter.py", line 50, in __init__ 
_interpreter_wrapper.InterpreterWrapper_CreateWrapperCPPFromFile(
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/lazy_loader.py", line 53, in __getattr__
module = self._load()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/lazy_loader.py", line 42, in _load
module = importlib.import_module(self.__name__)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/lite/python/interpreter_wrapper/tensorflow_wrap_interpreter_wrapper.py", line 28, in <module>
_tensorflow_wrap_interpreter_wrapper = swig_import_helper()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/lite/python/interpreter_wrapper/tensorflow_wrap_interpreter_wrapper.py", line 24, in swig_import_helper
_mod = imp.load_module('_tensorflow_wrap_interpreter_wrapper', fp, pathname, description)
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 914, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/lite/python/interpreter_wrapper/_tensorflow_wrap_interpreter_wrapper.so: undefined symbol: _ZN6tflite12tensor_utils39NeonMatrixBatchVectorMultiplyAccumulateEPKfiiS2_iPfi

如果有人尝试过此操作,请帮助我修复此错误

谢谢

阿尔瓦罗·马丁

这是使用TensorFlow v1.14或更低版本运行TensorFlow Lite时发生的错误。要解决该错误,我们可以卸载常规的TensorFlow,然后使用Google提供的tflite_runtime软件包。

首先,我描述我的环境:

  • Raspberry Pi 3B +型。
  • Raspbian作业系统。
  • 我正在一个名为“ Project”的文件夹中工作。
  • 在此文件夹中,我使用virtualenv在名为“ Project-env”的文件夹中创建了一个隔离环境。
  • 我在raspberry pi中的python项目具有此组件“将tensorflow导入为tf”,这导致了错误。

当我使用tensorflow在Google Colab中构建模型时,至少在我的程序中不必在这里使用它。

  • 因此,首先进入您的工作文件夹:在我的情况下为“ cd Project”。
  • 然后激活您的环境:就我而言,为“ source Project-env / bin / activate”。
  • 卸载tensorflow:“ pip3卸载tensorflow”。
  • 掌握这个方向:“ wget https://dl.google.com/coral/python/tflite_runtime-1.14.0-cp35-cp35m-linux_armv7l.whl”,适用于Raspberry Pi 3B +模型。
  • 现在安装轮子:“ pip3 install tflite_runtime-1.14.0-cp35-cp35m-linux_armv7l.whl”。
  • 最后,在您的python程序中,删除此行“将tensorflow导入为tf”,并将其替换为“ from tflite_runtime.interpreter import Interpreter”。

因此,不要使用“ interpreter = tf.lite.Interpreter(modelpath)”,而应使用此“ interpreter = Interpreter(modelpath)”。

就这样。感谢EdjeElectronics帮助我解决了这个问题。此处是其YouTube频道:https//www.youtube.com/watch?v = aimSGOAUI8Y&t = 26s

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Python:OSError:[Errno -9985]在Raspberry PI 3B +上使用Snowboy和SpeechRecognition时设备不可用

如何使用Raspbian Stretch在Raspberry Pi 3B上设置默认麦克风?

尝试在Raspberry Pi 3B上运行Lancache时出现“内存不足” Nginx错误

为什么在Raspberry Pi 3B +上Ubuntu 19.10这么慢

带有Lavaplayer的JDA Discord Bot在Raspberry Pi 3B +(Raspbian)上无法正常工作

带有Lavaplayer的JDA Discord Bot在Raspberry Pi 3B +(Raspbian)上无法正常工作

通过Raspberry Pi 3B上的串行端口访问传感器

SSID在Android Things(Raspberry Pi 3B)上不可见

Raspberry Pi 3B +上的scons和w281x的Yocto配方问题

使用Ubuntu ARM64的Raspberry Pi 3B +上没有网络

Raspberry Pi3上的Tensorflow 1.5

Raspberry Pi上的Tensorflow

如何获得Raspberry Pi的TensorFlow C绑定?

Raspberry Pi上的Python延迟

在运行Android的Raspberry Pi 3上配置Python 3

Raspberry Pi上的Numpy导入错误Python3?

在Raspberry Pi上使用python 3安装Spyder

在Raspberry Pi 3,Python 3.4上运行Scrapy

在Centos7 Raspberry Pi上安装Python3

在MacBook上为Raspberry Pi 3构建Python平台轮

无法使用UBoot + Grub从USB驱动器引导raspberry pi 3b

将Raspberry Pi 3B +(Raspian Stretch)变成蓝牙耳机(HSP)

使用 pip 错误安装 matplotlib(使用 raspberry pi 3b)

错误!在raspberry Pi 3型号b上安装节点serialPort

Raspberry Pi Zero上的Python非法指令

Raspberry Pi 3上的QML性能

Raspberry Pi 3 b +视频流至Python GUI

使用 Raspbian Lite 在 Raspberry Pi 上运行您的应用程序

Raspberry Pi3 Mysql Python错误