Search code examples
pythontensorflowtensorboard

How can I display multiple images in one tensorboard tab like it's done in tf-object-detection-api


I would like to create tensorboard image summaries using using tf.Summary.Image not using tf.summary.image and tensors. So it should be done without tf.Session. Currently I use this

    with BytesIO() as byte_io:
        img_crop_pil = Image.fromarray(image)
        img_crop_pil.save(byte_io, format="PNG")
        png_buffer = byte_io.getvalue()
    img_summary = tf.Summary.Image(encoded_image_string=png_buffer)
    return tf.Summary.Value(tag='img', image=img_summary)

And in tensorboard only one picture displayed. Slider is available but it is not convient especially with multiple steps. I would like images to be displayed side by side.


Solution

  • Turns out the problem was in the tf.Summary.Value tag parameter. If you want several images in one tab you need this images to have tags in the following form. The most important part is the / in the tag name. It is parsed by tensorboard to split images inside tab

    1st tab, 1st image - tf.Summary.Value(tag='tab_1/1', image=img_summary)  
    1st tab, 2nd image - tf.Summary.Value(tag='tab_1/2', image=img_summary) 
    1st tab, 3rd image - tf.Summary.Value(tag='tab_1/3', image=img_summary)
    
    2nd tab, 1st image - tf.Summary.Value(tag='tab_2/1', image=img_summary)
    2nd tab, 2nd image - tf.Summary.Value(tag='tab_2/2', image=img_summary)
    2nd tab, 3rd image - tf.Summary.Value(tag='tab_2/3', image=img_summary)
    and so on