Spaces:
Runtime error
Runtime error
bug fix for generating only 1 image
Browse files- image_generator.py +5 -3
image_generator.py
CHANGED
@@ -117,6 +117,7 @@ def generate_images(
|
|
117 |
|
118 |
#imgs_row = np.array()
|
119 |
#imgs_complete = np.array()
|
|
|
120 |
for seed_idx, seed in enumerate(seeds):
|
121 |
print('Generating image for seed %d (%d/%d) ...' % (seed, seed_idx, len(seeds)))
|
122 |
z = torch.from_numpy(np.random.RandomState(seed).randn(1, G.z_dim)).to(device).float()
|
@@ -131,18 +132,19 @@ def generate_images(
|
|
131 |
img = G(z, label, truncation_psi=truncation_psi, noise_mode=noise_mode)
|
132 |
img = (img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8)
|
133 |
print(seed_idx)
|
|
|
134 |
#first image
|
135 |
if seed_idx == 0:
|
136 |
imgs_row = img[0].cpu().numpy()
|
137 |
else:
|
138 |
-
imgs_row = np.hstack((imgs_row, img[0].cpu().numpy()))
|
139 |
#img = PIL.Image.fromarray(img[0].cpu().numpy(), 'RGB')
|
140 |
#PIL.Image.fromarray(img[0].cpu().numpy(), 'RGB').save(f'{outdir}/seed{seed:04d}.png')
|
141 |
#napravi vsplit i toe to ka
|
142 |
-
imgs_complete = np.vstack(np.hsplit(imgs_row, 4))
|
143 |
#cv2.imshow("lalaxd", imgs_complete)
|
144 |
#cv2.waitKey()
|
145 |
-
return PIL.Image.fromarray(
|
146 |
|
147 |
|
148 |
#----------------------------------------------------------------------------
|
|
|
117 |
|
118 |
#imgs_row = np.array()
|
119 |
#imgs_complete = np.array()
|
120 |
+
print(seeds)
|
121 |
for seed_idx, seed in enumerate(seeds):
|
122 |
print('Generating image for seed %d (%d/%d) ...' % (seed, seed_idx, len(seeds)))
|
123 |
z = torch.from_numpy(np.random.RandomState(seed).randn(1, G.z_dim)).to(device).float()
|
|
|
132 |
img = G(z, label, truncation_psi=truncation_psi, noise_mode=noise_mode)
|
133 |
img = (img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8)
|
134 |
print(seed_idx)
|
135 |
+
"""
|
136 |
#first image
|
137 |
if seed_idx == 0:
|
138 |
imgs_row = img[0].cpu().numpy()
|
139 |
else:
|
140 |
+
imgs_row = np.hstack((imgs_row, img[0].cpu().numpy()))"""
|
141 |
#img = PIL.Image.fromarray(img[0].cpu().numpy(), 'RGB')
|
142 |
#PIL.Image.fromarray(img[0].cpu().numpy(), 'RGB').save(f'{outdir}/seed{seed:04d}.png')
|
143 |
#napravi vsplit i toe to ka
|
144 |
+
#imgs_complete = np.vstack(np.hsplit(imgs_row, 4))
|
145 |
#cv2.imshow("lalaxd", imgs_complete)
|
146 |
#cv2.waitKey()
|
147 |
+
return PIL.Image.fromarray(img, 'RGB')
|
148 |
|
149 |
|
150 |
#----------------------------------------------------------------------------
|