Tensorflow saved_model.pb 文件转成 saved_model.pbtxt文件

想把saved_model.pb里的metagraph转成可读。代码如下:

#将.pb文件load到session中,导出到.pbtxt可视化
import tensorflow as tf
from tensorflow.python.platform import gfile
tf.compat.v1.disable_eager_execution()

model = './savedmodel/VGG16/1/'
export_dir = './test/'
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
    tf.compat.v1.saved_model.load(sess,[tf.compat.v1.saved_model.tag_constants.SERVING],model)

    builder = tf.compat.v1.saved_model.Builder(export_dir)
    builder.add_meta_graph_and_variables(sess, [tf.compat.v1.saved_model.tag_constants.SERVING])
    builder.save(as_text=True)

 

你可能感兴趣的:(Tensorflow)