MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / merge

Function merge

GAN/Self_attention_GAN_tensorflow/utils.py:89–107  ·  view source on GitHub ↗
(images, size)

Source from the content-addressed store, hash-verified

87 return imsave(inverse_transform(images), size, image_path)
88
89def merge(images, size):
90 h, w = images.shape[1], images.shape[2]
91 if (images.shape[3] in (3,4)):
92 c = images.shape[3]
93 img = np.zeros((h * size[0], w * size[1], c))
94 for idx, image in enumerate(images):
95 i = idx % size[1]
96 j = idx // size[1]
97 img[j * h:j * h + h, i * w:i * w + w, :] = image
98 return img
99 elif images.shape[3]==1:
100 img = np.zeros((h * size[0], w * size[1]))
101 for idx, image in enumerate(images):
102 i = idx % size[1]
103 j = idx // size[1]
104 img[j * h:j * h + h, i * w:i * w + w] = image[:,:,0]
105 return img
106 else:
107 raise ValueError('in merge(images,size) images parameter ''must have dimensions: HxW or HxWx3 or HxWx4')
108
109def imsave(images, size, path):
110 # image = np.squeeze(merge(images, size)) # 채널이 1인거 제거 ?

Callers 1

imsaveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected