Toybrick

标题: tensorflow ssdmobilenet 模型转换 [打印本页]

作者: senna_kim    时间: 2020-8-7 15:55
标题: tensorflow ssdmobilenet 模型转换
def convert_model():

    rknn = RKNN()

    # Config for Model Input PreProcess
    rknn.config(channel_mean_value='127.5 127.5 127.5 127.5', reorder_channel='0 1 2')

    # Load TensorFlow Model
    print('--> Loading model')
    rknn.load_tensorflow(tf_pb='./output_inference_graph/frozen_inference_graph.pb',
                         inputs=['input'],

                         outputs=['concat', 'concat_1'],
                         input_size_list=[[INPUT_SIZE, INPUT_SIZE, 3]])
    print('done')

    # Build Model
    print('--> Building model')
    rknn.build(do_quantization=False, dataset='./dataset.txt')
    print('done')


转换模型失败。原因应该是加载模型的时候失败了
Traceback (most recent call last):  File "D:/Work/develop_file/rknn-toolkit-v1.3.0/rknn-toolkit-v1.3.0/examples/tensorflow/event_v1/conversion_model.py", line 47, in <module>    convert_model()  File "D:/Work/develop_file/rknn-toolkit-v1.3.0/rknn-toolkit-v1.3.0/examples/tensorflow/event_v1/conversion_model.py", line 38, in convert_model    rknn.build(do_quantization=False, dataset='./dataset.txt')  File "D:\Users\yajin\anaconda3\envs\MLenv\lib\site-packages\rknn\api\rknn.py", line 220, in build    inputs = self.rknn_base.net.get_input_layers()AttributeError: 'NoneType' object has no attribute 'get_input_layers'想请教一下,rknn.load_tensorflow()这个方法的input参数指的是什么?怎么去找到这个input模型介绍:ssd_mobilenet_v2预训练模型经过迁移学习得到。
作者: leok    时间: 2020-8-7 16:26
1、请看官方给的例子,输入、输出节点需要选择。
2、接口说明请看文档https://github.com/rockchip-linux/rknn-toolkit/tree/master/doc
作者: senna_kim    时间: 2020-8-8 14:32
我是按照官方文档填写的,但是还是会报加载模型错误的情况
作者: senna_kim    时间: 2020-8-10 14:17
转换模型的时候,源模型必须是由版本为1.14以下TensorFlow生成的.pb文件才可以进行转换吗?
作者: leok    时间: 2020-8-11 08:56
senna_kim 发表于 2020-8-10 14:17
转换模型的时候,源模型必须是由版本为1.14以下TensorFlow生成的.pb文件才可以进行转换吗? ...

https://github.com/rockchip-linu ... olkit_V1.3.2_CN.pdf
文档里头有说明。
1.3.0 rknn toolkit匹配的tf版本是>=1.10.0,
<=1.13.2
作者: senna_kim    时间: 2020-8-11 14:16
leok 发表于 2020-8-11 08:56
https://github.com/rockchip-linux/rknn-toolkit/tree/master/doc/Rockchip_Trouble_Shooting_RKNN_Tool ...

'''Try match FusedBatchNormV3 FeatureExtractor/MobilenetV2/layer_19_2_Conv2d_5_3x3_s2_128/BatchNorm/FusedBatchNormV3 failed, catch exception!
E Catch exception when loading tensorflow model: ./output_inference_graph_v2/output_inference_graph_v2/frozen_inference_graph.pb!
E Traceback (most recent call last):
E   File "rknn\base\RKNNlib\converter\convert_tf.py", line 643, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
E   File "rknn\base\RKNNlib\RKNNnet.py", line 189, in rknn.base.RKNNlib.RKNNnet.RKNNNet.new_layer
E   File "rknn\base\RKNNlib\RKNNlog.py", line 327, in rknn.base.RKNNlib.RKNNlog.RKNNLog.e
E ValueError: Unknow layer "fusedbatchnormv3"
E During handling of the above exception, another exception occurred:
E Traceback (most recent call last):
E   File "rknn\api\rknn_base.py", line 303, in rknn.api.rknn_base.RKNNBase.load_tensorflow
E   File "rknn\base\RKNNlib\converter\convert_tf.py", line 742, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
E   File "rknn\base\RKNNlib\RKNNlog.py", line 327, in rknn.base.RKNNlib.RKNNlog.RKNNLog.e
E ValueError: Try match FusedBatchNormV3 FeatureExtractor/MobilenetV2/layer_19_2_Conv2d_5_3x3_s2_128/BatchNorm/FusedBatchNormV3 failed, catch exception!'''

出现以上错误,是不是说明我需要自己定义未知的op?




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