0

我已按照链接“https://www.tensorflow.org/lite/guide/python”中给出的程序在我的树莓派中安装 tensorflow lite。但是 .interpreter 和其他类不存在于已安装的包中。

我正在使用 Raspberry-pi 模型 B+ 和 raspberry pi OS(buster)

pi@raspberrypi:~ $ 
pi@raspberrypi:~ $ echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
deb https://packages.cloud.google.com/apt coral-edgetpu-stable main
pi@raspberrypi:~ $ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1974  100  1974    0     0   6902      0 --:--:-- --:--:-- --:--:--  6926
OK
pi@raspberrypi:~ $ sudo apt-get update
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Hit:2 https://packages.cloud.google.com/apt coral-edgetpu-stable InRelease
Hit:3 http://raspbian.raspberrypi.org/raspbian buster InRelease  
Reading package lists... Done
pi@raspberrypi:~ $ sudo apt-get install python3-tflite-runtime
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python3-tflite-runtime
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/2,929 kB of archives.
After this operation, 9,951 kB of additional disk space will be used.
Selecting previously unselected package python3-tflite-runtime.
(Reading database ... 106370 files and directories currently installed.)
Preparing to unpack .../python3-tflite-runtime_2.5.0_armhf.deb ...
Unpacking python3-tflite-runtime (2.5.0) ...
Setting up python3-tflite-runtime (2.5.0) ...
pi@raspberrypi:~ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflite_runtime
>>> dir(tflite_runtime)
['__builtins__', '__cached__', '__doc__', '__file__', '__git_version__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__']
>>> 
  1. 安装过程中还有什么需要注意的吗?
  2. 我已经有了 .tflite 模型。这个装置足以让我进行面部识别吗?
4

1 回答 1

0

它工作正常。仅仅因为导出未在 中列出dir并不意味着它不可调用。许多包用于__getattr__拦截调用,特别是对于包装 C++ 库的包。您甚至没有尝试运行您的代码吗?

C:\tmp>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflite_runtime
>>> dir(tflite_runtime)
['__builtins__', '__cached__', '__doc__', '__file__', '__git_version__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__']
>>> from tflite_runtime.interpreter import Interpreter
>>> dir(tflite_runtime)
['__builtins__', '__cached__', '__doc__', '__file__', '__git_version__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'interpreter', 'tensorflow_wrap_interpreter_wrapper']
>>> Interpreter
<class 'tflite_runtime.interpreter.Interpreter'>
>>>
于 2021-03-15T17:39:51.263 回答