benderthon/tf_freeze.py
def freeze_from_checkpoint(input_checkpoint, output_file_path, output_node_names):
    """Freeze and shrink the graph based on a checkpoint and the output node names."""
    check_input_checkpoint(input_checkpoint)

    output_node_names = output_node_names_string_as_list(output_node_names)

    with tf.Session() as sess:
        restore_from_checkpoint(sess, input_checkpoint)
        freeze_graph.freeze_graph_with_def_protos(input_graph_def=sess.graph_def, input_saver_def=None,
                                                  input_checkpoint=input_checkpoint,
                                                  output_node_names=','.join(output_node_names),
                                                  restore_op_name='save/restore_all',
                                                  filename_tensor_name='save/Const:0', output_graph=output_file_path,
                                                  clear_devices=True, initializer_nodes='')
def freeze_from_checkpoint(input_checkpoint, output_file_path, output_node_names):
    check_input_checkpoint(input_checkpoint)

    output_node_names = output_node_names_string_as_list(output_node_names)

    with tf.Session() as sess:
        restore_from_checkpoint(sess, input_checkpoint)
        freeze_graph.freeze_graph_with_def_protos(input_graph_def=sess.graph_def, input_saver_def=None,
                                                  input_checkpoint=input_checkpoint,
                                                  output_node_names=','.join(output_node_names),
                                                  restore_op_name='save/restore_all',
                                                  filename_tensor_name='save/Const:0', output_graph=output_file_path,
                                                  clear_devices=True, initializer_nodes='')
def freeze_from_checkpoint ( input_checkpoint , output_file_path , output_node_names ) : check_input_checkpoint ( input_checkpoint ) output_node_names = output_node_names_string_as_list ( output_node_names ) with tf . Session ( ) as sess : restore_from_checkpoint ( sess , input_checkpoint ) freeze_graph . freeze_graph_with_def_protos ( input_graph_def = sess . graph_def , input_saver_def = None , input_checkpoint = input_checkpoint , output_node_names = ',' . join ( output_node_names ) , restore_op_name = 'save/restore_all' , filename_tensor_name = 'save/Const:0' , output_graph = output_file_path , clear_devices = True , initializer_nodes = '' )
Freeze and shrink the graph based on a checkpoint and the output node names.
Freeze and shrink the graph based on a checkpoint and the output node names .