How to display custom images in TensorBoard using Keras?

前端 未结 8 1390
暗喜
暗喜 2020-12-02 12:16

I\'m working on a segmentation problem in Keras and I want to display segmentation results at the end of every training epoch.

I want something similar to Tensorflow

8条回答
  •  再見小時候
    2020-12-02 13:18

    I believe I found a better way to log such custom images to tensorboard making use of the tf-matplotlib. Here is how...

    class TensorBoardDTW(tf.keras.callbacks.TensorBoard):
        def __init__(self, **kwargs):
            super(TensorBoardDTW, self).__init__(**kwargs)
            self.dtw_image_summary = None
    
        def _make_histogram_ops(self, model):
            super(TensorBoardDTW, self)._make_histogram_ops(model)
            tf.summary.image('dtw-cost', create_dtw_image(model.output))
    

    One just need to overwrite the _make_histogram_ops method from the TensorBoard callback class to add the custom summary. In my case, the create_dtw_image is a function that creates an image using the tf-matplotlib.

    Regards,.

提交回复
热议问题