Toybrick

运行mobilenetssd-v2 无法转换 rknn 模型

摇太阳

注册会员

积分
132
发表于 2019-7-19 14:06:27    查看: 9806|回复: 1 | [复制链接]    打印 | 显示全部楼层
系统:fedora28
toolkit版本: 1.0.0
tensorflow版本: 1.10.1




按照官方的训练步骤重新训练了pb文件
用mobilenetssd-v2 step1.py 无法转换
不知道什么原因 谢谢指导~~~


step1.py 代码

import numpy as np
import cv2
from rknn.api import RKNN


if __name__ == '__main__':


    # Create RKNN object
    rknn = RKNN(verbose = True, verbose_file =  './Error.log')
   
    # pre-process config
    print('--> config model')
    rknn.config(channel_mean_value='127.5 127.5 127.5 128', reorder_channel='0 1 2', quantized_dtype='asymmetric_quantized-u8')
    print('done')


    # Load tflite model
    print('--> Loading model')
    ret = rknn.load_tensorflow(tf_pb='./frozen_inference_graph.pb',
                               inputs=['FeatureExtractor/MobilenetV2/MobilenetV2/input'],
                               outputs=['concat_1', 'concat'],
                               input_size_list=[[300,300,3]],
                               predef_file=None)
    if ret != 0:
        print('Load model failed!')
        exit(ret)
    print('done')


    if ret != 0:
        print('Load model failed!')
        exit(ret)
    print('done')


    # Build model
    print('--> hybrid_quantization_step1')
    ret = rknn.hybrid_quantization_step1(dataset='./dataset.txt')
    if ret != 0:
        print('hybrid_quantization_step1 failed!')
        exit(ret)
    print('done')


    # Tips
    print('Please modify ssd_mobilenet_v2.quantization.cfg!')
    print('==================================================================================================')
    print('Modify method:')
    print('1. delete @FeatureExtractor/MobilenetV2/expanded_conv/depthwise/depthwise_227:weight and its value')
    print('2. delete @FeatureExtractor/MobilenetV2/expanded_conv/depthwise/depthwise_227:bias and its value')
    print('3. delete @FeatureExtractor/MobilenetV2/Conv/Relu6_228ut0 and its value')
    print('==================================================================================================')
    print('Original quantization profile and modified quantization profile diff shows in file quantization_profile.diff')


    rknn.release()




报错信息:


E Catch exception when loading tensorflow model: ./frozen_inference_graph.pb!
T Traceback (most recent call last):
T   File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 418, in import_graph_def
T     graph._c_graph, serialized, options)  # pylint: disable=protected-access
T tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'explicit_paddings' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]; attr=dilations:list(int),default=[1, 1, 1, 1]>; NodeDef: FeatureExtractor/MobilenetV2/Conv/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true](FeatureExtractor/MobilenetV2/MobilenetV2/input, FeatureExtractor/MobilenetV2/Conv/weights). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
T During handling of the above exception, another exception occurred:
T Traceback (most recent call last):
T   File "rknn/api/rknn_base.py", line 137, in rknn.api.rknn_base.RKNNBase.load_tensorflow
T   File "rknn/base/RKNNlib/converter/convert_tf.py", line 482, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.pre_process
T   File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 102, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.pre_proces
T   File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 627, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.calc_2_const
T   File "rknn/base/RKNNlib/converter/tf_util.py", line 371, in rknn.base.RKNNlib.converter.tf_util.TFProto_Util.query_tensor
T   File "rknn/base/RKNNlib/converter/tf_util.py", line 372, in rknn.base.RKNNlib.converter.tf_util.TFProto_Util.query_tensor
T   File "/usr/local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
T     return func(*args, **kwargs)
T   File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 422, in import_graph_def
T     raise ValueError(str(e))
T ValueError: NodeDef mentions attr 'explicit_paddings' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]; attr=dilations:list(int),default=[1, 1, 1, 1]>; NodeDef: FeatureExtractor/MobilenetV2/Conv/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true](FeatureExtractor/MobilenetV2/MobilenetV2/input, FeatureExtractor/MobilenetV2/Conv/weights). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).


回复

使用道具 举报

troy

版主

积分
2358
发表于 2019-7-26 08:42:39 | 显示全部楼层
是不是你的pb文件是高版本的TensorFlow生成的,上面日志,报错的点在TensorFlow里面。
回复

使用道具 举报

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

本版积分规则

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


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