python - MaskRCNN TensorFlow Lite 推理问题。TFLite 模型没有输出
问题描述
系统信息
- 操作系统平台和发行版(Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-1034-azure x86_64)):
- TensorFlow 安装自 (source-Pip Install):
- TensorFlow 版本(2.3.0):
用于运行转换器的命令
converter = tf.lite.TFLiteConverter.from_keras_model(keras_model)
converter.allow_custom_ops = True
converter.experimental_new_converter = True
converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
converter.optimizations = [ tf.lite.Optimize.DEFAULT ]
tflite_model = converter.convert()
链接到 Jupyter notebook 和 tflite 模型
https://drive.google.com/drive/folders/1pTB33fTSo5ENzevobTvuG7hN4YmiCPF_?usp=sharing
用于推理的命令
### Load the TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="model_2.3.tflite")
interpreter.allocate_tensors()
### Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
### Test the model on random input data.
input_data_1 = np.array(np.random.random_sample(input_details[0]['shape']), dtype=np.float32)
input_data_2 = np.array(np.random.random_sample(input_details[1]['shape']), dtype=np.float32)
input_data_3 = np.array(np.random.random_sample(input_details[2]['shape']), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data_1)
interpreter.set_tensor(input_details[1]['index'], input_data_2)
interpreter.set_tensor(input_details[2]['index'], input_data_3)
interpreter.invoke() ---> Kernel is getting stuck here. No output. I am executing the code from jupyter.
转换器调用的输出
Jupyter 中没有输出。
分段错误(核心转储)——在命令行中执行时。
失败详情
转换成功。但是模型没有输出。
各位大侠能不能给点思路?我被困在这里,不知道如何继续!
解决方案
推荐阅读
- c# - 无法将类型为“<>f__AnonymousType5`3[System.String,System.String,System.String]”的对象转换为类型“System.Data.DataRowView”。
- javascript - 如何让 JSON 解析包含单引号的 JSON 字符串
- asp.net-web-api - 如何检索我的 api 的所有已实现版本的列表?
- python-3.x - Python 3:PyCharm 中未使用局部变量“xyz”值警告
- javascript - 我在为 Android 构建 quasar 项目时遇到问题
- python - Keras 中的多通道 CNN-LSTM
- java - 如何单独测试作为 oozie 工作流程(带有文件标签)的一部分的 hadoop MapReduce java 操作?
- reactjs - React 钩子不会在状态更新时重新渲染
- amazon-web-services - aws 胶水 rds 增量负载
- bash - 为每个用户目录创建一个文件并将 Grep 输出附加到每个用户文件