我已将我的暗网 YOLOv3-SPP 模型转换为 PyTorch .pt 模型。然后我将.pt 转换为.onnx。我的最终目标是建立一个 CoreML 模型。我尝试使用这个GitHub 存储库。但是,在转换我的模型时,我遇到了这样的错误......
...
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
我正在使用的脚本是这个......
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)
这个简单的 python 脚本应该可以工作,但我不知道为什么会出现这个错误。我对机器学习很陌生,所以我什至不明白如何开始尝试解决这个问题。我应该怎么做才能成功地将我的 .onnx 模型转换为 CoreML?