Working with SSIM loss function in tensorflow for RGB images

前端 未结 3 1837
孤独总比滥情好
孤独总比滥情好 2020-12-29 15:27

I want to use SSIM metric as my loss function for the model I\'m working on in tensorflow. SSIM should measure the similarity between my re

相关标签:
3条回答
  • 2020-12-29 15:42

    I was capable of solving the issue by changing the dynamic range of the images to 2.0, since I have images scaled between [-1, 1] by:

    loss_rec = tf.reduce_mean(tf.image.ssim(truth, reconstructed, 2.0))

    And since a better image quality is shown by a higher SSIM value, I had to minimize the negative of my loss function (SSIM) to optimize my model:

    optimizer = tf.train.AdamOptimizer(learning_rate).minimize(-1 * loss_rec)

    0 讨论(0)
  • 2020-12-29 15:57

    SSIM is designed to only measure the difference between two luminance signals. The RGB images are converted to greyscale before measuring similarity. If that was fed back into the loss function, it wouldn't know if the image was losing color saturation because it wouldn't show up in the error metric. That's just a theory.

    0 讨论(0)
  • 2020-12-29 16:03

    The TensorFlow documentation says that no colorspace conversion is applied.

    https://www.tensorflow.org/api_docs/python/tf/image/ssim

    "Note: The true SSIM is only defined on grayscale. This function does not perform any colorspace transform. (If input is already YUV, then it will compute YUV SSIM average.)"

    0 讨论(0)
提交回复
热议问题