onnx2keras icon indicating copy to clipboard operation
onnx2keras copied to clipboard

KeyError: 'split'

Open SelComputas opened this issue 4 years ago • 7 comments

I am trying to convert a ONNX file to Keras using this onnx2keras functionality: k_model = onnx_to_keras(model, ['data'])

But I get an error message saying:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\onnx2keras\converter.py in onnx_to_keras(onnx_model, input_names, input_shapes, name_policy, verbose, change_ordering) 178 lambda_funcs, 179 node_name, --> 180 keras_names 181 ) 182

~\AppData\Local\Continuum\anaconda3\lib\site-packages\onnx2keras\operation_layers.py in convert_split(node, params, layers, lambda_func, node_name, keras_names) 211 212 input_0 = ensure_tf_type(layers[node.input[0]], name="%s_const" % keras_names[0]) --> 213 splits = params["split"] 214 axis = params.get("axis", 0) 215 if not isinstance(splits, Iterable):

KeyError: 'split'

Anybody have any tips?

SelComputas avatar May 19 '20 09:05 SelComputas

So what I figured out was this: My model contains 12/13 nodes with * op_type: "Split"* as we can see here: image This triggers this part of the code: image Where node_type, at the end of the image, is split.

This in turn triggers image But as you can see from the first image, the node does not have any split parameter, which is the reason we get this error.

Tried solutions

So I tried to find some solutions such as finding an example of how values for this Split would look by accessing ONNX's model zoo: https://github.com/onnx/models#image_classification. I tried with 3 models:

  • mobilenetv2-7
  • squeezenet1.0-9
  • shufflenet-v2-10

And to my surprise only the mobilenet one worked - the other two returned different errors: squeezenet: ValueError: name for name_scope must be a string. shufflenet: ValueError: The channel dimension of the inputs should be defined. Found None.

So the mobilenet worked, but it does not contain any Split notes, making it pretty much useless for me, for information about my problem.

SelComputas avatar May 20 '20 09:05 SelComputas

Hello @SelComputas. I fixed problems related to Squeezenet (you can get latest changes from github, master branch). There was a problem with Dropout (in ONNX it returns not only operation result but mask as well).

Unfortunately, Shufflenet is quite more complex (they split channels and concat into new axes, it always causes problems, I will take a look but later.

gmalivenko avatar May 20 '20 13:05 gmalivenko

Thank you @nerox8664!

To move on in my project I require a fix on the split channels, as seen in the first post, so fingers crossed

SelComputas avatar May 20 '20 13:05 SelComputas

@nerox8664 - any updates on the "split"-nodes?

SelComputas avatar Jun 02 '20 07:06 SelComputas

I am running into this 'KeyError: split' issue too, were you able to find any resolution?

k-macdonald avatar Mar 01 '21 23:03 k-macdonald

same here

hiskuDN avatar Feb 15 '23 06:02 hiskuDN

I am running into this 'KeyError: split' issue too, were you able to find any resolution?

me too, did anyone find a solution yet?

timoffenhaeusser avatar Jan 23 '24 08:01 timoffenhaeusser