Tensorflow Lite tflite 进程已完成,退出代码为 -1073741819

Tensorflow Lite tflite Process finished with exit code -1073741819

发布一个我花了一段时间才弄清楚但在搜索时找不到的问题,希望这能帮助其他人节省时间。

调用 set.tensor 时程序崩溃并返回响应进程已完成,退出代码为 -1073741819

interpreter = tf.lite.Interpreter(model_path="....")
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
interpreter.set_tensor(input_details[0]['index'],image_for_input )
interpreter.invoke()

在调用 set_tensor 之前需要先调用 allocate_tensors

interpreter = tf.lite.Interpreter(model_path="....")
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

interpreter.allocate_tensors()

interpreter.set_tensor(input_details[0]['index'],image_for_input )
interpreter.invoke()