Toybrick

标题: convet onnx model to rknn [打印本页]

作者: NG1368    时间: 2020-4-21 03:35
标题: convet onnx model to rknn
h, I want to convert onnx model in https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB/tree/master/models to rknn. in first step, when I run  ret = rknn.load_onnx(model = './version-RFB-320.onnx'), I face with this error:


/usr/local/lib/python3.6/site-packages/onnx_tf/common/handler_helper.py:73: UserWarning: Unknown op ConstantFill in domain `ai.onnx`.
  handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
/usr/local/lib/python3.6/site-packages/onnx_tf/common/handler_helper.py:73: UserWarning: Unknown op ConstantLike in domain `ai.onnx`.
  handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
/usr/local/lib/python3.6/site-packages/onnx_tf/common/handler_helper.py:73: UserWarning: Unknown op MeanVarianceNormalization in domain `ai.onnx`.
  handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
E Catch exception when loading onnx model: ./version-RFB-320.onnx!
E Traceback (most recent call last):
E File "rknn / api / rknn_base.py", line 345, in rknn.api.rknn_base.RKNNBase.load_onnx
E File "rknn / base / RKNNlib / converter / convert_onnx.py", line 1040, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx.match_paragraph_and_param
E File "rknn / base / RKNNlib / converter / convert_onnx.py", line 893, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx._onnx_try_match_ruler
E File "<string>", line 1, in <module>
E KeyError: 'Slice'






作者: jefferyzhang    时间: 2020-4-21 08:36
本帖最后由 jefferyzhang 于 2020-4-21 08:40 编辑

It means the op 'Slice' is unsupported by rknn.
You need to change it or waiting for our implementation.

You have to update rknn-toolkit to the latest version, each new version will support more OPs.
After you trying the latest rknn-toolkit and find it is still unsupported, you can report it here with rknn-toolkit version number.
作者: NG1368    时间: 2020-4-21 15:12
jefferyzhang 发表于 2020-4-21 08:36
It means the op 'Slice' is unsupported by rknn.
You need to change it or waiting for our implementat ...

I downloaded rknn_toolkit-1.3.0-cp36-cp36m-linux_aarch64.whl for install rknn-toolkit-1.3.0. in but in installation occurred errors:
[attach]999[/attach][attach]999[/attach]

作者: jefferyzhang    时间: 2020-4-21 16:55
Fedora or debian10? If in debian10, just using 'pip3 install rknn'
作者: NG1368    时间: 2020-4-21 19:12
jefferyzhang 发表于 2020-4-21 16:55
Fedora or debian10? If in debian10, just using 'pip3 install rknn'

I use from Fedora

作者: NG1368    时间: 2020-4-21 22:27
NG1368 发表于 2020-4-21 19:12
I use from Fedora

please help me to solve this problem.
作者: NG1368    时间: 2020-4-22 02:21
本帖最后由 NG1368 于 2020-4-22 02:25 编辑
NG1368 发表于 2020-4-21 22:27
please help me to solve this problem.

Finaly, I can resolve problems in installing rknn-toolkit 1.3.0 and installed it.
but again in loading onnx model , this error occurred:
[toybrick@localhost ONNX]$ python3 ModelTransform.py
D Save log info to: ./e.log
--> Loading model
/usr/local/lib/python3.6/site-packages/onnx_tf/common/__init__.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release.. Use node.outputs instead.
  warnings.warn(message)
I Current ONNX Model use ir_version 4 opset_version 9
/usr/local/lib/python3.6/site-packages/onnx_tf/common/handler_helper.py:73: UserWarning: Unknown op ConstantFill in domain `ai.onnx`.
  handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
/usr/local/lib/python3.6/site-packages/onnx_tf/common/handler_helper.py:73: UserWarning: Unknown op ConstantLike in domain `ai.onnx`.
  handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
/usr/local/lib/python3.6/site-packages/onnx_tf/common/handler_helper.py:73: UserWarning: Unknown op MeanVarianceNormalization in domain `ai.onnx`.
  handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
D calc tensor shape of Reshape_428ut0 [[1, 160, 4]]
D calc tensor shape of Reshape_414ut0 [[1, 160, 2]]
D calc tensor shape of Reshape_342ut0 [[1, 3600, 4]]
D calc tensor shape of Reshape_458ut0 [[1, 60, 4]]
D calc tensor shape of Reshape_374ut0 [[1, 600, 2]]
D calc tensor shape of Reshape_328ut0 [[1, 3600, 2]]
D calc tensor shape of Reshape_446ut0 [[1, 60, 2]]
D calc tensor shape of Reshape_388ut0 [[1, 600, 4]]
D calc tensor shape of Concat_460ut0 [[1, 4420, 4]]
D calc tensor shape of Concat_459ut0 [[1, 4420, 2]]
D import clients finished
I build output layer attach_Softmax_scores:out0
I build output layer attach_Concat_boxes:out0
I Try match Concat_boxes:out0
I Match concat_2 [['Concat_boxes']] [['Concat']] to [['concat']]
I Try match Softmax_scores:out0
I Match r_softmax [['Softmax_scores']] [['Softmax']] to [['softmax']]
I Try match Sub_480:out0
I Match r_sub [['Sub_480']] [['Sub']] to [['subtract']]
I Try match Add_485:out0
I Match r_add [['Add_485']] [['Add']] to [['add']]
I Try match Concat_459:out0
I Match concat_4 [['Concat_459']] [['Concat']] to [['concat']]
I Try match Slice_476:out0
E Try match Slice_476:out0 failed, catch exception!
I ----------------Warning(0)----------------
E Catch exception when loading onnx model: ./ultralight.onnx!
E Traceback (most recent call last):
E   File "rknn/base/RKNNlib/converter/convert_onnx.py", line 1027, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx.match_paragraph_and_param
E   File "rknn/base/RKNNlib/converter/convert_onnx.py", line 877, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx._onnx_try_match_ruler
E   File "<string>", line 1, in <module>
E KeyError: 'Slice'
E During handling of the above exception, another exception occurred:
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 472, in rknn.api.rknn_base.RKNNBase.load_onnx
E   File "rknn/base/RKNNlib/converter/convert_onnx.py", line 1066, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx.match_paragraph_and_param
E   File "/home/toybrick/.local/lib/python3.6/site-packages/rknn/base/RKNNlib/RKNNlog.py", line 327, in e
E     raise ValueError(msg)
E ValueError: Try match Slice_476:out0 failed, catch exception!
Load model failed!





欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3