首页 > 解决方案 > MaskRCNN TensorFlow Lite 推理问题。TFLite 模型没有输出

问题描述

系统信息

用于运行转换器的命令

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 中没有输出。

分段错误(核心转储)——在命令行中执行时。

失败详情

转换成功。但是模型没有输出。

各位大侠能不能给点思路?我被困在这里,不知道如何继续!

标签: pythontensorflowtensorflow-lite

解决方案


推荐阅读