Tensorflow Lite 模型可以用于 Windows 10 的推理吗?
Can Tensorflow Lite models be used for inference on Windows 10?
我将现有的 SavedModel 转换为 TFLite:
model = tf.keras.models.load_model("/path/to/original_model")
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open("/path/to/optimized_model.tflite", 'wb') as f:
f.write(tflite_model)
并尝试加载它:
interp = tf.lite.Interpreter(model_path="/path/to/optimized_model.tflite")
my_signature = interp.get_signature_runner()
之后我得到这个错误:
ValueError: SignatureDef method_name is None and model has 0 Signatures. None is only allowed when the model has 1 SignatureDef
我是不是做错了什么?
运行 Windows 10 与 TF2.5.
在 TensorFlow 2.5 版本中,只有从 from_saved_model
API 转换而来的模型才会有签名。
我将现有的 SavedModel 转换为 TFLite:
model = tf.keras.models.load_model("/path/to/original_model")
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open("/path/to/optimized_model.tflite", 'wb') as f:
f.write(tflite_model)
并尝试加载它:
interp = tf.lite.Interpreter(model_path="/path/to/optimized_model.tflite")
my_signature = interp.get_signature_runner()
之后我得到这个错误:
ValueError: SignatureDef method_name is None and model has 0 Signatures. None is only allowed when the model has 1 SignatureDef
我是不是做错了什么?
运行 Windows 10 与 TF2.5.
在 TensorFlow 2.5 版本中,只有从 from_saved_model
API 转换而来的模型才会有签名。