查看pb模型的节点
方法一:
import tensorflow as tf
import os
import cv2
#model_dir=frozen_inference_graph.pb"
# 读取并创建一个图graph来存放Google训练好的Inception_v3模型(函数)
def create_graph():
with tf.gfile.FastGFile(model_dir, 'rb') as f:
# 使用tf.GraphDef()定义一个空的Graph
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
# Imports the graph from graph_def into the current default Graph.
tf.import_graph_def(graph_def,name='')
# 创建graph
create_graph()
tensor_name_list = [tensor.name for tensor in tf.get_default_graph().as_graph_def().node]
for tensor_name in tensor_name_list:
print(tensor_name,'\n')
方法二:
import tensorflow as tf
import os
import cv2
with tf.Session() as sess:
with open(model_dir, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
print('>>>打印输入节点的结构如下:\n', graph_def.node[0])
print('*'*50,'\n')
print('>>>打印输出节点的结构如下:\n',graph_def.node[-1])
用方法一查看
export_tflite_ssd_graph.py生成的lite.pb模型报错,用方法二可以