INNER CODE UNIT · Python
image_numpy
Mukosame/Anime2Sketch · data.py:81
image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + 1) / 2.0 * 255.0 # post-processing: tranpose and scaling
else: # if it is a numpy array, do nothing
image_numpy = input_image
return image_numpy.astype(imtype)
def save_image(image_numpy, image_path, output_resize=None):
"""Save a numpy image to the disk
Parameters:
image_numpy (numpy array) -- input numpy array
image_path (str) -- the path of the image
output_resize(None or tuple) -- the output size. If None, don't resize
"""
image_pil = Image.fromarray(image_numpy)
if output_resize:
image_pil = image_pil.resize(output_resize, bic)
image_pil.save(image_path)