onnx2keras
onnx2keras copied to clipboard
KeyError: 'split'
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?
So what I figured out was this:
My model contains 12/13 nodes with * op_type: "Split"* as we can see here:
This triggers this part of the code:
Where node_type, at the end of the image, is split.
This in turn triggers
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.
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.
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
@nerox8664 - any updates on the "split"-nodes?
I am running into this 'KeyError: split' issue too, were you able to find any resolution?
same here
I am running into this 'KeyError: split' issue too, were you able to find any resolution?
me too, did anyone find a solution yet?