Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def generator_output(sess, n_images, input_z, output_channel_dim, image_mode, image_path):
"""
Save output from the generator.
Arguments:
----------
:param sess: TensorFlow session
:param n_images: Number of Images to display
:param input_z: Input Z Tensor (noise vector)
:param output_channel_dim: The number of channels in the output image
:param image_mode: The mode to use for images ("RGB" or "L")
:param image_path: Path to save the generated image
----------
"""
cmap = None if image_mode == 'RGB' else 'gray'
z_dimension = input_z.get_shape().as_list()[-1]
example_z = np.random.uniform(-1, 1, size=[n_images, z_dimension])
samples = sess.run(
build_generator(input_z, output_channel_dim, False),
feed_dict={input_z: example_z})
images_grid = helper.images_square_grid(samples, image_mode)
# Save image to the image path
images_grid.save(image_path, 'JPEG')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment