如何转换 tf2 模型,使其在 tflite 解释器上 运行
How to convert tf2 model so it will run on tflite interpreter
背景:
我正在尝试从官方 tf zoo 转换 SSD MobileNet V2 FPNLite 320x320(例如)的 tf2 模型。该模型最终应该 运行 raspberry pi,所以我希望它在 tflite 解释器(没有完整的 tf)上 运行。文档暗示支持ssd模型转换。
发生了什么:
该过程在 this colab notebook 中有详细说明。它因错误而失败:
ConverterError: <unknown>:0: error: loc(callsite(callsite("Postprocessor/BatchMultiClassNonMaxSuppression/MultiClassNonMaxSuppression/SortByField_1/Size@__inference___call___23519" at "StatefulPartitionedCall@__inference_signature_wrapper_25508") at "StatefulPartitionedCall")): 'tf.Size' op is neither a custom op nor a flex op
<unknown>:0: note: loc("StatefulPartitionedCall"): called from
<unknown>:0: error: failed while converting: 'main': Ops that can be supported by the flex runtime (enabled via setting the -emit-select-tf-ops flag):
tf.Size {device = ""}
如果我添加标志 tf.lite.OpsSet.SELECT_TF_OPS,它可以工作,但不会在 rpi 上 运行,因为它没有操作。
这能做到吗?有人成功了吗?
由于 TF.Size 在 TFLite 上不受原生支持,您可以使用 TF Select 模式,该模式回退到 TF 以获取缺少的操作,在转换过程中使用“SELECT_TF_OPS”启用你试过了
当您 运行 推理时,您将需要使用链接了 Select 操作的解释器。
请参阅 guide 关于 运行ning 的推理。
背景: 我正在尝试从官方 tf zoo 转换 SSD MobileNet V2 FPNLite 320x320(例如)的 tf2 模型。该模型最终应该 运行 raspberry pi,所以我希望它在 tflite 解释器(没有完整的 tf)上 运行。文档暗示支持ssd模型转换。
发生了什么: 该过程在 this colab notebook 中有详细说明。它因错误而失败:
ConverterError: <unknown>:0: error: loc(callsite(callsite("Postprocessor/BatchMultiClassNonMaxSuppression/MultiClassNonMaxSuppression/SortByField_1/Size@__inference___call___23519" at "StatefulPartitionedCall@__inference_signature_wrapper_25508") at "StatefulPartitionedCall")): 'tf.Size' op is neither a custom op nor a flex op
<unknown>:0: note: loc("StatefulPartitionedCall"): called from
<unknown>:0: error: failed while converting: 'main': Ops that can be supported by the flex runtime (enabled via setting the -emit-select-tf-ops flag):
tf.Size {device = ""}
如果我添加标志 tf.lite.OpsSet.SELECT_TF_OPS,它可以工作,但不会在 rpi 上 运行,因为它没有操作。
这能做到吗?有人成功了吗?
由于 TF.Size 在 TFLite 上不受原生支持,您可以使用 TF Select 模式,该模式回退到 TF 以获取缺少的操作,在转换过程中使用“SELECT_TF_OPS”启用你试过了 当您 运行 推理时,您将需要使用链接了 Select 操作的解释器。 请参阅 guide 关于 运行ning 的推理。