def save_np_image(image, output_file, save_format='jpeg'):
"""Saves an image to disk.
Args:
image: 3-D numpy array of shape [image_size, image_size, 3] and dtype
float32, with values in [0, 1].
output_file: str, output file.
save_format: format for saving image (eg. jpeg).
"""
image = np.uint8(image * 255.0)
buf = io.BytesIO()
scipy.misc.imsave(buf, np.squeeze(image, 0), format=save_format)
buf.seek(0)
f = tf.gfile.GFile(output_file, 'w')
f.write(buf.getvalue())
f.close()
评论列表
文章目录