模型保存时没有错误
tflite_model = converter.convert()
当我执行这一行时,我得到了以下异常
ConverterError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/convert.py in toco_convert_protos(model_flags_str, toco_flags_str, input_data_str, debug_info_str, enable_mlir_converter)
295 return model_str
296 except Exception as e:
--> 297 raise ConverterError(str(e))
298
299 if distutils.spawn.find_executable(_toco_from_proto_bin) is None:
ConverterError: <unknown>:0: error: loc("head/predictions/str_classes"): 'tf.AsString' op is neither a custom op nor a flex op
<unknown>:0: error: failed while converting: 'main': Some ops in the model are custom ops, See instructions to implement custom ops: https://www.tensorflow.org/lite/guide/ops_custom Custom ops: AsString
Details: tf.AsString(tensor<?x1xi64>) -> (tensor<?x1x!tf.string>) : {device = "", fill = "", precision = -1 : i64, scientific = false, shortest = false, width = -1 : i64}
我尝试使用TensorFlow的每日版本,但错误仍然存在。我正在尝试使用TensorFlow构建一个分类模型,然后我想将其转换为TensorFlow Lite以用于Android应用程序。如果有其他不需要转换为TensorFlow Lite的方法,那也是可以接受的
回答:
TFLite产品中的TF选择选项目前还不支持tf.AsString
操作。对于这种情况,您可以在这里报告功能请求。
上述操作未包含在TF选择的允许列表中,可以通过添加类似于这个提交的相关代码来修复。如果您能创建这样的拉取请求,那就太好了。
修复已提交,AsString操作将从明天的TensorFlow每日版本开始通过TF选择选项可用。