EAST
EAST copied to clipboard
inference using frozen pb can not gets the same result in contrast to original ckpt
as the title above, i tried lots of solutions in the internet, including one related in this issues, but the problem still remains, can anyone help?
my converting code as follows, i saved the pb in the init func
def init(self):
model_path = self.checkpoint_path
global_step = tf.get_variable('global_step', [], initializer=tf.constant_initializer(0), trainable=False)
self.input_images = tf.placeholder(tf.float32, shape=[None, None, None, 3], name='input_images')
self.f_score, self.f_geometry = model.model(self.input_images, is_training=False)
variable_averages = tf.train.ExponentialMovingAverage(0.997, global_step)
saver = tf.train.Saver(variable_averages.variables_to_restore())
config = tf.ConfigProto(allow_soft_placement=True)
config.gpu_options.per_process_gpu_memory_fraction = 0.3
self.sess = tf.Session(config=config)
# ckpt_state = tf.train.get_checkpoint_state(checkpoint_path)
# model_path = os.path.join(checkpoint_path, os.path.basename(ckpt_state.model_checkpoint_path))
print('Restore from {}'.format(model_path))
saver.restore(self.sess, model_path)
# 以下为转pb模块
input_graph_def = self.sess.graph.as_graph_def()
output_node_names = ["feature_fusion/Conv_7/Sigmoid", "feature_fusion/concat_3"]
graph = tf.graph_util.convert_variables_to_constants(self.sess, input_graph_def, output_node_names)
tf.train.write_graph(graph, ".", "angle_detection_1061530.pb", False)
I also encountered the same problem
I think I found the solution - "global_step" variable has to be blacklisted during the conversion/freezing of a model.
output_graph_def = graph_util.convert_variables_to_constants( sess, input_graph_def, ["feature_fusion/Conv_7/Sigmoid","feature_fusion/concat_3"], variable_names_blacklist="global_step")
did you solve the problem? @tsangsea