自己的模型 lenet---三通道
在运行03_build.sh时候出现错误,以下是log日志
----------------------------------------------------------------------------------------------------------------------------------------------------------
2020-12-10 19:59:21,772 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/03_classification/00_lenet/mapper/model_output
2020-12-10 19:59:21,772 INFO hb_mapper_makertbin 55 Start Model Convert....
2020-12-10 19:59:21,773 DEBUG helper 118 Model input names: ['input.1']
2020-12-10 19:59:21,776 DEBUG mapper_conf_parser 468 mean value: [0. 0. 0.]
2020-12-10 19:59:21,952 DEBUG mapper_conf_parser 532 layer run on cpu:
[]
2020-12-10 19:59:21,952 DEBUG hb_mapper_makertbin 280 call build params:
{'march': 'bernoulli2', 'debug_mode': False, 'save_model': True, 'name_prefix': 'lenet', 'input_dict': {'input.1': {'input_shape': [1, 3, 32, 32], 'expected_input_type': 'RGB_128', 'original_input_type': 'BGR', 'means': array([0., 0., 0.], dtype=float32)}}, 'cali_dict': {'calibration_type': 'kl', 'calibration_loader': {'input.1': <horizon_nn.data.loader.TransformLoader object at 0x7f0af20b2a58>}, '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 19:59:21,963 INFO build 31 [Thu Dec 10 19:59:21 2020] Start to Horizon NN Model Convert.
2020-12-10 19:59:21,963 INFO build 133 Parsing the input parameter:{'input.1': {'input_shape': [1, 3, 32, 32], 'expected_input_type': 'RGB_128', 'original_input_type': 'BGR', 'means': array([0., 0., 0.], dtype=float32)}}
2020-12-10 19:59:21,964 INFO build 146 Parsing the calibration parameter
2020-12-10 19:59:21,969 DEBUG Image 405 Importing BlpImagePlugin
2020-12-10 19:59:21,972 DEBUG Image 405 Importing BmpImagePlugin
2020-12-10 19:59:21,972 DEBUG Image 405 Importing BufrStubImagePlugin
2020-12-10 19:59:21,973 DEBUG Image 405 Importing CurImagePlugin
2020-12-10 19:59:21,973 DEBUG Image 405 Importing DcxImagePlugin
2020-12-10 19:59:21,974 DEBUG Image 405 Importing DdsImagePlugin
2020-12-10 19:59:21,974 DEBUG Image 405 Importing EpsImagePlugin
2020-12-10 19:59:21,975 DEBUG Image 405 Importing FitsStubImagePlugin
2020-12-10 19:59:21,976 DEBUG Image 405 Importing FliImagePlugin
2020-12-10 19:59:21,976 DEBUG Image 405 Importing FpxImagePlugin
2020-12-10 19:59:22,027 DEBUG Image 405 Importing FtexImagePlugin
2020-12-10 19:59:22,027 DEBUG Image 405 Importing GbrImagePlugin
2020-12-10 19:59:22,028 DEBUG Image 405 Importing GifImagePlugin
2020-12-10 19:59:22,028 DEBUG Image 405 Importing GribStubImagePlugin
2020-12-10 19:59:22,028 DEBUG Image 405 Importing Hdf5StubImagePlugin
2020-12-10 19:59:22,028 DEBUG Image 405 Importing IcnsImagePlugin
2020-12-10 19:59:22,030 DEBUG Image 405 Importing IcoImagePlugin
2020-12-10 19:59:22,030 DEBUG Image 405 Importing ImImagePlugin
2020-12-10 19:59:22,031 DEBUG Image 405 Importing ImtImagePlugin
2020-12-10 19:59:22,032 DEBUG Image 405 Importing IptcImagePlugin
2020-12-10 19:59:22,032 DEBUG Image 405 Importing JpegImagePlugin
2020-12-10 19:59:22,033 DEBUG Image 405 Importing Jpeg2KImagePlugin
2020-12-10 19:59:22,033 DEBUG Image 405 Importing McIdasImagePlugin
2020-12-10 19:59:22,033 DEBUG Image 405 Importing MicImagePlugin
2020-12-10 19:59:22,033 DEBUG Image 405 Importing MpegImagePlugin
2020-12-10 19:59:22,034 DEBUG Image 405 Importing MpoImagePlugin
2020-12-10 19:59:22,034 DEBUG Image 405 Importing MspImagePlugin
2020-12-10 19:59:22,035 DEBUG Image 405 Importing PalmImagePlugin
2020-12-10 19:59:22,036 DEBUG Image 405 Importing PcdImagePlugin
2020-12-10 19:59:22,036 DEBUG Image 405 Importing PcxImagePlugin
2020-12-10 19:59:22,036 DEBUG Image 405 Importing PdfImagePlugin
2020-12-10 19:59:22,049 DEBUG Image 405 Importing PixarImagePlugin
2020-12-10 19:59:22,049 DEBUG Image 405 Importing PngImagePlugin
2020-12-10 19:59:22,049 DEBUG Image 405 Importing PpmImagePlugin
2020-12-10 19:59:22,050 DEBUG Image 405 Importing PsdImagePlugin
2020-12-10 19:59:22,050 DEBUG Image 405 Importing SgiImagePlugin
2020-12-10 19:59:22,050 DEBUG Image 405 Importing SpiderImagePlugin
2020-12-10 19:59:22,051 DEBUG Image 405 Importing SunImagePlugin
2020-12-10 19:59:22,051 DEBUG Image 405 Importing TgaImagePlugin
2020-12-10 19:59:22,052 DEBUG Image 405 Importing TiffImagePlugin
2020-12-10 19:59:22,052 DEBUG Image 405 Importing WebPImagePlugin
2020-12-10 19:59:22,053 DEBUG Image 405 Importing WmfImagePlugin
2020-12-10 19:59:22,054 DEBUG Image 405 Importing XbmImagePlugin
2020-12-10 19:59:22,055 DEBUG Image 405 Importing XpmImagePlugin
2020-12-10 19:59:22,056 DEBUG Image 405 Importing XVThumbImagePlugin
2020-12-10 19:59:22,229 DEBUG tool_utils 94 exception in makertbin
2020-12-10 19:59:22,231 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 778, in build_onnx
debug_mode=debug_mode)
File "/root/.local/lib/python3.6/site-packages/horizon_nn/build.py", line 99, in __init__
self.parse_cali_dict(cali_dict)
File "/root/.local/lib/python3.6/site-packages/horizon_nn/build.py", line 159, in parse_cali_dict
self.calibration_data = self.get_all_data(calibration_loader)
File "/root/.local/lib/python3.6/site-packages/horizon_nn/build.py", line 349, in get_all_data
datasets = gen_datasets(new_generators)
File "/root/.local/lib/python3.6/site-packages/horizon_nn/build.py", line 335, in gen_datasets
for all_data in zip(*generator):
File "/root/.local/lib/python3.6/site-packages/horizon_nn/data/loader.py", line 32, in __next__
return self.perform()
File "/root/.local/lib/python3.6/site-packages/horizon_nn/data/loader.py", line 35, in perform
data = self._parant.perform()
File "/root/.local/lib/python3.6/site-packages/x3_tc_ui/data/loader.py", line 42, in perform
return self.image_read_method(next(self.file_gen))
File "/root/.local/lib/python3.6/site-packages/x3_tc_ui/data/loader.py", line 51, in image_read_method
image = skimage.img_as_float(skimage.io.imread(file)).astype(
File "/root/.local/lib/python3.6/site-packages/skimage/io/_io.py", line 48, in imread
img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
File "/root/.local/lib/python3.6/site-packages/skimage/io/manage_plugins.py", line 210, in call_plugin
return func(*args, **kwargs)
File "/root/.local/lib/python3.6/site-packages/skimage/io/_plugins/imageio_plugin.py", line 10, in imread
return np.asarray(imageio_imread(*args, **kwargs))
File "/root/.local/lib/python3.6/site-packages/imageio/core/functions.py", line 265, in imread
reader = read(uri, format, "i", **kwargs)
File "/root/.local/lib/python3.6/site-packages/imageio/core/functions.py", line 182, in get_reader
"Could not find a format to read the specified file in %s mode" % modename
ValueError: Could not find a format to read the specified file in single-image mode
2020-12-10 19:59:22,231 ERROR tool_utils 96 Could not find a format to read the specified file in single-image mode
2020-12-10 19:59:22,233 INFO build 34 [Thu Dec 10 19:59:22 2020] End to Horizon NN Model Convert.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
我的模型的配置文件
# Copyright (c) 2020 Horizon Robotics.All Rights Reserved.
#
# The material in this file is confidential and contains trade secrets
# of Horizon Robotics Inc. This is proprietary information owned by
# Horizon Robotics Inc. No part of this work may be disclosed,
# reproduced, copied, transmitted, or used in any way for any purpose,
# without the express written permission of Horizon Robotics Inc.
# 模型转化相关的参数
model_parameters:
# Caffe浮点网络数据模型文件
onnx_model: '../../../01_common/modelzoo/mapper/classification/lenet_onnx/lenet.onnx'
# Caffe网络描述文件
# prototxt: '../../../01_common/modelzoo/mapper/classification/resnet18/resnet18_deploy.prototxt'
# 指定模型转换过程中是否输出各层的中间结果,如果为True,则输出所有层的中间输出结果,
layer_out_dump: False
# 用于设置上板模型输出的layout, 支持NHWC和NCHW, 输入None则使用模型默认格式
output_layout: None
# 日志文件的输出控制参数,
# debug输出模型转换的详细信息
# info只输出关键信息
# warn输出警告和错误级别以上的信息
log_level: 'debug'
# 模型转换输出的结果的存放目录
working_dir: 'model_output'
# 模型转换输出的用于上板执行的模型文件的名称前缀
output_model_file_prefix: 'lenet'
# 模型输入相关参数, 若输入多个节点, 则应使用';'进行分隔, 使用默认缺省设置则写None
input_parameters:
# (可不填) 模型输入的节点名称, 此名称应与模型文件中的名称一致, 否则会报错, 不填则会使用模型文件中的节点名称
input_name: 'input.1'
# 网络实际执行时,输入给网络的数据格式,包括 nv12/rgbp/bgrp/yuv444_128/gray/featuremap,
# 如果输入的数据为yuv444_128, 模型训练用的是bgrp,则hb_mapper将自动插入YUV到BGRP(NCHW)转化操作
input_type_rt: 'rgbp'
# 网络训练时输入的数据格式,可选的值为rgbp/bgrp/gray/featuremap/yuv444_128
input_type_train: 'bgrp'
# 网络输入的预处理方法,主要有以下几种:
# no_preprocess 不做任何操作
# mean_file 减去从通道均值文件(mean_file)得到的均值
# data_scale 对图像像素乘以data_scale系数
# mean_file_and_scale 减去通道均值后再乘以scale系数
norm_type: 'mean_file'
# (可不填) 模型网络的输入大小, 以'x'分隔, 不填则会使用模型文件中的网络输入大小
input_shape: '1x3x32x32'
# 图像减去的均值存放文件, 文件内存放的如果是通道均值,均值之间必须用空格分隔
mean_file: './meanfile.txt'
# 图像预处理缩放比例,该数值应为浮点数
scale_value: 1.0
calibration_parameters:
# 模型量化的参考图像的存放目录,图片格式支持Jpeg、Bmp等格式,输入的图片
# 应该是使用的典型场景,一般是从测试集中选择20~50张图片,另外输入
# 的图片要覆盖典型场景,不要是偏僻场景,如过曝光、饱和、模糊、纯黑、纯白等图片
# 若有多个输入节点, 则应使用';'进行分隔
cal_data_dir: './calibration_data_bgrp'
# 如果输入的图片文件尺寸和模型训练的尺寸不一致时,并且preprocess_on为true,
# 则将采用默认预处理方法(opencv resize),
# 将输入图片缩放或者裁减到指定尺寸,否则,需要用户提前把图片处理为训练时的尺寸
preprocess_on: True
# 模型量化的算法类型,支持kl、max,通常采用KL即可满足要求
calibration_type: 'kl'
# 模型的量化校准方法设置为promoter,mapper会根据calibration的数据对模型进行微调从而提高精度,
# promoter_level的级别,可选的参数为-1到2,建议按照0到2的顺序实验,满足精度即可停止实验
# -1: 不进行promoter
# 0:表示对模型进行轻微调节,精度提高比较小
# 1:表示相对0对模型调节幅度稍大,精度提高也比较多
# 2:表示调节比较激进,可能造成精度的大幅提高也可能造成精度下降
promoter_level: -1
# 编译器相关参数
compiler_parameters:
# 编译策略,支持bandwidth和latency两种优化模式;
# bandwidth以优化ddr的访问带宽为目标;
# latency以优化推理时间为目标
compile_mode: 'latency'
# 设置debug为True将打开编译器的debug模式,能够输出性能仿真的相关信息,如帧率、DDR带宽占用等
debug: False
# 编译模型指定核数,不指定默认编译单核模型, 若编译双核模型,将下边注释打开即可
# core_num: 2
# 优化等级可选范围为O0~O3
# O0不做任何优化, 编译速度最快,优化程度最低,
# O1-O3随着优化等级提高,预期编译后的模型的执行速度会更快,但是所需编译时间也会变长。
# 推荐用O2做最快验证
optimize_level: 'O3'


