想要调用他人保存的pb或lite模型时往往需要查看模型结构,输入节点类型等,总结一些方法
首先考虑使用Netron看图,还有命令行中使用命令的方式,这里总结利用python
.Lite模型
interpreter = tf.contrib.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
print(str(input_details))
output_details = interpreter.get_output_details()
print(str(output_details))
.pb模型
使用tensorboard
inception_graph_def_file = '/home/huang/huang/model/inception/classify_image_graph_def.pb'
with tf.Session() as sess:
#创建一个图来存放google训练好的模型
with tf.gfile.GFile(inception_graph_def_file, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
#保存图的结构
writer = tf.su