错误是按照此处Kernal Restarting: The kernel appears to have died. It will restart automatically.
提到的步骤进行操作。内核在执行时崩溃- 在下面的代码中。interpreter.invoke()
我正在使用 Tensorflow 1.14.0 通过 Jupyter Notebook 运行代码
编辑 1:当我为二进制分类模型的 .tflite 文件运行相同的代码时,它工作正常。
interpreter = tf.lite.Interpreter(model_path=PATH_TO_MODEL)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Load image for testing
image = cv2.imread(os.path.join(os.getcwd(),IMAGE_NAME))
input_data_f32 = np.array(image, dtype=np.float32)
input_data = np.expand_dims(input_data_f32, axis=0)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])