Forked from matpalm/gist:23dc5804c6d673b800093d0d15e5de0e
Created
April 21, 2018 11:31
-
-
Save vyraun/5e81223870732e5bd088d06b4c30fc99 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
#!/usr/bin/env python3 | |
from PIL import Image | |
import numpy as np | |
import tensorflow as tf | |
import tensorflow_hub as hub | |
# smooth values from point a to point b. | |
STEPS = 100 | |
pt_a = np.random.normal(size=(512)) | |
pt_b = np.random.normal(size=(512)) | |
z = np.empty((STEPS, 512)) | |
for i, alpha in enumerate(np.linspace(start=0.0, stop=1.0, num=STEPS)): | |
z[i] = alpha * pt_a + (1.0-alpha) * pt_b | |
# sample all z and write out as separate images. | |
generator = hub.Module("https://tfhub.dev/google/progan-128/1") | |
with tf.Session() as sess: | |
sess.run(tf.global_variables_initializer()) | |
imgs = sess.run(generator(z)) | |
imgs = (imgs * 255).astype(np.uint8) | |
for i, img in enumerate(imgs): | |
Image.fromarray(img).save("foo_%02d.png" % i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment