tensorflow - 模块未找到错误: No module named 'tflite_support.metadata_writers'

标签 tensorflow model metadata object-detection tensorflow-lite

from tflite_support.metadata_writers import object_detector
from tflite_support.metadata_writers import writer_utils
from tflite_support import metadata

ObjectDetectorWriter = object_detector.MetadataWriter
_MODEL_PATH = "mobile.tflite"
_LABEL_FILE = "labelmap.txt"
_SAVE_TO_PATH = "detect_metadata.tflite"

writer = ObjectDetectorWriter.create_for_inference(
    writer_utils.load_file(_MODEL_PATH), [127.5], [127.5], [_LABEL_FILE])
writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)

# Verify the populated metadata and associated files.
displayer = metadata.MetadataDisplayer.with_model_file(_SAVE_TO_PATH)
print("Metadata populated:")
print(displayer.get_metadata_json())
print("Associated file(s) populated:")
print(displayer.get_packed_associated_file_list())

我使用来自 Github 链接的代码:https://github.com/tensorflow/tensorflow/issues/43775

但是这段代码是一个错误。下面是运行上面代码后的错误。


ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-87-39fd915e7a2a> in <module>()

---->     1 from tflite_support.metadata_writers import object_detector
          2 from tflite_support.metadata_writers import writer_utils
          3 from tflite_support import metadata
          4 
          5 ObjectDetectorWriter = object_detector.MetadataWriter

ModuleNotFoundError:没有名为“tflite_support.metadata_writers”的模块

注意:如果您的导入由于缺少软件包而失败,您可以 使用 !pip!apt 手动安装依赖项。

要查看安装一些常见依赖项的示例,请单击 "Open Examples"下面的按钮。

如何修复此错误?

最佳答案

您必须通过安装

!pip install tflite_support

这仅在夜间( https://github.com/tensorflow/tensorflow/issues/26422 )中受支持,因此通过安装

!pip install tflite_support_nightly

关于tensorflow - 模块未找到错误: No module named 'tflite_support.metadata_writers' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67483995/

相关文章:

python - Levenberg-Marquardt 优化算法的 keras 实现作为自定义优化器

python - Keras:CNN 模型没有学习

php - 讨论 MySQL 数据库结构

json - 使用 Swagger/OpenAPI 扩展 JSON 元数据

c# - 找不到 VS 2017 元数据文件 '.dll

python - 如何使用 TensorFlow 数据集获取 Omniglot 数据对

python - Numpy 索引赋值的 Tensorflow 等价物

php - 使用 CakePHP 触发模型验证

php - Yii2:如何检查 activeRecord 模型是否为空

php - 如何缓存 PHP 生成的动态页面并包含开放图形元信息