def _multiple_images(input_image, which_styles, output_dir):
"""Stylizes an image into a set of styles and writes them to disk."""
with tf.Graph().as_default(), tf.Session() as sess:
stylized_images = model.transform(
tf.concat([input_image for _ in range(len(which_styles))], 0),
normalizer_params={
'labels': tf.constant(which_styles),
'num_categories': FLAGS.num_styles,
'center': True,
'scale': True})
_load_checkpoint(sess, FLAGS.checkpoint)
stylized_images = stylized_images.eval()
for which, stylized_image in zip(which_styles, stylized_images):
image_utils.save_np_image(
stylized_image[None, ...],
'{}/{}_{}.png'.format(output_dir, FLAGS.output_basename, which))
评论列表
文章目录