Search code examples
tensorflowtensorboard

How to show all my images in tensorboard?


I only see images which are currently residing in symbolic tensor (logits, label):

with tf.name_scope("Train"):
    optimizer = tf.train.AdamOptimizer(FLAGS.learning_rate).minimize(cost_function)
    tf.summary.image('logits', tn_logits, max_outputs=4)
    tf.summary.image('label', t_label, max_outputs=4)

In the session, I feed the network images in a loop.

for epoch in range(FLAGS.training_epochs):

        for img in images:
            _, summary_str, costs = sess.run([optimizer, merged_summary_op, cost_function],
                                             feed_dict={t_im0: img.l_img.eval(), t_im1: img.r_img.eval(),
                                                        t_label: img.mask.eval()})

How to show all images simultaneously?


I want to have this view for all my images like in a gallery: example


Solution

  • The first dimension of image tensor and max_output argument of tf.summary.image define number of images in tensorboard gallery. Since you write 1 image at a time, the existing images are overwritten.

    Instead of iterating, concatenate 4 images such that tn_logits and t_label will have shape of [4, h, w, 1].

    Then in tensorboard you will have Train/logits/image/0, Train/label/image/1, Train/label/image/2 and Train/label/image/3 entries for tn_logits.