Python tensorflow.image_summary() Examples
The following are 30
code examples of tensorflow.image_summary().
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
tensorflow
, or try the search function
.
Example #1
Source File: Deblurring.py From TensorflowProjects with MIT License | 6 votes |
def inputs(): data_dir = os.path.join(FLAGS.data_dir, 'cifar-10-batches-bin') filenames = [os.path.join(data_dir, 'data_batch_%d.bin' % i) for i in xrange(1, 6)] for f in filenames: if not tf.gfile.Exists(f): raise ValueError('Failed to find file: ' + f) # Create a queue that produces the filenames to read. filename_queue = tf.train.string_input_producer(filenames) # Read examples from files in the filename queue. read_input = read_cifar10(filename_queue) num_preprocess_threads = 16 min_queue_examples = int(0.4 * NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN) input_images, ref_images = tf.train.shuffle_batch([read_input.noise_image, read_input.uint8image], batch_size=FLAGS.batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * FLAGS.batch_size, min_after_dequeue=min_queue_examples) tf.image_summary("Input_Noise_images", input_images) tf.image_summary("Ref_images", ref_images) return input_images, ref_images
Example #2
Source File: tfbasemodel.py From Supply-demand-forecasting with MIT License | 6 votes |
def get_input(self): # Input data. # Load the training, validation and test data into constants that are # attached to the graph. self.mnist = input_data.read_data_sets('data', one_hot=True, fake_data=False) # Input placehoolders with tf.name_scope('input'): self.x = tf.placeholder(tf.float32, [None, 784], name='x-input') self.y_true = tf.placeholder(tf.float32, [None, 10], name='y-input') self.keep_prob = tf.placeholder(tf.float32, name='drop_out') # below is just for the sake of visualization with tf.name_scope('input_reshape'): image_shaped_input = tf.reshape(self.x, [-1, 28, 28, 1]) tf.image_summary('input', image_shaped_input, 10) return
Example #3
Source File: cifarnet_preprocessing.py From Action_Recognition_Zoo with MIT License | 6 votes |
def preprocess_for_eval(image, output_height, output_width): """Preprocesses the given image for evaluation. Args: image: A `Tensor` representing an image of arbitrary size. output_height: The height of the image after preprocessing. output_width: The width of the image after preprocessing. Returns: A preprocessed image. """ tf.image_summary('image', tf.expand_dims(image, 0)) # Transform the image to floats. image = tf.to_float(image) # Resize and crop if needed. resized_image = tf.image.resize_image_with_crop_or_pad(image, output_width, output_height) tf.image_summary('resized_image', tf.expand_dims(resized_image, 0)) # Subtract off the mean and divide by the variance of the pixels. return tf.image.per_image_whitening(resized_image)
Example #4
Source File: cifarnet_preprocessing.py From ECO-pytorch with BSD 2-Clause "Simplified" License | 6 votes |
def preprocess_for_eval(image, output_height, output_width): """Preprocesses the given image for evaluation. Args: image: A `Tensor` representing an image of arbitrary size. output_height: The height of the image after preprocessing. output_width: The width of the image after preprocessing. Returns: A preprocessed image. """ tf.image_summary('image', tf.expand_dims(image, 0)) # Transform the image to floats. image = tf.to_float(image) # Resize and crop if needed. resized_image = tf.image.resize_image_with_crop_or_pad(image, output_width, output_height) tf.image_summary('resized_image', tf.expand_dims(resized_image, 0)) # Subtract off the mean and divide by the variance of the pixels. return tf.image.per_image_whitening(resized_image)
Example #5
Source File: trainer.py From how_to_convert_text_to_images with MIT License | 6 votes |
def visualization(self, n): fake_sum_train, superimage_train =\ self.visualize_one_superimage(self.fake_images[:n * n], self.images[:n * n], n, "train") fake_sum_test, superimage_test =\ self.visualize_one_superimage(self.fake_images[n * n:2 * n * n], self.images[n * n:2 * n * n], n, "test") self.superimages = tf.concat(0, [superimage_train, superimage_test]) self.image_summary = tf.merge_summary([fake_sum_train, fake_sum_test]) hr_fake_sum_train, hr_superimage_train =\ self.visualize_one_superimage(self.hr_fake_images[:n * n], self.hr_images[:n * n, :, :, :], n, "hr_train") hr_fake_sum_test, hr_superimage_test =\ self.visualize_one_superimage(self.hr_fake_images[n * n:2 * n * n], self.hr_images[n * n:2 * n * n], n, "hr_test") self.hr_superimages =\ tf.concat(0, [hr_superimage_train, hr_superimage_test]) self.hr_image_summary =\ tf.merge_summary([hr_fake_sum_train, hr_fake_sum_test])
Example #6
Source File: zap50k.py From gan-image-similarity with GNU General Public License v3.0 | 6 votes |
def zap_data(FLAGS, shuffle): files = glob(FLAGS.file_pattern) filename_queue = tf.train.string_input_producer( files, shuffle=shuffle, num_epochs=None if shuffle else 1) image = read_image(filename_queue, shuffle) # Mini batch num_preprocess_threads = 1 if FLAGS.debug else 4 min_queue_examples = 100 if FLAGS.debug else 10000 if shuffle: images = tf.train.shuffle_batch( image, batch_size=FLAGS.batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * FLAGS.batch_size, min_after_dequeue=min_queue_examples) else: images = tf.train.batch( image, FLAGS.batch_size, allow_smaller_final_batch=True) # tf.image_summary('images', images, max_images=8) return dict(batch=images, size=len(files))
Example #7
Source File: main.py From gan-image-similarity with GNU General Public License v3.0 | 6 votes |
def generator(z, latent_c): depths = [32, 64, 64, 64, 64, 64, 3] sizes = zip( np.linspace(4, IMAGE_SIZE['resized'][0], len(depths)).astype(np.int), np.linspace(6, IMAGE_SIZE['resized'][1], len(depths)).astype(np.int)) with slim.arg_scope([slim.conv2d_transpose], normalizer_fn=slim.batch_norm, kernel_size=3): with tf.variable_scope("gen"): size = sizes.pop(0) net = tf.concat(1, [z, latent_c]) net = slim.fully_connected(net, depths[0] * size[0] * size[1]) net = tf.reshape(net, [-1, size[0], size[1], depths[0]]) for depth in depths[1:-1] + [None]: net = tf.image.resize_images( net, sizes.pop(0), tf.image.ResizeMethod.NEAREST_NEIGHBOR) if depth: net = slim.conv2d_transpose(net, depth) net = slim.conv2d_transpose( net, depths[-1], activation_fn=tf.nn.tanh, stride=1, normalizer_fn=None) tf.image_summary("gen", net, max_images=8) return net
Example #8
Source File: trainer.py From StackGAN with MIT License | 6 votes |
def visualization(self, n): fake_sum_train, superimage_train =\ self.visualize_one_superimage(self.fake_images[:n * n], self.images[:n * n], n, "train") fake_sum_test, superimage_test =\ self.visualize_one_superimage(self.fake_images[n * n:2 * n * n], self.images[n * n:2 * n * n], n, "test") self.superimages = tf.concat(0, [superimage_train, superimage_test]) self.image_summary = tf.merge_summary([fake_sum_train, fake_sum_test]) hr_fake_sum_train, hr_superimage_train =\ self.visualize_one_superimage(self.hr_fake_images[:n * n], self.hr_images[:n * n, :, :, :], n, "hr_train") hr_fake_sum_test, hr_superimage_test =\ self.visualize_one_superimage(self.hr_fake_images[n * n:2 * n * n], self.hr_images[n * n:2 * n * n], n, "hr_test") self.hr_superimages =\ tf.concat(0, [hr_superimage_train, hr_superimage_test]) self.hr_image_summary =\ tf.merge_summary([hr_fake_sum_train, hr_fake_sum_test])
Example #9
Source File: cifar10.py From TensorFlow-Playground with MIT License | 5 votes |
def _generate_image_and_label_batch(image, label, min_queue_examples): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [IMAGE_SIZE, IMAGE_SIZE, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. labels: Labels. 1D tensor of [batch_size] size. """ # Create a queue that shuffles the examples, and then # read 'FLAGS.batch_size' images + labels from the example queue. num_preprocess_threads = 16 images, label_batch = tf.train.shuffle_batch( [image, label], batch_size=FLAGS.batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * FLAGS.batch_size, min_after_dequeue=min_queue_examples) # Display the training images in the visualizer. tf.image_summary('images', images) return images, tf.reshape(label_batch, [FLAGS.batch_size])
Example #10
Source File: trainer.py From how_to_convert_text_to_images with MIT License | 5 votes |
def visualize_one_superimage(self, img_var, images, rows, filename): stacked_img = [] for row in range(rows): img = images[row * rows, :, :, :] row_img = [img] # real image for col in range(rows): row_img.append(img_var[row * rows + col, :, :, :]) # each rows is 1realimage +10_fakeimage stacked_img.append(tf.concat(1, row_img)) imgs = tf.expand_dims(tf.concat(0, stacked_img), 0) current_img_summary = tf.image_summary(filename, imgs) return current_img_summary, imgs
Example #11
Source File: trainer.py From how_to_convert_text_to_images with MIT License | 5 votes |
def epoch_sum_images(self, sess, n): images_train, _, embeddings_train, captions_train, _ =\ self.dataset.train.next_batch(n * n, cfg.TRAIN.NUM_EMBEDDING) images_train = self.preprocess(images_train, n) embeddings_train = self.preprocess(embeddings_train, n) images_test, _, embeddings_test, captions_test, _ = \ self.dataset.test.next_batch(n * n, 1) images_test = self.preprocess(images_test, n) embeddings_test = self.preprocess(embeddings_test, n) images = np.concatenate([images_train, images_test], axis=0) embeddings =\ np.concatenate([embeddings_train, embeddings_test], axis=0) if self.batch_size > 2 * n * n: images_pad, _, embeddings_pad, _, _ =\ self.dataset.test.next_batch(self.batch_size - 2 * n * n, 1) images = np.concatenate([images, images_pad], axis=0) embeddings = np.concatenate([embeddings, embeddings_pad], axis=0) feed_dict = {self.images: images, self.embeddings: embeddings} gen_samples, img_summary =\ sess.run([self.superimages, self.image_summary], feed_dict) # save images generated for train and test captions scipy.misc.imsave('%s/train.jpg' % (self.log_dir), gen_samples[0]) scipy.misc.imsave('%s/test.jpg' % (self.log_dir), gen_samples[1]) # pfi_train = open(self.log_dir + "/train.txt", "w") pfi_test = open(self.log_dir + "/test.txt", "w") for row in range(n): # pfi_train.write('\n***row %d***\n' % row) # pfi_train.write(captions_train[row * n]) pfi_test.write('\n***row %d***\n' % row) pfi_test.write(captions_test[row * n]) # pfi_train.close() pfi_test.close() return img_summary
Example #12
Source File: trainer.py From how_to_convert_text_to_images with MIT License | 5 votes |
def visualization(self, n): fake_sum_train, superimage_train = \ self.visualize_one_superimage(self.fake_images[:n * n], self.images[:n * n], n, "train") fake_sum_test, superimage_test = \ self.visualize_one_superimage(self.fake_images[n * n:2 * n * n], self.images[n * n:2 * n * n], n, "test") self.superimages = tf.concat(0, [superimage_train, superimage_test]) self.image_summary = tf.merge_summary([fake_sum_train, fake_sum_test])
Example #13
Source File: trainer.py From how_to_convert_text_to_images with MIT License | 5 votes |
def visualize_one_superimage(self, img_var, images, rows, filename): stacked_img = [] for row in range(rows): img = images[row * rows, :, :, :] row_img = [img] # real image for col in range(rows): row_img.append(img_var[row * rows + col, :, :, :]) # each rows is 1realimage +10_fakeimage stacked_img.append(tf.concat(1, row_img)) imgs = tf.expand_dims(tf.concat(0, stacked_img), 0) current_img_summary = tf.image_summary(filename, imgs) return current_img_summary, imgs
Example #14
Source File: cifar10_input.py From dlbench with MIT License | 5 votes |
def _generate_image_and_label_batch(image, label, min_queue_examples, batch_size, shuffle): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. batch_size: Number of images per batch. shuffle: boolean indicating whether to use a shuffling queue. Returns: images: Images. 4D tensor of [batch_size, height, width, 3] size. labels: Labels. 1D tensor of [batch_size] size. """ # Create a queue that shuffles the examples, and then # read 'batch_size' images + labels from the example queue. num_preprocess_threads = 8 if shuffle: images, label_batch = tf.train.shuffle_batch( [image, label], batch_size=batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 16 * batch_size, min_after_dequeue=min_queue_examples) else: images, label_batch = tf.train.batch( [image, label], batch_size=batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 16 * batch_size) # Display the training images in the visualizer. #tf.image_summary('images', images) return images, tf.reshape(label_batch, [batch_size])
Example #15
Source File: cifarnet_preprocessing.py From ECO-pytorch with BSD 2-Clause "Simplified" License | 5 votes |
def preprocess_for_train(image, output_height, output_width, padding=_PADDING): """Preprocesses the given image for training. Note that the actual resizing scale is sampled from [`resize_size_min`, `resize_size_max`]. Args: image: A `Tensor` representing an image of arbitrary size. output_height: The height of the image after preprocessing. output_width: The width of the image after preprocessing. padding: The amound of padding before and after each dimension of the image. Returns: A preprocessed image. """ tf.image_summary('image', tf.expand_dims(image, 0)) # Transform the image to floats. image = tf.to_float(image) if padding > 0: image = tf.pad(image, [[padding, padding], [padding, padding], [0, 0]]) # Randomly crop a [height, width] section of the image. distorted_image = tf.random_crop(image, [output_height, output_width, 3]) # Randomly flip the image horizontally. distorted_image = tf.image.random_flip_left_right(distorted_image) tf.image_summary('distorted_image', tf.expand_dims(distorted_image, 0)) # Because these operations are not commutative, consider randomizing # the order their operation. distorted_image = tf.image.random_brightness(distorted_image, max_delta=63) distorted_image = tf.image.random_contrast(distorted_image, lower=0.2, upper=1.8) # Subtract off the mean and divide by the variance of the pixels. return tf.image.per_image_whitening(distorted_image)
Example #16
Source File: event_accumulator_test.py From tensorboard with Apache License 2.0 | 5 votes |
def testTFSummaryImage(self): """Verify processing of tf.summary.image.""" event_sink = _EventGenerator(self, zero_out_timestamps=True) with test_util.FileWriterCache.get(self.get_temp_dir()) as writer: writer.event_writer = event_sink with self.test_session() as sess: ipt = tf.ones([10, 4, 4, 3], tf.uint8) # This is an interesting example, because the old tf.image_summary op # would throw an error here, because it would be tag reuse. # Using the tf node name instead allows argument re-use to the image # summary. with tf.name_scope("1"): tf.compat.v1.summary.image("images", ipt, max_outputs=1) with tf.name_scope("2"): tf.compat.v1.summary.image("images", ipt, max_outputs=2) with tf.name_scope("3"): tf.compat.v1.summary.image("images", ipt, max_outputs=3) merged = tf.compat.v1.summary.merge_all() writer.add_graph(sess.graph) for i in xrange(10): summ = sess.run(merged) writer.add_summary(summ, global_step=i) accumulator = ea.EventAccumulator(event_sink) accumulator.Reload() tags = [ u"1/images/image", u"2/images/image/0", u"2/images/image/1", u"3/images/image/0", u"3/images/image/1", u"3/images/image/2", ] self.assertTagsEqual( accumulator.Tags(), {ea.IMAGES: tags, ea.GRAPH: True, ea.META_GRAPH: False,}, )
Example #17
Source File: ImageColoring.py From TensorflowProjects with MIT License | 5 votes |
def main(argv=None): utils.maybe_download_and_extract(FLAGS.data_dir, DATA_URL, is_tarfile=True) print "Setting up model..." global_step = tf.Variable(0,trainable=False) gray, color = inputs() pred = 255 * inference(gray) + 128 tf.image_summary("Gray", gray, max_images=1) tf.image_summary("Ground_truth", color, max_images=1) tf.image_summary("Prediction", pred, max_images=1) image_loss = loss(pred, color) train_op = train(image_loss, global_step) summary_op = tf.merge_all_summaries() with tf.Session() as sess: print "Setting up summary writer, queue, saver..." sess.run(tf.initialize_all_variables()) summary_writer = tf.train.SummaryWriter(FLAGS.logs_dir, sess.graph) saver = tf.train.Saver() ckpt = tf.train.get_checkpoint_state(FLAGS.logs_dir) if ckpt and ckpt.model_checkpoint_path: print "Restoring model from checkpoint..." saver.restore(sess, ckpt.model_checkpoint_path) tf.train.start_queue_runners(sess) for step in xrange(MAX_ITERATIONS): if step % 400 == 0: loss_val, summary_str = sess.run([image_loss, summary_op]) print "Step %d, Loss: %g" % (step, loss_val) summary_writer.add_summary(summary_str, global_step=step) if step % 1000 == 0: saver.save(sess, FLAGS.logs_dir + "model.ckpt", global_step=step) print "%s" % datetime.now() sess.run(train_op)
Example #18
Source File: cifarnet_preprocessing.py From Action_Recognition_Zoo with MIT License | 5 votes |
def preprocess_for_train(image, output_height, output_width, padding=_PADDING): """Preprocesses the given image for training. Note that the actual resizing scale is sampled from [`resize_size_min`, `resize_size_max`]. Args: image: A `Tensor` representing an image of arbitrary size. output_height: The height of the image after preprocessing. output_width: The width of the image after preprocessing. padding: The amound of padding before and after each dimension of the image. Returns: A preprocessed image. """ tf.image_summary('image', tf.expand_dims(image, 0)) # Transform the image to floats. image = tf.to_float(image) if padding > 0: image = tf.pad(image, [[padding, padding], [padding, padding], [0, 0]]) # Randomly crop a [height, width] section of the image. distorted_image = tf.random_crop(image, [output_height, output_width, 3]) # Randomly flip the image horizontally. distorted_image = tf.image.random_flip_left_right(distorted_image) tf.image_summary('distorted_image', tf.expand_dims(distorted_image, 0)) # Because these operations are not commutative, consider randomizing # the order their operation. distorted_image = tf.image.random_brightness(distorted_image, max_delta=63) distorted_image = tf.image.random_contrast(distorted_image, lower=0.2, upper=1.8) # Subtract off the mean and divide by the variance of the pixels. return tf.image.per_image_whitening(distorted_image)
Example #19
Source File: cifar10.py From pixel-rnn-tensorflow with MIT License | 5 votes |
def _generate_image_and_label_batch(image, label, min_queue_examples, batch_size): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, height, width, 3] size. labels: Labels. 1D tensor of [batch_size] size. """ # Create a queue that shuffles the examples, and then # read 'batch_size' images + labels from the example queue. num_preprocess_threads = 16 images, label_batch = tf.train.shuffle_batch( [image, label], batch_size=batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * batch_size, min_after_dequeue=min_queue_examples) # Display the training images in the visualizer. # FIXED pre-1.0 # tf.image_summary('images', images) tf.summary.image('images', images) return images, tf.reshape(label_batch, [batch_size])
Example #20
Source File: summary_utils.py From fc4 with MIT License | 5 votes |
def conv_summary(weights, name): grid = _get_grid(weights) return tf.summary.image(name, grid) #tf.image_summary(name + 'random', tf.random_uniform(shape=grid.get_shape()), max_images=3) # Output: RGB images
Example #21
Source File: trainer.py From StackGAN with MIT License | 5 votes |
def visualization(self, n): fake_sum_train, superimage_train = \ self.visualize_one_superimage(self.fake_images[:n * n], self.images[:n * n], n, "train") fake_sum_test, superimage_test = \ self.visualize_one_superimage(self.fake_images[n * n:2 * n * n], self.images[n * n:2 * n * n], n, "test") self.superimages = tf.concat(0, [superimage_train, superimage_test]) self.image_summary = tf.merge_summary([fake_sum_train, fake_sum_test])
Example #22
Source File: q_network.py From agent-trainer with MIT License | 5 votes |
def _convolutional_layer(self, input, patch_size, stride, input_channels, output_channels, bias_init_value, scope_name): with tf.variable_scope(scope_name) as scope: weights = tf.get_variable(name='weights', shape=[patch_size, patch_size, input_channels, output_channels], initializer=tf.contrib.layers.xavier_initializer_conv2d()) biases = tf.Variable(name='biases', initial_value=tf.constant(value=bias_init_value, shape=[output_channels])) conv = tf.nn.conv2d(input, weights, [1, stride, stride, 1], padding='SAME') linear_rectification_bias = tf.nn.bias_add(conv, biases) output = tf.nn.relu(linear_rectification_bias, name=scope.name) grid_x = output_channels // 4 grid_y = 4 * input_channels kernels_image_grid = self._create_kernels_image_grid(weights, (grid_x, grid_y)) tf.image_summary(scope_name + '/features', kernels_image_grid, max_images=1) if "_conv1" in scope_name: x_min = tf.reduce_min(weights) x_max = tf.reduce_max(weights) weights_0_to_1 = (weights - x_min) / (x_max - x_min) weights_0_to_255_uint8 = tf.image.convert_image_dtype(weights_0_to_1, dtype=tf.uint8) # to tf.image_summary format [batch_size, height, width, channels] weights_transposed = tf.transpose(weights_0_to_255_uint8, [3, 0, 1, 2]) tf.image_summary(scope_name + '/features', weights_transposed[:,:,:,0:1], max_images=32) return output
Example #23
Source File: trainer.py From StackGAN with MIT License | 5 votes |
def visualize_one_superimage(self, img_var, images, rows, filename): stacked_img = [] for row in range(rows): img = images[row * rows, :, :, :] row_img = [img] # real image for col in range(rows): row_img.append(img_var[row * rows + col, :, :, :]) # each rows is 1realimage +10_fakeimage stacked_img.append(tf.concat(1, row_img)) imgs = tf.expand_dims(tf.concat(0, stacked_img), 0) current_img_summary = tf.image_summary(filename, imgs) return current_img_summary, imgs
Example #24
Source File: trainer.py From StackGAN with MIT License | 5 votes |
def epoch_sum_images(self, sess, n): images_train, _, embeddings_train, captions_train, _ =\ self.dataset.train.next_batch(n * n, cfg.TRAIN.NUM_EMBEDDING) images_train = self.preprocess(images_train, n) embeddings_train = self.preprocess(embeddings_train, n) images_test, _, embeddings_test, captions_test, _ = \ self.dataset.test.next_batch(n * n, 1) images_test = self.preprocess(images_test, n) embeddings_test = self.preprocess(embeddings_test, n) images = np.concatenate([images_train, images_test], axis=0) embeddings =\ np.concatenate([embeddings_train, embeddings_test], axis=0) if self.batch_size > 2 * n * n: images_pad, _, embeddings_pad, _, _ =\ self.dataset.test.next_batch(self.batch_size - 2 * n * n, 1) images = np.concatenate([images, images_pad], axis=0) embeddings = np.concatenate([embeddings, embeddings_pad], axis=0) feed_dict = {self.images: images, self.embeddings: embeddings} gen_samples, img_summary =\ sess.run([self.superimages, self.image_summary], feed_dict) # save images generated for train and test captions scipy.misc.imsave('%s/train.jpg' % (self.log_dir), gen_samples[0]) scipy.misc.imsave('%s/test.jpg' % (self.log_dir), gen_samples[1]) # pfi_train = open(self.log_dir + "/train.txt", "w") pfi_test = open(self.log_dir + "/test.txt", "w") for row in range(n): # pfi_train.write('\n***row %d***\n' % row) # pfi_train.write(captions_train[row * n]) pfi_test.write('\n***row %d***\n' % row) pfi_test.write(captions_test[row * n]) # pfi_train.close() pfi_test.close() return img_summary
Example #25
Source File: trainer.py From StackGAN with MIT License | 5 votes |
def visualize_one_superimage(self, img_var, images, rows, filename): stacked_img = [] for row in range(rows): img = images[row * rows, :, :, :] row_img = [img] # real image for col in range(rows): row_img.append(img_var[row * rows + col, :, :, :]) # each rows is 1realimage +10_fakeimage stacked_img.append(tf.concat(1, row_img)) imgs = tf.expand_dims(tf.concat(0, stacked_img), 0) current_img_summary = tf.image_summary(filename, imgs) return current_img_summary, imgs
Example #26
Source File: cifar10_input.py From ml with Apache License 2.0 | 5 votes |
def _generate_image_and_label_batch(image, label, min_queue_examples, batch_size): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, height, width, 3] size. labels: Labels. 1D tensor of [batch_size] size. """ # Create a queue that shuffles the examples, and then # read 'batch_size' images + labels from the example queue. num_preprocess_threads = 16 images, label_batch = tf.train.shuffle_batch( [image, label], batch_size=batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * batch_size, min_after_dequeue=min_queue_examples) # Display the training images in the visualizer. # tf.image_summary('images', images) tf.summary.image('images', images) return images, tf.reshape(label_batch, [batch_size])
Example #27
Source File: cifar10_input.py From ml with Apache License 2.0 | 5 votes |
def _generate_image_and_label_batch(image, label, min_queue_examples, batch_size): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, height, width, 3] size. labels: Labels. 1D tensor of [batch_size] size. """ # Create a queue that shuffles the examples, and then # read 'batch_size' images + labels from the example queue. num_preprocess_threads = 16 images, label_batch = tf.train.shuffle_batch( [image, label], batch_size=batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * batch_size, min_after_dequeue=min_queue_examples) # Display the training images in the visualizer. # tf.image_summary('images', images) tf.summary.image('images', images) return images, tf.reshape(label_batch, [batch_size])
Example #28
Source File: image_input.py From iLID with MIT License | 5 votes |
def _generate_image_and_label_batch(image, label, key, min_queue_examples, batch_size): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 1] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, height, width, 1] size. labels: Labels. 1D tensor of [batch_size] size. """ # Create a queue that shuffles the examples, and then # read 'batch_size' images + labels from the example queue. num_preprocess_threads = 16 images, label_batch, key_batch = tf.train.shuffle_batch( [image, label, key], batch_size=batch_size, num_threads=num_preprocess_threads, capacity=min_queue_examples + 3 * batch_size, min_after_dequeue=min_queue_examples) # Display the training images in the visualizer. tf.image_summary('images', images) return images, tf.reshape(label_batch, [batch_size]), tf.reshape(key_batch, [batch_size])
Example #29
Source File: network.py From iLID with MIT License | 5 votes |
def set_activation_summary(self): '''Log each layers activations and sparsity.''' tf.image_summary("input images", self.input_layer.output, max_images=100) for var in tf.trainable_variables(): tf.histogram_summary(var.op.name, var) for layer in self.hidden_layers: tf.histogram_summary(layer.name + '/activations', layer.output) tf.scalar_summary(layer.name + '/sparsity', tf.nn.zero_fraction(layer.output))
Example #30
Source File: scalar_strict_test.py From deep_image_model with Apache License 2.0 | 5 votes |
def testImageSummary(self): image = np.zeros((2, 2, 2, 3), dtype=np.uint8) self.check(tf.image_summary, (['img'], image), 'Tags must be a scalar')