I want to implement a similar loss function like in this paper: https://arxiv.org/pdf/1511.08861.pdf
They are combining here the l1 (Mean Average Error) and the MS-SSIM Loss like in following equation:
L_Mix = α · L_MSSSIM + (1 − α) · GaussFilter· L_1
There is a caffe code available on GitHub: https://github.com/NVlabs/PL4NN/blob/master/src/loss.py
But I dont know how to use this in TF. Is there already a similar existing code for TF?
I started trying this:
def ms_ssim_loss(y_true, y_pred):
ms_ssim = tf.image.ssim_multiscale(y_true, y_pred, 1.0)
loss = 1-ms_ssim
return loss
def mix_loss(y_true, y_pred):
alpha = 0.84
ms_ssim = ms_ssim_loss(y_true, y_pred)
l1 = tf.keras.losses.MeanAbsoluteError(y_true, y_pred)
gauss = gaussian(...)
loss = ms_ssim * alpha + (1-alpha) * gauss * l1
return loss
But don't know how to implement and use the gaussian filter here.
Thanks in advance and best regards!