interfacegan_pp / utils /image_manip.py
ybelkada's picture
add new files
b260763
raw
history blame
805 Bytes
import numpy as np
import PIL
def concat_images(generated_images, modified_generated_images):
"""Shows images in one figure."""
concatenated_array_genenerated_images = np.concatenate([np.array(image) for image in generated_images], axis=1)
concatenated_array_modified_generated_images = np.concatenate([np.array(image) for image in modified_generated_images], axis=1)
return [PIL.Image.fromarray(concatenated_array_genenerated_images), PIL.Image.fromarray(concatenated_array_modified_generated_images)]
def tensor_to_pil(input_object):
if isinstance(input_object, dict):
im_array = []
images = input_object['image']
else:
images = input_object
for _, image in enumerate(images):
im_array.append(PIL.Image.fromarray(image))
return im_array