Errors converting PyTorch Unet (“tiramisu”) into coreml, via onnx

半世苍凉 提交于 2019-12-23 04:06:42

问题


I'm trying to convert a pytorch "tiramisu" UNet (from: https://github.com/bfortuner/pytorch_tiramisu) to coreml, via onnx, and I'm getting this error in onnx-coreml's _operators.py:

TypeError: Error while converting op of type: Concat. Error message: Unsupported axis 1 in input of shape

Any thoughts about how I might work around this? The layers file is here, for reference: https://github.com/bfortuner/pytorch_tiramisu/blob/master/models/layers.py

UPDATE 1: So, digging down further into this, I've noticed that some of my graph.shape_dicts contain keys with no values/shapes: e.g., '422': (1, 324, 2, 4), '423': (1, 324, 2, 4), '424': (1, 12, 2, 4), '425': (1, 48, 2, 4), '426': (), '427': (), '428': (), '429': (), '430': () [...]

I'm really not sure how this is happening, or whether its my original model, onnx, or onnx-coreml that's the problem. But with this in mind, I changed if node.inputs[0] in graph.shape_dict: to if len(graph.shape_dict[node.inputs[0]]) != 0:) in _operators.py. This allows the conversion to complete, though I won't know until I try it whether the model is actually converted correctly...

UPDATE 2: Okay, so the resulting mlmodel fails validation in Xcode with validator error: Layer '427' of type 320 has 1 inputs but expects at least 2. I'm guessing this is a consequence of (simplistically) ignoring the empty shape_dict values I found in "UPDATE 1" above. But clearly the model is incorrect. Could the error be originating in onnx?

来源:https://stackoverflow.com/questions/51605747/errors-converting-pytorch-unet-tiramisu-into-coreml-via-onnx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!