【问题标题】:Can't load onnx model converted from mxnet无法加载从 mxnet 转换的 onnx 模型
【发布时间】:2023-03-09 18:14:01
【问题描述】:

我正在尝试从这里启动模型 R100 (mxnet):
https://github.com/deepinsight/insightface/tree/master/model_zoo
我将它转换为 onnx :

sym = './model-symbol.json'
params = './model-0000.params'
input_shape = (1,3,112,112)
onnx_file = './R100_mxnet.onnx'
converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)

此检查已通过:

model_proto = onnx.load_model('./R100_mxnet.onnx')
checker.check_graph(model_proto.graph)

但是当我尝试推断:

classifier.run(None, {'data': np.ones([1, 3, 112, 112]).astype('float32')})[0].shape

我明白了:

~/.local/lib/python3.6/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py in run(self, output_names, input_feed, run_options)
    190             output_names = [output.name for output in self._outputs_meta]
    191         try:
--> 192             return self._sess.run(output_names, input_feed, run_options)
    193         except C.EPFail as err:
    194             if self._enable_fallback:

Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running PRelu node. Name:'conv_1_relu' Status Message: conv_1_relu: left operand cannot broadcast on dim 3 LeftShape: {1,64,56,56}, RightShape: {64}

这是导出还是导入错误,我可以修复它吗?

【问题讨论】:

    标签: python mxnet onnx


    【解决方案1】:

    已通过从此处粘贴“#fix PRelu issue”部分进行修复:
    https://github.com/deepinsight/insightface/blob/master/examples/mxnet_to_onnx.py

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-10
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      • 2020-03-31
      • 1970-01-01
      • 1970-01-01
      • 2020-02-12
      相关资源
      最近更新 更多