简体   繁体   English

使用 onnx_coreml 转换节点类型切片时出错

[英]Error when Converting Node Type Slice with onnx_coreml

I have converted my dar.net YOLOv3-SPP model into a PyTorch.pt model. I then converted the.pt to a.onnx.我已将我的 dar.net YOLOv3-SPP model 转换为 PyTorch.pt model。然后我将 .pt 转换为 a.onnx。 My end goal is to get to a CoreML model. I tried to use this GitHub repository.我的最终目标是获得 CoreML model。我尝试使用这个GitHub 存储库。 However when converting my model I am getting an error like this...但是,在转换我的 model 时,出现这样的错误...

...    
145/229: Converting Node Type LeakyRelu
146/229: Converting Node Type Conv
147/229: Converting Node Type Reshape
148/229: Converting Node Type Transpose
149/229: Converting Node Type Reshape
150/229: Converting Node Type Slice
Traceback (most recent call last):
  File "convert2.py", line 11, in <module>
    coreml_model = convert(model_proto, image_input_names=['inputImage'], image_output_names=['outputImage'], minimum_ios_deployment_target='13')
  File "/usr/local/lib/python3.6/dist-packages/onnx_coreml/converter.py", line 626, in convert
    _convert_node_nd(builder, node, graph, err)
  File "/usr/local/lib/python3.6/dist-packages/onnx_coreml/_operators_nd.py", line 2387, in _convert_node_nd
    return converter_fn(builder, node, graph, err)
  File "/usr/local/lib/python3.6/dist-packages/onnx_coreml/_operators_nd.py", line 2011, in _convert_slice
    end_masks=end_masks
  File "/usr/local/lib/python3.6/dist-packages/coremltools/models/neural_network/builder.py", line 4220, in add_slice_static
    assert len(strides) == rank
AssertionError

The script I am using is this...我正在使用的脚本是这样的......

import sys
from onnx import onnx_pb
from onnx_coreml import convert

model_in = sys.argv[1]
model_out = sys.argv[2]

model_file = open(model_in, 'rb')
model_proto = onnx_pb.ModelProto()
model_proto.ParseFromString(model_file.read())
coreml_model = convert(model_proto, image_input_names=['inputImage'], image_output_names=['outputImage'], minimum_ios_deployment_target='13')
coreml_model.save(model_out)

This simple python script should work, but I don't know why I am getting this error.这个简单的 python 脚本应该可以工作,但我不知道为什么会出现此错误。 I am very new to Machine Learning, so I do not understand how I can even begin to try to solve this issue.我是机器学习的新手,所以我什至不知道如何开始尝试解决这个问题。 What should I do in order to convert my.onnx model to CoreML successfully?我应该怎么做才能成功将 my.onnx model 转换为 CoreML?

Looks like rank mis-match between input tensor rank and slice parameter Could you please file bug at onnx-coreml看起来输入张量等级和切片参数之间的等级不匹配你能在onnx-coreml上提交错误吗

As @matthijs-hollemans commented, try installing latest onnx-coreml正如@matthijs-hollemans 评论的那样,尝试安装最新的 onnx-coreml

pip install onnx-coreml==1.2

Few other concerns:其他一些问题:

  1. What is the version of onnx model you are working with?您使用的 onnx model 是什么版本? with Operator-9 slice behavior is changed and that could be potential failure point from converter. Operator-9 slice 的行为发生了变化,这可能是转换器的潜在故障点。

  2. Could you please attach ONNX model as well?你能附上 ONNX model 吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM