我已将模型转换为tensorflow-lite,但在编译时出现以下错误:
这是我的代码:
interpreter = tf.contrib.lite.Interpreter(model_path= "/mnt/ficusspain/cqli/tensorflow_models/Quantized_Models/mobilenet_v1_0.25_128_quant/mobilenet_v1_0.25_128_quant.tflite")
interpreter.allocate_tensors()
print("can we get here?")
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
print("can we get here")
# Test model on random input data.
input_shape = input_details[0]['shape']
print(input_shape)
print(input_details[0]['index'])
print(output_details[0]['index'])
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
您需要将数据类型从 np.float32 更改为 np.uint8:
input_data = np.array(np.random.random_sample(input_shape), dtype=np.uint8)
您可以随时查看
print(interpreter.get_input_details())
需要哪种数据类型
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)