|
请问neg支不支持啊,这个简单的操作
导入onnx模型
导入代码:
- from rknn.api import RKNN
-
- INPUT_SIZE = 64
-
- if __name__ == '__main__':
- # 创建RKNN执行对象
- rknn = RKNN(verbose=True)
- # 配置模型输入,用于NPU对数据输入的预处理
- # channel_mean_value='0 0 0 255',那么模型推理时,将会对RGB数据做如下转换
- # (R - 0)/255, (G - 0)/255, (B - 0)/255。推理时,RKNN模型会自动做均值和归一化处理
- # reorder_channel=’0 1 2’用于指定是否调整图像通道顺序,设置成0 1 2即按输入的图像通道顺序不做调整
- # reorder_channel=’2 1 0’表示交换0和2通道,如果输入是RGB,将会被调整为BGR。如果是BGR将会被调整为RGB
- #图像通道顺序不做调整
- rknn.config(channel_mean_value='0 0 0 255', reorder_channel='0 1 2')
- #model_file = 'XMC2-Cls_face_emotion_classifier.onnx'
- model_file = 'XMC2-Det_student_detector.onnx'
- #model_file = 'XMC2-Det_student_detector.pth.tar.onnx'
- #model_file = 'XMC2-Det_student_detector.pth.tar_op-v8.onnx'
- # 加载TensorFlow模型
- # tf_pb='digital_gesture.pb'指定待转换的TensorFlow模型
- # inputs指定模型中的输入节点
- # outputs指定模型中输出节点
- # input_size_list指定模型输入的大小
- print('--> Loading model', model_file)
- # rknn.load_tensorflow(tf_pb='digital_gesture.pb',
- # inputs=['input_x'],
- # outputs=['probability'],
- # input_size_list=[[INPUT_SIZE, INPUT_SIZE, 3]])
- rknn.load_onnx(model=model_file)
- print('done')
- is_quantization = False
- # 创建解析pb模型
- # do_quantization=False指定不进行量化
- # 量化会减小模型的体积和提升运算速度,但是会有精度的丢失
- print('--> Building model')
- rknn.build(do_quantization=is_quantization)
- print('done')
-
- # 导出保存rknn模型文件
- if is_quantization:
- quant_suff = '_quant'
- else:
- quant_suff = '_un-quant'
- rknn.export_rknn( model_file + quant_suff + '.rknn')
-
- # Release RKNN Context
- rknn.release()
报错信息:
- I Match r_maxpool [['MaxPool_9']] [['MaxPool']] to [['pooling']]
- I Try match AveragePool_13:out0
- I Match r_avgpool [['AveragePool_13']] [['AveragePool']] to [['pooling']]
- I Try match Relu_17:out0
- I Match r_relu [['Relu_17']] [['Relu']] to [['relu']]
- I Try match Conv_22:out0
- I Match r_conv [['Conv_22', 'Initializer_26', 'Initializer_27']] [['Conv', 'Constant_0', 'Constant_1']] to [['convolution']]
- I Try match Relu_8:out0
- I Match r_relu [['Relu_8']] [['Relu']] to [['relu']]
- I Try match Pad_12:out0
- I Match pad_g1 [['Pad_12']] [['Pad']] to [['pad']]
- I Try match Conv_16:out0
- I Match r_conv [['Conv_16', 'Initializer_20', 'Initializer_21']] [['Conv', 'Constant_0', 'Constant_1']] to [['convolution']]
- I Try match Relu_21:out0
- I Match r_relu [['Relu_21']] [['Relu']] to [['relu']]
- I Try match Concat_7:out0
- I Match concat_2 [['Concat_7']] [['Concat']] to [['concat']]
- I Try match Neg_6:out0
- W Not match tensor Neg_6:out0
- E Catch exception when loading onnx model: XMC2-Det_student_detector.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 1072, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx.match_paragraph_and_param
- E File "rknn\base\RKNNlib\converter\convert_onnx.py", line 985, in rknn.base.RKNNlib.converter.convert_onnx.convert_onnx._onnx_push_ready_tensor
- E TypeError: 'NoneType' object is not iterable
- Traceback (most recent call last):
- File "D:\Program Files\JetBrains\PyCharm 2019.2.3\helpers\pydev\pydevd.py", line 2073, in <module>
- main()
- File "D:\Program Files\JetBrains\PyCharm 2019.2.3\helpers\pydev\pydevd.py", line 2067, in main
- globals = debugger.run(setup['file'], None, None, is_module)
- File "D:\Program Files\JetBrains\PyCharm 2019.2.3\helpers\pydev\pydevd.py", line 1418, in run
- return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
- File "D:\Program Files\JetBrains\PyCharm 2019.2.3\helpers\pydev\pydevd.py", line 1425, in _exec
- pydev_imports.execfile(file, globals, locals) # execute the script
- File "D:\Program Files\JetBrains\PyCharm 2019.2.3\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
- exec(compile(contents+"\n", file, 'exec'), glob, loc)
- File "E:/Work/_Code/dmax/tools/covert_onnx/main.py", line 42, in <module>
- rknn.build(do_quantization=is_quantization)
- File "D:\Program Files\Python\Python36\lib\site-packages\rknn\api\rknn.py", line 148, in build
- inputs = self.rknn_base.net.get_input_layers()
- AttributeError: 'NoneType' object has no attribute 'get_input_layers'
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|