Skip to content

Instantly share code, notes, and snippets.

@merishnaSuwal
Last active October 20, 2020 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merishnaSuwal/d4d97809db758625609fa7ac0fe5ba2a to your computer and use it in GitHub Desktop.
Save merishnaSuwal/d4d97809db758625609fa7ac0fe5ba2a to your computer and use it in GitHub Desktop.
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