示例#1
0
def precompute_gram_matrices(image, final_endpoint='fc8'):
  """Pre-computes the Gram matrices on a given image.

  Args:
    image: 4-D tensor. Input (batch of) image(s).
    final_endpoint: str, name of the final layer to compute Gram matrices for.
        Defaults to 'fc8'.

  Returns:
    dict mapping layer names to their corresponding Gram matrices.
  """
  with tf.Session() as session:
    end_points = vgg.vgg_16(image, final_endpoint=final_endpoint)
    tf.train.Saver(slim.get_variables('vgg_16')).restore(
        session, vgg.checkpoint_file())
    return dict((key, gram_matrix(value).eval())
                for key, value in end_points.items())
示例#2
0
 def init_fn_train(session):
     saver_vgg.restore(session, vgg.checkpoint_file())
示例#3
0
 def init_fn(session):
     saver.restore(session, vgg.checkpoint_file())
示例#4
0
 def init_fn_finetune(session):
     saver_vgg.restore(session, vgg.checkpoint_file())
     saver_n_styles.restore(
         session, os.path.expanduser(FLAGS.checkpoint))