|
【技术讨论】
RKNN工具转换模型失败
发表于 2021-8-20 10:26:31
浏览:6145
|
回复:1
打印
只看该作者
[复制链接]
楼主
本帖最后由 zhuixunmengtu 于 2021-8-20 10:26 编辑
使用rknn转换模型时,报错。错误信息如下:
Use `tf.compat.v1.graph_util.extract_sub_graph`
E Catch exception when loading tensorflow model: model/db.pb!
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 140, in rknn.base.RKNNlib.app.importer.import_tensorflow.Importensorflow.run
E File "rknn/base/RKNNlib/converter/convert_tf.py", line 610, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.pre_process
E File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 100, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.pre_proces
E File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 825, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.calc_2_const
E File "rknn/base/RKNNlib/converter/tf_util.py", line 199, in rknn.base.RKNNlib.converter.tf_util.TFProto_Util.change_input
E IndexError: list index (216) out of range
Load model failed!
这个模型我自己编写了加载程序是可以正常运行的。
def load_pb(pb_file_path):
sess = tf.compat.v1.Session()
with gfile.FastGFile(pb_file_path, 'rb') as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
sess.graph.as_default()
tf.import_graph_def(graph_def, name='')
for name in sess.graph._nodes_by_name:
print(name)
input_x = sess.graph.get_tensor_by_name('Input:0')
img = np.ones((1,512,512,3), dtype=np.uint8)
#输出
op = sess.graph.get_tensor_by_name('output:0')
#预测结果
#print(sess.graph._nodes_by_name)
ret = sess.run(op, {input_x: img})
print(ret)
模型和文件见一下链接:
https://gitee.com/yuantanglaing/share
应用环境:
absl-py 0.13.0
asn1crypto 0.24.0
astor 0.8.1
certifi 2021.5.30
chardet 3.0.4
click 8.0.1
cryptography 2.1.4
dataclasses 0.8
decorator 5.0.9
dill 0.2.8.2
distro 1.6.0
Flask 1.0.2
flatbuffers 1.10
future 0.18.2
gast 0.5.2
google-pasta 0.2.0
graphviz 0.8.4
grpcio 1.39.0
h5py 2.8.0
idna 2.6
importlib-metadata 4.6.3
itsdangerous 2.0.1
Jinja2 3.0.1
joblib 1.0.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.2
keyring 10.6.0
keyrings.alt 3.0
lmdb 0.93
Markdown 3.3.4
MarkupSafe 2.0.1
mxnet 1.5.0
networkx 1.11
numpy 1.16.3
onnx 1.6.0
onnx-tf 1.2.1
opencv-python 4.5.3.56
packaging 21.0
Pillow 5.3.0
pip 21.2.3
ply 3.11
protobuf 3.11.2
psutil 5.6.2
pycrypto 2.6.1
PyGObject 3.26.1
pyparsing 2.4.7
pyxdg 0.25
PyYAML 5.4.1
requests 2.22.0
rknn-toolkit 1.6.0
ruamel.yaml 0.15.81
scikit-build 0.11.1
scikit-learn 0.24.2
scipy 1.3.0
SecretStorage 2.3.1
setuptools 57.4.0
six 1.11.0
sklearn 0.0
tensorboard 1.14.0
tensorflow-estimator 1.14.0
tensorflow-gpu 1.14.0
termcolor 1.1.0
threadpoolctl 2.2.0
torch 1.6.0
torchvision 0.7.0
typing-extensions 3.10.0.0
urllib3 1.25.11
Werkzeug 2.0.1
wheel 0.30.0
wrapt 1.12.1
zipp 3.5.0 |
|