Toybrick

PB 模型转换RKNN 问题

wenzhu

注册会员

积分
58
发表于 2021-6-30 19:24:20    查看: 576|回复: 1 | [复制链接]    打印 | 显示全部楼层
python3 test.py
--> Loading model
W:tensorflow:From /home/tf/anaconda3/envs/rk1808_TFV1/lib/python3.6/site-packages/rknn/api/rknn.py:75: The name tf.GraphDef is deprecated. Please use tf.compat.v1.GraphDef instead.

W:tensorflow:From /home/tf/anaconda3/envs/rk1808_TFV1/lib/python3.6/site-packages/rknn/api/rknn.py:75: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
W:tensorflow:From /home/tf/anaconda3/envs/rk1808_TFV1/lib/python3.6/site-packages/rknn/api/rknn.py:75: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W:tensorflow:From /home/tf/anaconda3/envs/rk1808_TFV1/lib/python3.6/site-packages/rknn/api/rknn.py:75: The name tf.global_variables_initializer is deprecated. Please use tf.compat.v1.global_variables_initializer instead.

E Unknow layer "tensorarraygatherv3"
E Try match TensorArrayGatherV3 Postprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack/TensorArrayGatherV3 failed, catch exception!
E Catch exception when loading tensorflow model: 2_28.pb!
E Traceback (most recent call last):
E   File "rknn/base/RKNNlib/converter/convert_tf.py", line 750, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
E   File "rknn/base/RKNNlib/RKNNnet.py", line 211, in rknn.base.RKNNlib.RKNNnet.RKNNNet.new_layer
E   File "rknn/api/rknn_log.py", line 312, in rknn.api.rknn_log.RKNNLog.e
E ValueError: Unknow layer "tensorarraygatherv3"
E During handling of the above exception, another exception occurred:
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 209, in rknn.api.rknn_base.RKNNBase.load_tensorflow
E   File "rknn/base/RKNNlib/RK_nn.py", line 47, in rknn.base.RKNNlib.RK_nn.RKnn.load_tensorflow
E   File "rknn/base/RKNNlib/app/importer/import_tensorflow.py", line 232, in rknn.base.RKNNlib.app.importer.import_tensorflow.Importensorflow.run
E   File "rknn/base/RKNNlib/converter/convert_tf.py", line 849, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
E   File "rknn/api/rknn_log.py", line 312, in rknn.api.rknn_log.RKNNLog.e
E ValueError: Try match TensorArrayGatherV3 Postprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack/TensorArrayGatherV3 failed, catch exception!
done
--> Building model
Traceback (most recent call last):
  File "test.py", line 33, in <module>
    rknn.build(do_quantization=False)
  File "/home/tf/anaconda3/envs/rk1808_TFV1/lib/python3.6/site-packages/rknn/api/rknn.py", line 228, in build
    inputs = self.rknn_base.net.get_input_layers()
AttributeError: 'NoneType' object has no attribute 'get_input_layers'


cat test.py
from rknn.api import RKNN

INPUT_SIZE = 64

if __name__ == '__main__':
        # 创建RKNN执行对象
        rknn = RKNN()
        # 配置模型输入,用于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')
        rknn.config(reorder_channel='0 1 2')

        # 加载TensorFlow模型
        # tf_pb='digital_gesture.pb'指定待转换的TensorFlow模型
        # inputs指定模型中的输入节点
        # outputs指定模型中输出节点
        # input_size_list指定模型输入的大小
        print('--> Loading model')
        rknn.load_tensorflow(tf_pb='2_28.pb',
                                inputs=['image_tensor'],
                                outputs=['detection_boxes', 'detection_scores', 'detection_multiclass_scores', 'detection_classes', 'num_detections', 'raw_detection_boxes', 'raw_detection_scores'],
                                input_size_list=[[800, 600, 3]])
        print('done')

        # 创建解析pb模型
        #指定不进行量化,量化会减小模型的体积和提升运算速度,但是会有精度的丢失
        #do_quantization=False
        print('--> Building model')
        rknn.build(do_quantization=False)
        print('done')

        # 导出保存rknn模型文件
        rknn.export_rknn('./digital_gesture.rknn')
       
        # Release RKNN Context
        rknn.release()

想问下这是哪里问题?tensorarraygatherv3 Layer 不支持问题
回复

使用道具 举报

wenzhu

注册会员

积分
58
 楼主| 发表于 2021-7-1 10:30:06 | 显示全部楼层
斑竹能不能帮忙看下
回复

使用道具 举报

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

本版积分规则

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


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