ERROR Float input type RGB does not match ...

自己训练的letNet模型,check通过,但是当进行build时报如下错误:

ERROR Float input type RGB does not match model input channel 28.

错误日志如下:

2020-12-10 23:35:59,117 INFO hb_mapper_makertbin 54 Working dir: /data/x3/x3_tc_1.1.17e/x3-toolchain-1.1.17e.tar/horizon_x3_tc_1.1.17e/samples/05_miscellaneous/01_lenet_3_channel/mapper/model_output2020-12-10 23:35:59,117 INFO hb_mapper_makertbin 55 Start Model Convert....2020-12-10 23:35:59,118 DEBUG helper 118 Model input names: ['input.1']2020-12-10 23:35:59,119 DEBUG mapper_conf_parser 532 layer run on cpu:  []2020-12-10 23:35:59,119 DEBUG hb_mapper_makertbin 280 call build params: {'march': 'bernoulli2', 'debug_mode': False, 'save_model': True, 'name_prefix': 'lenet_gray', 'input_dict': {'input.1': {'input_shape': [1, 3, 28, 28], 'expected_input_type': 'RGB_128', 'original_input_type': 'RGB', 'original_input_layout': 'NHWC'}}, 'cali_dict': {'calibration_type': 'kl', 'calibration_loader': {'input.1': <horizon_nn.data.loader.TransformLoader object at 0x7f22bab61c50>}, 'per_channel': False, 'max_percentile': 1.0}, 'hbdk_dict': {'compile_mode': 'latency', 'debug': False, 'optimize_level': 'O3', 'input_source': {'input.1': 'ddr'}}, 'layer_dict': {'run_on_cpu': []}}2020-12-10 23:35:59,129 INFO build 31 [Thu Dec 10 23:35:59 2020] Start to Horizon NN Model Convert.2020-12-10 23:35:59,129 INFO build 133 Parsing the input parameter:{'input.1': {'input_shape': [1, 3, 28, 28], 'expected_input_type': 'RGB_128', 'original_input_type': 'RGB', 'original_input_layout': 'NHWC'}}2020-12-10 23:35:59,130 INFO build 146 Parsing the calibration parameter2020-12-10 23:35:59,140 INFO build 171 Parsing the hbdk parameter:{'compile_mode': 'latency', 'debug': False, 'optimize_level': 'O3', 'input_source': {'input.1': 'ddr'}}2020-12-10 23:35:59,140 INFO build 116 HorizonNN version: 0.7.62020-12-10 23:35:59,140 INFO build 120 HBDK version: 3.12.92020-12-10 23:35:59,141 INFO build 31 [Thu Dec 10 23:35:59 2020] Start to parse the onnx model.2020-12-10 23:35:59,152 INFO onnx_parser 101 ONNX model info:ONNX IR version:  6Opset version:    10Input name:       input.1, [1, 3, 28, 28]2020-12-10 23:35:59,155 INFO build 34 [Thu Dec 10 23:35:59 2020] End to parse the onnx model.2020-12-10 23:35:59,155 INFO build 256 Model input names: ['input.1']2020-12-10 23:35:59,155 DEBUG build 278 Input preprocessing:{'input.1': {'input_shape': [1, 3, 28, 28], 'expected_input_type': 'RGB_128', 'original_input_type': 'RGB', 'original_input_layout': 'NHWC'}}2020-12-10 23:35:59,155 INFO build 301 Create a preprocessing operator for input_name input.1 with means=None, scales=None, original_input_type=RGB, color convert from 'RGB_128' to 'RGB'.2020-12-10 23:35:59,156 DEBUG tool_utils 94 exception in makertbin2020-12-10 23:35:59,157 DEBUG tool_utils 95 Traceback (most recent call last):  File "/root/.local/lib/python3.6/site-packages/x3_tc_ui/utils/tool_utils.py", line 92, in __decorator    func(*args, **kargs)  File "/root/.local/lib/python3.6/site-packages/x3_tc_ui/hb_mapper.py", line 86, in makertbin    MakertbinRunner(config, model_type).run(version)  File "/root/.local/lib/python3.6/site-packages/x3_tc_ui/hb_mapper_makertbin.py", line 322, in run    onnx_file=self.mp_conf.get_onnx_model(), **build_params)  File "/root/.local/lib/python3.6/site-packages/horizon_nn/build.py", line 782, in build_onnx    original_model = builder.add_preprocessing_node(original_model)  File "/root/.local/lib/python3.6/site-packages/horizon_nn/build.py", line 304, in add_preprocessing_node    float_input_type, fixed_input_type, float_input_layout)  File "/root/.local/lib/python3.6/site-packages/horizon_nn/horizon_onnx/quantizer.py", line 174, in insert_mean_scale_node    'channel {}.'.format(float_input_type, input_channel))ValueError: Float input type RGB does not match model input channel 28.2020-12-10 23:35:59,157 ERROR tool_utils 96 Float input type RGB does not match model input channel 28.2020-12-10 23:35:59,158 INFO build 34 [Thu Dec 10 23:35:59 2020] End to Horizon NN Model Convert.

具体输出如下

cd $(dirname $0) || exitdirname $0. ../env.conf#sample_name='lenet_gray'#input_width=28#input_height=28#input_type=0  # BPU_TYPE_IMG_Y#model_type="caffe"#proto="/data/x3/x3_tc_1.1.17e/x3-toolchain-1.1.17e.tar/horizon_x3_tc_1.1.17e/samples/05_miscellaneous/01_lenet_gray/mapper"#caffe_model="/data/x3/x3_tc_1.1.17e/x3-toolchain-1.1.17e.tar/horizon_x3_tc_1.1.17e/samples/05_miscellaneous/01_lenet_gray/mapper"#test_image='/data/x3/x3_tc_1.1.17e/x3-toolchain-1.1.17e.tar/horizon_x3_tc_1.1.17e/samples/05_miscellaneous/01_lenet_gray/lenet_data/0.jpg'#board_test_image='/data/x3/x3_tc_1.1.17e/x3-toolchain-1.1.17e.tar/horizon_x3_tc_1.1.17e/samples/05_miscellaneous/01_lenet_gray/lenet_data/0.jpg'config_file="./my_mnist.yaml"model_type="onnx"# build modelhb_mapper makertbin --config ${config_file}  \                    --model-type  ${model_type}-12-10 23:35:58,699 INFO Start hb_mapper....2020-12-10 23:35:58,700 INFO hb_mapper version 1.1.242020-12-10 23:35:59,108 INFO norm_types[i]: no_preprocess2020-12-10 23:35:59,117 INFO Working dir: /data/x3/x3_tc_1.1.17e/x3-toolchain-1.1.17e.tar/horizon_x3_tc_1.1.17e/samples/05_miscellaneous/01_lenet_3_channel/mapper/model_output2020-12-10 23:35:59,117 INFO Start Model Convert....2020-12-10 23:35:59,129 INFO [Thu Dec 10 23:35:59 2020] Start to Horizon NN Model Convert.2020-12-10 23:35:59,129 INFO Parsing the input parameter:{'input.1': {'input_shape': [1, 3, 28, 28], 'expected_input_type': 'RGB_128', 'original_input_type': 'RGB', 'original_input_layout': 'NHWC'}}2020-12-10 23:35:59,130 INFO Parsing the calibration parameter2020-12-10 23:35:59,140 INFO Parsing the hbdk parameter:{'compile_mode': 'latency', 'debug': False, 'optimize_level': 'O3', 'input_source': {'input.1': 'ddr'}}2020-12-10 23:35:59,140 INFO HorizonNN version: 0.7.62020-12-10 23:35:59,140 INFO HBDK version: 3.12.92020-12-10 23:35:59,141 INFO [Thu Dec 10 23:35:59 2020] Start to parse the onnx model.2020-12-10 23:35:59,152 INFO ONNX model info:ONNX IR version:  6Opset version:    10Input name:       input.1, [1, 3, 28, 28]2020-12-10 23:35:59,155 INFO [Thu Dec 10 23:35:59 2020] End to parse the onnx model.2020-12-10 23:35:59,155 INFO Model input names: ['input.1']2020-12-10 23:35:59,155 INFO Create a preprocessing operator for input_name input.1 with means=None, scales=None, original_input_type=RGB, color convert from 'RGB_128' to 'RGB'.2020-12-10 23:35:59,157 ERROR Float input type RGB does not match model input channel 28.2020-12-10 23:35:59,158 INFO [Thu Dec 10 23:35:59 2020] End to Horizon NN Model Convert.

这个问题已经解决,和模型的输入数据格式有关,