Skip to content

Instantly share code, notes, and snippets.

Last active Feb 27, 2018
What would you like to do?
# git clone from
# download the snapshot from their Google drive
# use the following code in the same directory to generate random faces
import os
import sys
import time
import glob
import shutil
import operator
import theano
import lasagne
import dataset
import network
from theano import tensor as T
import config
import misc
import numpy as np
import scipy.ndimage
_, _, G = misc.load_pkl("network-snapshot-009041.pkl")
class Net: pass
net = Net()
net.G = G
import train
num_example_latents = 10
net.example_latents = train.random_latents(num_example_latents, net.G.input_shape)
net.example_labels = net.example_latents
net.latents_var = T.TensorType('float32', [False] * len(net.example_latents.shape))('latents_var')
net.labels_var = T.TensorType('float32', [False] * len(net.example_latents.shape)) ('labels_var')
net.images_expr = net.G.eval(net.latents_var, net.labels_var, ignore_unused_inputs=True)
net.images_expr = misc.adjust_dynamic_range(net.images_expr, [-1,1], [0,1])
images = net.gen_fn(net.example_latents[:1], net.example_labels[:1])
misc.save_image(images[0], "fake2b.png", drange=[0,1])

This comment has been minimized.

Copy link

@mtyka mtyka commented Oct 29, 2017

I think you want this ?
misc.save_image(images[0], "fake2b.png", drange=[0,1])
or better

for i in range(num_example_latents):
  misc.save_image(images[i], "fake2b.%05d.png"%i, drange=[0,1])

Thanks for posting, worked for me with their pre-trained models.


This comment has been minimized.

Copy link
Owner Author

@htoyryla htoyryla commented Oct 29, 2017

@mtyka, thanks. Should have tested the file before posting but was in a hurry to get this is out.


This comment has been minimized.

Copy link

@cohen5 cohen5 commented Nov 2, 2017

Hi, I cannot find the file 'network-snapshot-009041.pkl' on the Google Drive (I have '009601' and four other files).
Does anyone now where I can find it?


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment