PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.49k stars 566 forks source link

I try to convert intel's Handwritten Text Recognition Demo but I met a error #340

Closed jprorikon closed 1 year ago

jprorikon commented 1 year ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

TensorFlow.js

Model name and Weights/Checkpoints URL

https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/handwritten_text_recognition_demo/python

Description

With the latest version of openvino2tensorflow, I can not convert Handwritten-japanese-recognition-0001.xml with --weight_replacement_config weights_replacement.json option.

Relevant Log Output

ERROR: Exception encountered when calling layer "tf.linalg.matmul" (type TFOpLambda).

Shape must be at least rank 2 but is rank 1 for '{{node tf.linalg.matmul/MatMul}} = BatchMatMulV2[T=DT_FLOAT, adj_x=true, adj_y=true](Placeholder, tf.linalg.matmul/MatMul/b)' with input shapes: [1,512,186], [3].

Call arguments received by layer "tf.linalg.matmul" (type TFOpLambda):
  • a=tf.Tensor(shape=(1, 512, 186), dtype=float32)
  • b=array([  1, 512, 186])
  • transpose_a=True
  • transpose_b=True
  • adjoint_a=False
  • adjoint_b=False
  • a_is_sparse=False
  • b_is_sparse=False
  • output_type=None
  • name=None
ERROR: model_path  : handwritten-japanese-recognition-0001.xml
ERROR: weights_path: handwritten-japanese-recognition-0001.bin
ERROR: layer_id    : 76
ERROR: input_layer0 layer_id=74: KerasTensor(type_spec=TensorSpec(shape=(1, 512, 186), dtype=tf.float32, name=None), name='tf.reshape/Reshape:0', description="created by layer 'tf.reshape'")
ERROR: input_layer1 layer_id=75: Const(ndarray).shape  (3,)
array([  1, 512, 186])
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/home/liuzhaoyu/.local/bin/openvino2tensorflow", line 3822, in convert
    tf_layers_dict[layer_id] = tf.linalg.matmul(
  File "/home/liuzhaoyu/.local/lib/python3.10/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/liuzhaoyu/.local/lib/python3.10/site-packages/keras/layers/core/tf_op_layer.py", line 119, in handle
    return TFOpLambda(op)(*args, **kwargs)
  File "/home/liuzhaoyu/.local/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
ValueError: Exception encountered when calling layer "tf.linalg.matmul" (type TFOpLambda).

Shape must be at least rank 2 but is rank 1 for '{{node tf.linalg.matmul/MatMul}} = BatchMatMulV2[T=DT_FLOAT, adj_x=true, adj_y=true](Placeholder, tf.linalg.matmul/MatMul/b)' with input shapes: [1,512,186], [3].

Call arguments received by layer "tf.linalg.matmul" (type TFOpLambda):
  • a=tf.Tensor(shape=(1, 512, 186), dtype=float32)
  • b=array([  1, 512, 186])
  • transpose_a=True
  • transpose_b=True
  • adjoint_a=False
  • adjoint_b=False
  • a_is_sparse=False
  • b_is_sparse=False
  • output_type=None
  • name=None
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

URL or source code for simple inference testing code

No response

PINTO0309 commented 1 year ago

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/055_Handwritten_Japanese_Recognition

PINTO0309 commented 1 year ago

image

PINTO0309 commented 1 year ago

image

onnx2tf -i model_float32.onnx -osd -coion

image

pip install tensorflowjs

onnx2tf -i mobilenetv2-12.onnx -ois input:1,3,224,224 -osd

tensorflowjs_converter \
--input_format tf_saved_model \
--output_format tfjs_graph_model \
saved_model \
tfjs_model

image

image

image