Skip to content

Instantly share code, notes, and snippets.

@matpalm
Created April 20, 2018 21:13
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matpalm/23dc5804c6d673b800093d0d15e5de0e to your computer and use it in GitHub Desktop.
Save matpalm/23dc5804c6d673b800093d0d15e5de0e to your computer and use it in GitHub Desktop.
#!/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