Python networks.conditional_generator() Examples
The following are 15
code examples of networks.conditional_generator().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
networks
, or try the search function
.
Example #1
Source File: eval.py From yolo_v2 with Apache License 2.0 | 6 votes |
def _get_generated_data(num_images_generated, conditional_eval, num_classes): """Get generated images.""" noise = tf.random_normal([num_images_generated, 64]) # If conditional, generate class-specific images. if conditional_eval: conditioning = util.get_generator_conditioning( num_images_generated, num_classes) generator_inputs = (noise, conditioning) generator_fn = networks.conditional_generator else: generator_inputs = noise generator_fn = networks.generator # In order for variables to load, use the same variable scope as in the # train job. with tf.variable_scope('Generator'): data = generator_fn(generator_inputs) return data
Example #2
Source File: eval.py From Gun-Detector with Apache License 2.0 | 6 votes |
def _get_generated_data(num_images_generated, conditional_eval, num_classes): """Get generated images.""" noise = tf.random_normal([num_images_generated, 64]) # If conditional, generate class-specific images. if conditional_eval: conditioning = util.get_generator_conditioning( num_images_generated, num_classes) generator_inputs = (noise, conditioning) generator_fn = networks.conditional_generator else: generator_inputs = noise generator_fn = networks.generator # In order for variables to load, use the same variable scope as in the # train job. with tf.variable_scope('Generator'): data = generator_fn(generator_inputs, is_training=False) return data
Example #3
Source File: eval.py From object_detection_with_tensorflow with MIT License | 6 votes |
def _get_generated_data(num_images_generated, conditional_eval, num_classes): """Get generated images.""" noise = tf.random_normal([num_images_generated, 64]) # If conditional, generate class-specific images. if conditional_eval: conditioning = util.get_generator_conditioning( num_images_generated, num_classes) generator_inputs = (noise, conditioning) generator_fn = networks.conditional_generator else: generator_inputs = noise generator_fn = networks.generator # In order for variables to load, use the same variable scope as in the # train job. with tf.variable_scope('Generator'): data = generator_fn(generator_inputs) return data
Example #4
Source File: eval.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def _get_generated_data(num_images_generated, conditional_eval, num_classes): """Get generated images.""" noise = tf.random_normal([num_images_generated, 64]) # If conditional, generate class-specific images. if conditional_eval: conditioning = util.get_generator_conditioning( num_images_generated, num_classes) generator_inputs = (noise, conditioning) generator_fn = networks.conditional_generator else: generator_inputs = noise generator_fn = networks.generator # In order for variables to load, use the same variable scope as in the # train job. with tf.variable_scope('Generator'): data = generator_fn(generator_inputs, is_training=False) return data
Example #5
Source File: eval.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def _get_generated_data(num_images_generated, conditional_eval, num_classes): """Get generated images.""" noise = tf.random_normal([num_images_generated, 64]) # If conditional, generate class-specific images. if conditional_eval: conditioning = util.get_generator_conditioning( num_images_generated, num_classes) generator_inputs = (noise, conditioning) generator_fn = networks.conditional_generator else: generator_inputs = noise generator_fn = networks.generator # In order for variables to load, use the same variable scope as in the # train job. with tf.variable_scope('Generator'): data = generator_fn(generator_inputs, is_training=False) return data
Example #6
Source File: networks_test.py From yolo_v2 with Apache License 2.0 | 5 votes |
def test_generator_conditional(self): tf.set_random_seed(1234) batch_size = 100 noise = tf.random_normal([batch_size, 64]) conditioning = tf.one_hot([0] * batch_size, 10) image = networks.conditional_generator((noise, conditioning)) with self.test_session(use_gpu=True) as sess: sess.run(tf.global_variables_initializer()) image_np = image.eval() self.assertAllEqual([batch_size, 32, 32, 3], image_np.shape) self.assertTrue(np.all(np.abs(image_np) <= 1))
Example #7
Source File: conditional_eval.py From yolo_v2 with Apache License 2.0 | 5 votes |
def main(_, run_eval_loop=True): with tf.name_scope('inputs'): noise, one_hot_labels = _get_generator_inputs( FLAGS.num_images_per_class, NUM_CLASSES, FLAGS.noise_dims) # Generate images. with tf.variable_scope('Generator'): # Same scope as in train job. images = networks.conditional_generator((noise, one_hot_labels)) # Visualize images. reshaped_img = tfgan.eval.image_reshaper( images, num_cols=FLAGS.num_images_per_class) tf.summary.image('generated_images', reshaped_img, max_outputs=1) # Calculate evaluation metrics. tf.summary.scalar('MNIST_Classifier_score', util.mnist_score(images, FLAGS.classifier_filename)) tf.summary.scalar('MNIST_Cross_entropy', util.mnist_cross_entropy( images, one_hot_labels, FLAGS.classifier_filename)) # Write images to disk. image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_gan.png'), tf.image.encode_png(data_provider.float_image_to_uint8(reshaped_img[0]))) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir), tf.contrib.training.StopAfterNEvalsHook(1)], eval_ops=image_write_ops, max_number_of_evaluations=FLAGS.max_number_of_evaluations)
Example #8
Source File: networks_test.py From Gun-Detector with Apache License 2.0 | 5 votes |
def test_generator_conditional(self): tf.set_random_seed(1234) batch_size = 100 noise = tf.random_normal([batch_size, 64]) conditioning = tf.one_hot([0] * batch_size, 10) image = networks.conditional_generator((noise, conditioning)) with self.test_session(use_gpu=True) as sess: sess.run(tf.global_variables_initializer()) image_np = image.eval() self.assertAllEqual([batch_size, 32, 32, 3], image_np.shape) self.assertTrue(np.all(np.abs(image_np) <= 1))
Example #9
Source File: conditional_eval.py From Gun-Detector with Apache License 2.0 | 5 votes |
def main(_, run_eval_loop=True): with tf.name_scope('inputs'): noise, one_hot_labels = _get_generator_inputs( FLAGS.num_images_per_class, NUM_CLASSES, FLAGS.noise_dims) # Generate images. with tf.variable_scope('Generator'): # Same scope as in train job. images = networks.conditional_generator( (noise, one_hot_labels), is_training=False) # Visualize images. reshaped_img = tfgan.eval.image_reshaper( images, num_cols=FLAGS.num_images_per_class) tf.summary.image('generated_images', reshaped_img, max_outputs=1) # Calculate evaluation metrics. tf.summary.scalar('MNIST_Classifier_score', util.mnist_score(images, FLAGS.classifier_filename)) tf.summary.scalar('MNIST_Cross_entropy', util.mnist_cross_entropy( images, one_hot_labels, FLAGS.classifier_filename)) # Write images to disk. image_write_ops = None if FLAGS.write_to_disk: image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_gan.png'), tf.image.encode_png(data_provider.float_image_to_uint8( reshaped_img[0]))) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir), tf.contrib.training.StopAfterNEvalsHook(1)], eval_ops=image_write_ops, max_number_of_evaluations=FLAGS.max_number_of_evaluations)
Example #10
Source File: networks_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
def test_generator_conditional(self): tf.set_random_seed(1234) batch_size = 100 noise = tf.random_normal([batch_size, 64]) conditioning = tf.one_hot([0] * batch_size, 10) image = networks.conditional_generator((noise, conditioning)) with self.test_session(use_gpu=True) as sess: sess.run(tf.global_variables_initializer()) image_np = image.eval() self.assertAllEqual([batch_size, 32, 32, 3], image_np.shape) self.assertTrue(np.all(np.abs(image_np) <= 1))
Example #11
Source File: conditional_eval.py From object_detection_with_tensorflow with MIT License | 5 votes |
def main(_, run_eval_loop=True): with tf.name_scope('inputs'): noise, one_hot_labels = _get_generator_inputs( FLAGS.num_images_per_class, NUM_CLASSES, FLAGS.noise_dims) # Generate images. with tf.variable_scope('Generator'): # Same scope as in train job. images = networks.conditional_generator((noise, one_hot_labels)) # Visualize images. reshaped_img = tfgan.eval.image_reshaper( images, num_cols=FLAGS.num_images_per_class) tf.summary.image('generated_images', reshaped_img, max_outputs=1) # Calculate evaluation metrics. tf.summary.scalar('MNIST_Classifier_score', util.mnist_score(images, FLAGS.classifier_filename)) tf.summary.scalar('MNIST_Cross_entropy', util.mnist_cross_entropy( images, one_hot_labels, FLAGS.classifier_filename)) # Write images to disk. image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_gan.png'), tf.image.encode_png(data_provider.float_image_to_uint8(reshaped_img[0]))) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir), tf.contrib.training.StopAfterNEvalsHook(1)], eval_ops=image_write_ops, max_number_of_evaluations=FLAGS.max_number_of_evaluations)
Example #12
Source File: networks_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def test_generator_conditional(self): tf.set_random_seed(1234) batch_size = 100 noise = tf.random_normal([batch_size, 64]) conditioning = tf.one_hot([0] * batch_size, 10) image = networks.conditional_generator((noise, conditioning)) with self.test_session(use_gpu=True) as sess: sess.run(tf.global_variables_initializer()) image_np = image.eval() self.assertAllEqual([batch_size, 32, 32, 3], image_np.shape) self.assertTrue(np.all(np.abs(image_np) <= 1))
Example #13
Source File: conditional_eval.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def main(_, run_eval_loop=True): with tf.name_scope('inputs'): noise, one_hot_labels = _get_generator_inputs( FLAGS.num_images_per_class, NUM_CLASSES, FLAGS.noise_dims) # Generate images. with tf.variable_scope('Generator'): # Same scope as in train job. images = networks.conditional_generator( (noise, one_hot_labels), is_training=False) # Visualize images. reshaped_img = tfgan.eval.image_reshaper( images, num_cols=FLAGS.num_images_per_class) tf.summary.image('generated_images', reshaped_img, max_outputs=1) # Calculate evaluation metrics. tf.summary.scalar('MNIST_Classifier_score', util.mnist_score(images, FLAGS.classifier_filename)) tf.summary.scalar('MNIST_Cross_entropy', util.mnist_cross_entropy( images, one_hot_labels, FLAGS.classifier_filename)) # Write images to disk. image_write_ops = None if FLAGS.write_to_disk: image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_gan.png'), tf.image.encode_png(data_provider.float_image_to_uint8( reshaped_img[0]))) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir), tf.contrib.training.StopAfterNEvalsHook(1)], eval_ops=image_write_ops, max_number_of_evaluations=FLAGS.max_number_of_evaluations)
Example #14
Source File: networks_test.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def test_generator_conditional(self): tf.set_random_seed(1234) batch_size = 100 noise = tf.random_normal([batch_size, 64]) conditioning = tf.one_hot([0] * batch_size, 10) image = networks.conditional_generator((noise, conditioning)) with self.test_session(use_gpu=True) as sess: sess.run(tf.global_variables_initializer()) image_np = image.eval() self.assertAllEqual([batch_size, 32, 32, 3], image_np.shape) self.assertTrue(np.all(np.abs(image_np) <= 1))
Example #15
Source File: conditional_eval.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def main(_, run_eval_loop=True): with tf.name_scope('inputs'): noise, one_hot_labels = _get_generator_inputs( FLAGS.num_images_per_class, NUM_CLASSES, FLAGS.noise_dims) # Generate images. with tf.variable_scope('Generator'): # Same scope as in train job. images = networks.conditional_generator( (noise, one_hot_labels), is_training=False) # Visualize images. reshaped_img = tfgan.eval.image_reshaper( images, num_cols=FLAGS.num_images_per_class) tf.summary.image('generated_images', reshaped_img, max_outputs=1) # Calculate evaluation metrics. tf.summary.scalar('MNIST_Classifier_score', util.mnist_score(images, FLAGS.classifier_filename)) tf.summary.scalar('MNIST_Cross_entropy', util.mnist_cross_entropy( images, one_hot_labels, FLAGS.classifier_filename)) # Write images to disk. image_write_ops = None if FLAGS.write_to_disk: image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_gan.png'), tf.image.encode_png(data_provider.float_image_to_uint8( reshaped_img[0]))) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, hooks=[tf.contrib.training.SummaryAtEndHook(FLAGS.eval_dir), tf.contrib.training.StopAfterNEvalsHook(1)], eval_ops=image_write_ops, max_number_of_evaluations=FLAGS.max_number_of_evaluations)