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)