Tensorflow 到 Tensorflow-lite 的转换

Tensorflow to Tensorflow-lite conversion

我正在尝试移植一些代码以在 Raspberry Pi 上运行。此代码使用 Tensorflow,但仅用于三个功能。

from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model

Instructions 说简单导入:

import tflite_runtime.interpreter as tflite

preprocess_inputimg_to_arrayload_model 函数在 tensorflow-lite 中可用吗?如果是,我如何访问它们?如果否,是否有解决方法?

简短的回答是否定的,它们不可用。 在大多数情况下,TFlite 是一种针对各种硬件上的训练模型优化为 运行 inference 的工具。 如果您想在 RaspberryPi 上使用 运行 TensorFlow and/or Keras,请考虑 build it (or use prebuild) 并像在工作站上一样使用。