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

ONNX conversion error #138

Open
benschreiber opened this issue Jun 19, 2019 · 4 comments
Open

ONNX conversion error #138

benschreiber opened this issue Jun 19, 2019 · 4 comments

Comments

@benschreiber
Copy link

I am attempting to convert this model to ONNX using the tf2onnx tool. The tool can take a frozen graph or saved model as input and produce an ONNX file. Unfortunately, it fails on aocr, apparently to due the graph being invalid.

I am filing the issue here and not against tf2onnx because the error occurred in Tensorflow while attempting to import the graph that aocr export produced. Here is the error:

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

To reproduce:

aocr export --format=frozengraph ./exported-model
python -m tf2onnx.convert --input=exported-model/frozen_graph.pb --outputs prediction:0 --inputs input_image_as_bytes:0

alternatively,

aocr export ./exported-model
python -m tf2onnx.convert --saved-model=exported-model
@emedvedev emedvedev changed the title Exported model inconsistent ONNX conversion error Jul 3, 2019
@emedvedev
Copy link
Owner

emedvedev commented Jul 3, 2019

What you could try to do is remove the conditional statement on L117-121 of model.py and using self.img_pl directly in the map argument on L122: the cond statement is responsible for converting the input to the same shape no matter if it's a single image or an array of images. Removing the statement will only make the model accept an array, but on the flip side, the conversion to ONNX might work.

@mialo-tech
Copy link

I have done the steps as you mentioned but now I'm getting another error

ValueError: slice index 0 of dimension 0 out of bounds. for 'map/strided_slice' (op: 'StridedSlice') with input shapes: [0], [1], [1], [1] and with computed input tensors: input[1] = <0>, input[2] = <1>, input[3] = <1>.

@Nateliu712
Copy link

@mialo-tech I meet the same question. Do you fix the problem?

@mialo-tech
Copy link

@mialo-tech I meet the same question. Do you fix the problem?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants