File size: 805 Bytes
b260763
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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