Python util.get_inception_scores() Examples
The following are 8
code examples of util.get_inception_scores().
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
util
, or try the search function
.
Example #1
Source File: util_test.py From yolo_v2 with Apache License 2.0 | 5 votes |
def test_get_inception_scores(self, mock_inception_score): mock_inception_score.return_value = 1.0 util.get_inception_scores( tf.placeholder(tf.float32, shape=[None, 28, 28, 3]), batch_size=100, num_inception_images=10) # Mock `frechet_inception_distance` which is expensive.
Example #2
Source File: util_test.py From Gun-Detector with Apache License 2.0 | 5 votes |
def test_get_inception_scores(self, mock_inception_score): mock_inception_score.return_value = 1.0 util.get_inception_scores( tf.placeholder(tf.float32, shape=[None, 28, 28, 3]), batch_size=100, num_inception_images=10) # Mock `frechet_inception_distance` which is expensive.
Example #3
Source File: util_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
def test_get_inception_scores(self, mock_inception_score): mock_inception_score.return_value = 1.0 util.get_inception_scores( tf.placeholder(tf.float32, shape=[None, 28, 28, 3]), batch_size=100, num_inception_images=10) # Mock `frechet_inception_distance` which is expensive.
Example #4
Source File: util_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def test_get_inception_scores(self, mock_inception_score): mock_inception_score.return_value = 1.0 util.get_inception_scores( tf.placeholder(tf.float32, shape=[None, 28, 28, 3]), batch_size=100, num_inception_images=10) # Mock `frechet_inception_distance` which is expensive.
Example #5
Source File: util_test.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def test_get_inception_scores(self, mock_inception_score): mock_inception_score.return_value = 1.0 util.get_inception_scores( tf.placeholder(tf.float32, shape=[None, 28, 28, 3]), batch_size=100, num_inception_images=10) # Mock `frechet_inception_distance` which is expensive.
Example #6
Source File: eval.py From yolo_v2 with Apache License 2.0 | 4 votes |
def main(_, run_eval_loop=True): # Fetch and generate images to run through Inception. with tf.name_scope('inputs'): real_data, num_classes = _get_real_data( FLAGS.num_images_generated, FLAGS.dataset_dir) generated_data = _get_generated_data( FLAGS.num_images_generated, FLAGS.conditional_eval, num_classes) # Compute Frechet Inception Distance. if FLAGS.eval_frechet_inception_distance: fid = util.get_frechet_inception_distance( real_data, generated_data, FLAGS.num_images_generated, FLAGS.num_inception_images) tf.summary.scalar('frechet_inception_distance', fid) # Compute normal Inception scores. if FLAGS.eval_real_images: inc_score = util.get_inception_scores( real_data, FLAGS.num_images_generated, FLAGS.num_inception_images) else: inc_score = util.get_inception_scores( generated_data, FLAGS.num_images_generated, FLAGS.num_inception_images) tf.summary.scalar('inception_score', inc_score) # If conditional, display an image grid of difference classes. if FLAGS.conditional_eval and not FLAGS.eval_real_images: reshaped_imgs = util.get_image_grid( generated_data, FLAGS.num_images_generated, num_classes, FLAGS.num_images_per_class) tf.summary.image('generated_data', reshaped_imgs, max_outputs=1) # Create ops that write images to disk. image_write_ops = None if FLAGS.conditional_eval: reshaped_imgs = util.get_image_grid( generated_data, FLAGS.num_images_generated, num_classes, FLAGS.num_images_per_class) uint8_images = data_provider.float_image_to_uint8(reshaped_imgs) image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_cifar10.png'), tf.image.encode_png(uint8_images[0])) else: if FLAGS.num_images_generated >= 100: reshaped_imgs = tfgan.eval.image_reshaper( generated_data[:100], num_cols=FLAGS.num_images_per_class) uint8_images = data_provider.float_image_to_uint8(reshaped_imgs) image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'unconditional_cifar10.png'), tf.image.encode_png(uint8_images[0])) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, master=FLAGS.master, 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 #7
Source File: eval.py From Gun-Detector with Apache License 2.0 | 4 votes |
def main(_, run_eval_loop=True): # Fetch and generate images to run through Inception. with tf.name_scope('inputs'): real_data, num_classes = _get_real_data( FLAGS.num_images_generated, FLAGS.dataset_dir) generated_data = _get_generated_data( FLAGS.num_images_generated, FLAGS.conditional_eval, num_classes) # Compute Frechet Inception Distance. if FLAGS.eval_frechet_inception_distance: fid = util.get_frechet_inception_distance( real_data, generated_data, FLAGS.num_images_generated, FLAGS.num_inception_images) tf.summary.scalar('frechet_inception_distance', fid) # Compute normal Inception scores. if FLAGS.eval_real_images: inc_score = util.get_inception_scores( real_data, FLAGS.num_images_generated, FLAGS.num_inception_images) else: inc_score = util.get_inception_scores( generated_data, FLAGS.num_images_generated, FLAGS.num_inception_images) tf.summary.scalar('inception_score', inc_score) # If conditional, display an image grid of difference classes. if FLAGS.conditional_eval and not FLAGS.eval_real_images: reshaped_imgs = util.get_image_grid( generated_data, FLAGS.num_images_generated, num_classes, FLAGS.num_images_per_class) tf.summary.image('generated_data', reshaped_imgs, max_outputs=1) # Create ops that write images to disk. image_write_ops = None if FLAGS.conditional_eval and FLAGS.write_to_disk: reshaped_imgs = util.get_image_grid( generated_data, FLAGS.num_images_generated, num_classes, FLAGS.num_images_per_class) uint8_images = data_provider.float_image_to_uint8(reshaped_imgs) image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_cifar10.png'), tf.image.encode_png(uint8_images[0])) else: if FLAGS.num_images_generated >= 100 and FLAGS.write_to_disk: reshaped_imgs = tfgan.eval.image_reshaper( generated_data[:100], num_cols=FLAGS.num_images_per_class) uint8_images = data_provider.float_image_to_uint8(reshaped_imgs) image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'unconditional_cifar10.png'), tf.image.encode_png(uint8_images[0])) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, master=FLAGS.master, 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: eval.py From object_detection_with_tensorflow with MIT License | 4 votes |
def main(_, run_eval_loop=True): # Fetch and generate images to run through Inception. with tf.name_scope('inputs'): real_data, num_classes = _get_real_data( FLAGS.num_images_generated, FLAGS.dataset_dir) generated_data = _get_generated_data( FLAGS.num_images_generated, FLAGS.conditional_eval, num_classes) # Compute Frechet Inception Distance. if FLAGS.eval_frechet_inception_distance: fid = util.get_frechet_inception_distance( real_data, generated_data, FLAGS.num_images_generated, FLAGS.num_inception_images) tf.summary.scalar('frechet_inception_distance', fid) # Compute normal Inception scores. if FLAGS.eval_real_images: inc_score = util.get_inception_scores( real_data, FLAGS.num_images_generated, FLAGS.num_inception_images) else: inc_score = util.get_inception_scores( generated_data, FLAGS.num_images_generated, FLAGS.num_inception_images) tf.summary.scalar('inception_score', inc_score) # If conditional, display an image grid of difference classes. if FLAGS.conditional_eval and not FLAGS.eval_real_images: reshaped_imgs = util.get_image_grid( generated_data, FLAGS.num_images_generated, num_classes, FLAGS.num_images_per_class) tf.summary.image('generated_data', reshaped_imgs, max_outputs=1) # Create ops that write images to disk. image_write_ops = None if FLAGS.conditional_eval: reshaped_imgs = util.get_image_grid( generated_data, FLAGS.num_images_generated, num_classes, FLAGS.num_images_per_class) uint8_images = data_provider.float_image_to_uint8(reshaped_imgs) image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'conditional_cifar10.png'), tf.image.encode_png(uint8_images[0])) else: if FLAGS.num_images_generated >= 100: reshaped_imgs = tfgan.eval.image_reshaper( generated_data[:100], num_cols=FLAGS.num_images_per_class) uint8_images = data_provider.float_image_to_uint8(reshaped_imgs) image_write_ops = tf.write_file( '%s/%s'% (FLAGS.eval_dir, 'unconditional_cifar10.png'), tf.image.encode_png(uint8_images[0])) # For unit testing, use `run_eval_loop=False`. if not run_eval_loop: return tf.contrib.training.evaluate_repeatedly( FLAGS.checkpoint_dir, master=FLAGS.master, 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)