AttentionOCR в ONNX
Есть проблема с конвертацией модели из TF1 в ONNX. Модель у меня в формате SavedModel. Вот сама модель.
Это код, который я использовал для конвертации.
import tensorflow as tf
import tf2onnx
saved_model_dir = "convert/aocr-model"
onnx_model_path = "aocr_model.onnx"
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
tf.compat.v1.saved_model.loader.load(sess, ["serve"], saved_model_dir)
sess.run(tf.compat.v1.global_variables_initializer())
output_node_names = ["prediction", "probability"]
frozen_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(
sess,
sess.graph_def,
output_node_names
)
input_names = ["input_image_as_bytes:0"]
output_names = ["prediction:0", "probability:0"]
onnx_model = tf2onnx.convert.from_graph_def(
frozen_graph_def,
input_names=input_names,
output_names=output_names,
output_path=onnx_model_path
)
print(f"{onnx_model_path}")
Ошибка, которая возникает:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 'cond/ExpandDims' has an _output_shapes attribute inconsistent with the GraphDef for output #0: Shapes must be equal rank, but are 1 and 0
Использовал tf2onxx и пробовал MO от OpenVino (т.к. там был официальный гайд).
По ссылке, которую я приложил можно скачать frozen_graph.
Спасибо заранее!