import tensorflow as tf
from tensorflow.python.framework import graph_util
def ckpt2pb():
with tf.Graph().as_default() as graph_old:
isess = tf.InteractiveSession()
ckpt_filename = './yolov3.ckpt'
isess.run(tf.global_variables_initializer())
saver = tf.train.import_meta_graph(ckpt_filename+'.meta', clear_devices=True)
saver.restore(isess, ckpt_filename)
constant_graph = graph_util.convert_variables_to_constants(isess, isess.graph_def, ['yolov3/yolov3_head/feature_map_1','yolov3/yolov3_head/feature_map_2','yolov3/yolov3_head/feature_map_3'])
constant_graph = graph_util.remove_training_nodes(constant_graph)
with tf.gfile.GFile('./yolov3.pb', mode='wb') as f:
f.write(constant_graph.SerializeToString())
ckpt2pb_=ckpt2pb()
tensorflow ckpt转化到pb
最新推荐文章于 2021-09-10 10:05:22 发布