benderthon/caffe_freeze.py
def freeze(caffe_def_path, caffemodel_path, inputs, output_file_path, output_node_names, graph_name='Graph',
           conversion_out_dir_path=None, checkpoint_out_path=None, use_padding_same=False):
    """Freeze and shrink the graph based on a Caffe model, the input tensors and the output node names."""
    with caffe_to_tensorflow_session(caffe_def_path, caffemodel_path, inputs, graph_name=graph_name,
                                     conversion_out_dir_path=conversion_out_dir_path,
                                     use_padding_same=use_padding_same) as sess:
        saver = tf.train.Saver()

        with (dummy_context_mgr(checkpoint_out_path) or util.TemporaryDirectory()) as temp_dir_path:
            checkpoint_path = checkpoint_out_path or os.path.join(temp_dir_path, 'pose.ckpt')
            saver.save(sess, checkpoint_path)

            output_node_names = util.output_node_names_string_as_list(output_node_names)

            tf_freeze.freeze_from_checkpoint(checkpoint_path, output_file_path, output_node_names)
def freeze(caffe_def_path, caffemodel_path, inputs, output_file_path, output_node_names, graph_name='Graph',
           conversion_out_dir_path=None, checkpoint_out_path=None, use_padding_same=False):
    with caffe_to_tensorflow_session(caffe_def_path, caffemodel_path, inputs, graph_name=graph_name,
                                     conversion_out_dir_path=conversion_out_dir_path,
                                     use_padding_same=use_padding_same) as sess:
        saver = tf.train.Saver()

        with (dummy_context_mgr(checkpoint_out_path) or util.TemporaryDirectory()) as temp_dir_path:
            checkpoint_path = checkpoint_out_path or os.path.join(temp_dir_path, 'pose.ckpt')
            saver.save(sess, checkpoint_path)

            output_node_names = util.output_node_names_string_as_list(output_node_names)

            tf_freeze.freeze_from_checkpoint(checkpoint_path, output_file_path, output_node_names)
def freeze ( caffe_def_path , caffemodel_path , inputs , output_file_path , output_node_names , graph_name = 'Graph' , conversion_out_dir_path = None , checkpoint_out_path = None , use_padding_same = False ) : with caffe_to_tensorflow_session ( caffe_def_path , caffemodel_path , inputs , graph_name = graph_name , conversion_out_dir_path = conversion_out_dir_path , use_padding_same = use_padding_same ) as sess : saver = tf . train . Saver ( ) with ( dummy_context_mgr ( checkpoint_out_path ) or util . TemporaryDirectory ( ) ) as temp_dir_path : checkpoint_path = checkpoint_out_path or os . path . join ( temp_dir_path , 'pose.ckpt' ) saver . save ( sess , checkpoint_path ) output_node_names = util . output_node_names_string_as_list ( output_node_names ) tf_freeze . freeze_from_checkpoint ( checkpoint_path , output_file_path , output_node_names )
Freeze and shrink the graph based on a Caffe model, the input tensors and the output node names.
Freeze and shrink the graph based on a Caffe model the input tensors and the output node names .