Last active
October 20, 2020 10:05
-
-
Save merishnaSuwal/d4d97809db758625609fa7ac0fe5ba2a to your computer and use it in GitHub Desktop.
This file contains 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
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