Toybrick

rknn.load_pytorch 加载resnet特征提取模型加载接口报错

Aruen

注册会员

积分
88
楼主
发表于 2021-7-7 22:59:14    查看: 6527|回复: 1 | [复制链接]    打印 | 只看该作者
root@7b013ddcfcc1:/test/pytorch/face_feature_rk# python test_mask.py
W __init__: Verbose file path is invalid, debug info will not dump to file.
--> config model
done
--> Loading model
/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py:243: UserWarning: `add_node_names' can be set to True only when 'operator_export_type' is `ONNX`. Since 'operator_export_type' is not set to 'ONNX', `add_node_names` argument will be ignored.
  "`{}` argument will be ignored.".format(arg_name, arg_name))
/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py:243: UserWarning: `do_constant_folding' can be set to True only when 'operator_export_type' is `ONNX`. Since 'operator_export_type' is not set to 'ONNX', `do_constant_folding` argument will be ignored.
  "`{}` argument will be ignored.".format(arg_name, arg_name))
E load_pytorch: Catch exception when loading pytorch model: TypeError("object of type 'NoneType' has no len() \n(Occurred when translating batch_norm).",)
E load_pytorch: Traceback (most recent call last):
E load_pytorch:   File "rknn/api/rknn_base.py", line 1889, in rknn.api.rknn_base.RKNNBase.load_pytorch
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/__init__.py", line 208, in export
E load_pytorch:     custom_opsets, enable_onnx_checker, use_external_data_format)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 92, in export
E load_pytorch:     use_external_data_format=use_external_data_format)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 530, in _export
E load_pytorch:     fixed_batch_size=fixed_batch_size)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 384, in _model_to_graph
E load_pytorch:     fixed_batch_size=fixed_batch_size, params_dict=params_dict)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 188, in _optimize_graph
E load_pytorch:     graph = torch._C._jit_pass_onnx(graph, operator_export_type)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/__init__.py", line 241, in _run_symbolic_function
E load_pytorch:     return utils._run_symbolic_function(*args, **kwargs)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 791, in _run_symbolic_function
E load_pytorch:     return symbolic_fn(g, *inputs, **attrs)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_helper.py", line 129, in wrapper
E load_pytorch:     return fn(g, *args)
E load_pytorch:   File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset9.py", line 1103, in batch_norm
E load_pytorch:     assert len(input_sizes) > 1
E load_pytorch: TypeError: object of type 'NoneType' has no len()
E load_pytorch: (Occurred when translating batch_norm).
Load pytorch model failed!


回复

使用道具 举报

Aruen

注册会员

积分
88
沙发
 楼主| 发表于 2021-7-8 10:46:33 | 只看该作者
转换成onnx后重新转换报错如下:
root@7b013ddcfcc1:/test/pytorch/face_feature_rk# python test_mask_onnx.py
W __init__: Verbose file path is invalid, debug info will not dump to file.
--> config model
done
--> Loading model
done
--> Building model
I _fold_constant remove nodes = ['Shape_356', 'Gather_358', 'Unsqueeze_359', 'Concat_360']
I
I _fuse_ops results:
I     fuse_bn_into_conv: remove node = ['BatchNormalization_1', 'BatchNormalization_5', 'BatchNormalization_8', 'BatchNormalization_10', 'BatchNormalization_14', 'BatchNormalization_17', 'BatchNormalization_21', 'BatchNormalization_24', 'BatchNormalization_28', 'BatchNormalization_31', 'BatchNormalization_33', 'BatchNormalization_37', 'BatchNormalization_40', 'BatchNormalization_44', 'BatchNormalization_47', 'BatchNormalization_51', 'BatchNormalization_54', 'BatchNormalization_58', 'BatchNormalization_61', 'BatchNormalization_65', 'BatchNormalization_68', 'BatchNormalization_72', 'BatchNormalization_75', 'BatchNormalization_79', 'BatchNormalization_82', 'BatchNormalization_86', 'BatchNormalization_89', 'BatchNormalization_93', 'BatchNormalization_96', 'BatchNormalization_100', 'BatchNormalization_103', 'BatchNormalization_107', 'BatchNormalization_110', 'BatchNormalization_114', 'BatchNormalization_117', 'BatchNormalization_121', 'BatchNormalization_124', 'BatchNormalization_126', 'BatchNormalization_130', 'BatchNormalization_133', 'BatchNormalization_137', 'BatchNormalization_140', 'BatchNormalization_144', 'BatchNormalization_147', 'BatchNormalization_151', 'BatchNormalization_154', 'BatchNormalization_158', 'BatchNormalization_161', 'BatchNormalization_165', 'BatchNormalization_168', 'BatchNormalization_172', 'BatchNormalization_175', 'BatchNormalization_179', 'BatchNormalization_182', 'BatchNormalization_186', 'BatchNormalization_189', 'BatchNormalization_193', 'BatchNormalization_196', 'BatchNormalization_200', 'BatchNormalization_203', 'BatchNormalization_207', 'BatchNormalization_210', 'BatchNormalization_214', 'BatchNormalization_217', 'BatchNormalization_221', 'BatchNormalization_224', 'BatchNormalization_228', 'BatchNormalization_231', 'BatchNormalization_235', 'BatchNormalization_238', 'BatchNormalization_242', 'BatchNormalization_245', 'BatchNormalization_249', 'BatchNormalization_252', 'BatchNormalization_256', 'BatchNormalization_259', 'BatchNormalization_263', 'BatchNormalization_266', 'BatchNormalization_270', 'BatchNormalization_273', 'BatchNormalization_277', 'BatchNormalization_280', 'BatchNormalization_284', 'BatchNormalization_287', 'BatchNormalization_291', 'BatchNormalization_294', 'BatchNormalization_298', 'BatchNormalization_301', 'BatchNormalization_305', 'BatchNormalization_308', 'BatchNormalization_312', 'BatchNormalization_315', 'BatchNormalization_319', 'BatchNormalization_322', 'BatchNormalization_326', 'BatchNormalization_329', 'BatchNormalization_333', 'BatchNormalization_336', 'BatchNormalization_338', 'BatchNormalization_342', 'BatchNormalization_345', 'BatchNormalization_349', 'BatchNormalization_352', 'BatchNormalization_355']
I     replace_gemm_by_conv: remove node = ['Reshape_361', 'Gemm_362'], add node = ['Gemm_362', 'Gemm_362_after']
I     swap_reshape_bn: remove node = ['Gemm_362_after', 'BatchNormalization_365'], add node = ['BatchNormalization_365', 'Gemm_362_after']
I     fuse_bn_into_conv: remove node = ['BatchNormalization_365']
I
I sparse weight ...
I sparse weight done.
I
Analysing : 100%|################################################| 254/254 [00:00<00:00, 954.42it/s]
Quantizating : 100%|#############################################| 254/254 [00:00<00:00, 454.46it/s]
I
I rknn building ...
I RKNN: librknnc version: 1.0.0 (454a7218@2021-04-30T16:32:25)
I RKNN: set log level to 0
I rknn buiding done
done
--> Export RKNN model
done
uint8
--> Init runtime environment
W init_runtime: target is None, use simulator!
done
--> Running model
I RKNN: librknnc version: 1.0.0 (454a7218@2021-04-30T16:32:25)
I RKNN: set log level to 0
E RKNN: [02:32:50.771] Depthwise: Invalid kernel width of 9. Must be an integer in [1, 8]
Aborted (core dumped)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表