PINTO0309 / onnx2tf

Self-Created Tools to convert ONNX files (NCHW) to TensorFlow/TFLite/Keras format (NHWC). The purpose of this tool is to solve the massive Transpose extrapolation problem in onnx-tensorflow (onnx-tf). I don't need a Star, but give me a pull request.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[docTR] Can it support from ONNX NHWC to TF NHWC?

lieding opened this issue · comments

Issue Type

Others

OS

Linux

onnx2tf version number

1.21

onnx version number

None

onnxruntime version number

None

onnxsim (onnx_simplifier) version number

None

tensorflow version number

2.x

Download URL for ONNX

https://github.com/mindee/doctr

crnn_mobilenet_v3_large.onnx.zip

Parameter Replacement JSON

None

Description

Hello, I want to ask you a simple question, whether this repo supports convert from ONNX NHWC frormat,
Input shape: [dim_param: "unk__1287" , dim_value: 32 , dim_value: 128 , dim_value: 3 ]
to Tensoflow format. This model is from a third-party tensorflow export, but it only supports ONNX export.

I tried following the typical process, but exported input format is always like None, 128, 3, 32, while the expected is like None, 32, 128, 3.

if helphul, this is full code in Colab:

!pip install python-doctr
!pip install tf2onnx

import tensorflow as tf
from doctr.models.recognition import crnn_mobilenet_v3_large
from doctr.models.utils import export_model_to_onnx

model = crnn_mobilenet_v3_large(pretrained=True, exportable=True)
export_model_to_onnx(model, "crnn_mobilenet_v3_large", dummy_input=[tf.TensorSpec([None, 32, 128, 3], tf.float32, name="input")])

!pip install onnx2tf onnx_graphsurgeon onnxsim sng4onnx

!onnx2tf \
-i crnn_mobilenet_v3_large.onnx \
-osd \
--disable_group_convolution

loaded_model = tf.saved_model.load("/content/saved_model")
loaded_model.signatures