TensorFlow: How to freeze a model and serve it with a python API 参考:https://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python-api-d4f3596b3adc 官方的源码:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/too
由于项目需要,需要将TensorFlow保存的模型从ckpt文件转换为pb文件. import os from tensorflow.python import pywrap_tensorflow from net2use import inception_resnet_v2_small#这里使用自己定义的模型函数即可 import tensorflow as tf if __name__=='__main__': pb_file = "./model/output.pb" ckpt_
参考网上的:https://github.com/tensorflow/tensorflow/issues/8854 import tensorflow as tf from tensorflow.python.platform import gfile with tf.Session() as sess: model_filename ='PATH_TO_PB.pb' with gfile.FastGFile(model_filename, 'rb') as f: graph_def = tf