Created
June 15, 2019 05:38
-
-
Save jxcodetw/c9917f591255fd68b13e4a76ccab1886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# draw a bunch of samples | |
def random_walk(png, Gs, cx, cy, cw, ch, step, seeds): | |
print(png) | |
latents = np.stack(np.random.RandomState(seed).randn(Gs.input_shape[1]) for seed in seeds) | |
# images = Gs.run(latents, None, **synthesis_kwargs) # [seed, y, x, rgb] | |
idx = 0 | |
for idxx, (l1, l2) in enumerate(zip(latents, latents[1:])): | |
print(idxx, '/', len(latents)) | |
latent = np.stack([l1 * (1-alpha) + l2 * alpha for alpha in np.linspace(0, 1, step)]) | |
dlatents = Gs.components.mapping.run(latent, None) | |
imgs = Gs.components.synthesis.run(dlatents, randomize_noise=False, **synthesis_kwargs) | |
for img in imgs: | |
img = PIL.Image.fromarray(img, 'RGB') | |
img.save(os.path.join(png, '{:05d}.png'.format(idx))) | |
idx += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment