Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ParSeq] [Error] convert error mismatch after saved_model output complete #436

Closed
ZhanchongDeng opened this issue Jul 31, 2023 · 5 comments
Labels
Environment Environment third party Third-party tool issues

Comments

@ZhanchongDeng
Copy link

ZhanchongDeng commented Jul 31, 2023

Issue Type

Others

OS

OSX

onnx2tf version number

1.15.4

onnx version number

1.14.0

onnxruntime version number

1.15.1

onnxsim (onnx_simplifier) version number

0.4.33

tensorflow version number

2.13.0

Download URL for ONNX

https://drive.google.com/file/d/1qC1EOT5hyiHSjVwFrYFh1318Dbu0ERNN/view?usp=sharing

Parameter Replacement JSON

N/A

Description

  1. Purpose: Product Development
  2. What:
    I was attempting to convert a transformer based model for text recognition from onnx to tensorflow graph def and tflite. The conversion was completed (the mapping from original onnx operations to tensorflow operations is generated), but I got an error on shape mismatch.
    onnx2tf -i parseq-tiny.onnx
loc(fused["AddV2:", callsite("model_292/tf.math.add_137/Add"("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/engine/training.py":569:0) at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), "Const:", callsite("model_292/tf.reshape_100/Reshape/shape"("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/engine/training.py":569:0) at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), "Reshape:", callsite("model_292/tf.reshape_30/Reshape"("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/engine/training.py":569:0) at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), "Squeeze:", callsite("model_292/tf.compat.v1.squeeze_638/Squeeze"("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/engine/training.py":569:0) at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), callsite("model_292/tf.compat.v1.squeeze_413/Squeeze"("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/engine/training.py":569:0) at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/onnx2tf/onnx2tf.py":974:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), callsite("model_292/211706"("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/tensor.py":309:0) at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/tensor.py":269:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/core/function/capture/capture_container.py":279:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/core/function/capture/capture_container.py":137:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/func_graph.py":675:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/ops.py":1337:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/tensor_conversion_registry.py":209:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/tensor_conversion.py":168:0 at callsite("/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/framework/tensor_conversion.py":160:0 at "/Users/zhdeng/Github/str_playground/venv/lib/python3.10/site-packages/tensorflow/python/util/dispatch.py":1176:0)))))))))]): error: 'tfl.reshape' op requires 'output' type 'tensor<1x1x192xf32>' to be cast compatible with expected type 'tensor<192xf32>'

It appears the problem occurs at reshape_30 and reshape_100. So I looked at the output during the conversion, and but can only find an op using the reshape_30 as input, but not where it got outputed:

[32mINFO:�[0m �[35monnx_op_type�[0m: Add�[35monnx_op_name�[0m: /decoder/layers.0/Add_1
�[32mINFO:�[0m �[36m input_name.1�[0m: /decoder/layers.0/Add_output_0 �[36mshape�[0m: [1, 1, 192] �[36mdtype�[0m: float32
�[32mINFO:�[0m �[36m input_name.2�[0m: /decoder/layers.0/cross_attn/Transpose_6_output_0 �[36mshape�[0m: [1, 1, 192] �[36mdtype�[0m: float32
�[32mINFO:�[0m �[36m output_name.1�[0m: /decoder/layers.0/Add_1_output_0 �[36mshape�[0m: [1, 1, 192] �[36mdtype�[0m: float32
�[32mINFO:�[0m �[35mtf_op_type�[0m: add
�[32mINFO:�[0m �[34m input.1.x�[0m: �[34mshape�[0m: (1, 1, 192) �[34mdtype�[0m: float32 
�[32mINFO:�[0m �[34m input.2.y�[0m: �[34mname�[0m: tf.reshape_30/Reshape:0 �[34mshape�[0m: (1, 1, 192) �[34mdtype�[0m: <dtype: 'float32'> 
�[32mINFO:�[0m �[34m output.1.output�[0m: �[34mname�[0m: tf.math.add_137/Add:0 �[34mshape�[0m: (1, 1, 192) �[34mdtype�[0m: <dtype: 'float32'> 

The closest reshape I can find is this reshape block producing reshape_28. Reshape_30 does exist at the end of the table.

tf.reshape_30 (TFOpLambda)               (1, 1, 192)                               0             ['tf.compat.v1.squeeze_413[0][0]']        
tf.math.add_137 (TFOpLambda)             (1, 1, 192)                               0             ['tf.reshape_30[0][0]'] 

I checked reshape_100, similar issue.
3. How:
I tried various release version, but this bug persisted. Because my code actually ran through the conversion step without error, it doesn't seem to be a similar problem to all the ones I saw in closed issue. I can't locate which module to debug because this reshape_30 and reshape_100 doesn't seem to exist on the netron visualization of my onnx model.
4. Why
I need this problem solved to incorporate this text recognition model into our product. While the current model is in pytorch, and torchscript/onnx conversion went smoothly, tensorflow family won't be possible without conversion between onnx to tensorflow.

@PINTO0309
Copy link
Owner

PINTO0309 commented Jul 31, 2023

Cannot be reproduced. I think it is a problem specific to your environment. It looks like a bug in the runtime for OSX. I do not investigate environment-specific issues.

onnx2tf -i parseq-tiny.onnx -cotof -rtpo Erf -coion

image

import numpy as np
import tensorflow as tf

interpreter = tf.lite.Interpreter(model_path="saved_model/parseq-tiny_float32.tflite")
tf_lite_model = interpreter.get_signature_runner()
inputs = {
    'input': np.ones([1,32,128,3], dtype=np.float32),
}
tf_lite_output = tf_lite_model(**inputs)
print("[TFLite] Model Predictions:", tf_lite_output)
[TFLite] Model Predictions: {'output': array([[[-2.389113  ,  5.4571705 ,  7.5741343 , ..., -0.89064467,
         -3.5843592 , -1.2752655 ],
        [ 3.4039326 ,  8.708299  ,  7.338778  , ...,  0.4596727 ,
         -4.1197634 , -1.8351618 ],
        [ 6.263452  ,  6.3937144 ,  5.2301087 , ..., -0.5230702 ,
         -4.6098537 , -3.1251729 ],
        ...,
        [-7.0126133 ,  5.969986  ,  4.7012253 , ..., -1.3481368 ,
         -3.0462472 , -2.8208456 ],
        [-6.380905  ,  5.5801325 ,  4.61361   , ..., -0.9989778 ,
         -3.2501647 , -2.5887609 ],
        [ 8.071988  ,  4.994136  ,  5.3829756 , ...,  2.0848088 ,
         -1.2946823 ,  1.70696   ]]], dtype=float32)}

@PINTO0309 PINTO0309 added third party Third-party tool issues Environment Environment labels Jul 31, 2023
@PINTO0309 PINTO0309 changed the title [Error] convert error mismatch after saved_model output complete [ParSeq] [Error] convert error mismatch after saved_model output complete Aug 1, 2023
@PINTO0309
Copy link
Owner

@ZhanchongDeng
Copy link
Author

I ran the command you post on a fresh ubuntu 20.04 with all the package installed as described in the issue, still got the same exact error. Can you share more about the package version you use?

@PINTO0309 PINTO0309 reopened this Aug 2, 2023
@PINTO0309
Copy link
Owner

PINTO0309 commented Aug 2, 2023

I see. I reproduced it. It appears to be a very specific error pattern.

docker run --rm -it \
-v `pwd`:/workdir \
-w /workdir \
ghcr.io/pinto0309/onnx2tf:1.15.7

pip show tensorflow

Name: tensorflow
Version: 2.13.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, numpy, opt-einsum, packaging, protobuf, setuptools, six, tensorboard, tensorflow-estimator, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wrapt
Required-by: 

onnx2tf -i parseq-tiny.onnx -cotof -rtpo Erf -coion
loc(fused["AddV2:", callsite("model_292/tf.math.add_137/Add"("/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py":569:0) at callsite("/usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), "Const:", callsite("model_292/tf.reshape_100/Reshape/shape"("/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py":569:0) at callsite("/usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), "Reshape:", callsite("model_292/tf.reshape_30/Reshape"("/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py":569:0) at callsite("/usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), "Squeeze:", callsite("model_292/tf.compat.v1.squeeze_632/Squeeze"("/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py":569:0) at callsite("/usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), callsite("model_292/tf.compat.v1.squeeze_407/Squeeze"("/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py":569:0) at callsite("/usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py":65:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/core/function_wrappers.py":113:0 at callsite("/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py":984:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py":41:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py":597:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py":1055:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":305:0 at "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py":398:0))))))))), callsite("model_292/250394"("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/tensor.py":309:0) at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/tensor.py":269:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/core/function/capture/capture_container.py":279:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/core/function/capture/capture_container.py":137:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py":675:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/ops.py":1337:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/tensor_conversion_registry.py":209:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/tensor_conversion.py":168:0 at callsite("/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/tensor_conversion.py":160:0 at "/usr/local/lib/python3.8/dist-packages/tensorflow/python/util/dispatch.py":1176:0)))))))))]): error: 'tfl.reshape' op requires 'output' type 'tensor<1x1x192xf32>' to be cast compatible with expected type 'tensor<192xf32>'
Traceback (most recent call last):
  File "/usr/local/bin/onnx2tf", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py", line 2134, in main
    model = convert(
  File "/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py", line 1072, in convert
    tflite_model = converter.convert()
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/lite.py", line 2105, in convert
    return super(TFLiteConverterV2, self).convert()
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/lite.py", line 1065, in wrapper
    return self._convert_and_export_metrics(convert_func, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/lite.py", line 1042, in _convert_and_export_metrics
    result = convert_func(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/lite.py", line 1717, in convert
    return super(TFLiteFrozenGraphConverterV2, self).convert(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/lite.py", line 1296, in convert
    result = _convert_graphdef(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/convert_phase.py", line 212, in wrapper
    raise converter_error from None  # Re-throws the exception.
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/convert_phase.py", line 205, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/convert.py", line 918, in convert_graphdef
    data = convert(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/lite/python/convert.py", line 367, in convert
    raise converter_error
tensorflow.lite.python.convert_phase.ConverterError: /usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py:569:0: error: 'tfl.reshape' op requires 'output' type 'tensor<1x1x192xf32>' to be cast compatible with expected type 'tensor<192xf32>'
/usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py:65:0: note: called from
/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py:984:0: note: called from
/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/core/function_wrappers.py:113:0: note: called from
/usr/local/lib/python3.8/dist-packages/onnx2tf/onnx2tf.py:984:0: note: called from
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/autograph_util.py:41:0: note: called from
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:597:0: note: called from
/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py:1055:0: note: called from
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:305:0: note: called from
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:398:0: note: called from

There seems to be a bug in Tensorflow v2.13.0. Maybe this is a bug that should be reported as an issue to the official TensorFlow repository.

pip install tensorflow==2.12.0

onnx2tf -i parseq-tiny.onnx -cotof -rtpo Erf -coion

image

@ZhanchongDeng
Copy link
Author

Thank you for the prompt response. I was able to generte the model after downgrading tensorflow. I apologize for not trying with Docker first, it's my 3rd week at work and I am learning as much as I can about Docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Environment Environment third party Third-party tool issues
Projects
None yet
Development

No branches or pull requests

2 participants