(image_pred, image_gt, valid_mask=None, reduction='mean')
| 2 | from kornia.losses import ssim as dssim |
| 3 | |
| 4 | def mse(image_pred, image_gt, valid_mask=None, reduction='mean'): |
| 5 | value = (image_pred-image_gt)**2 |
| 6 | if valid_mask is not None: |
| 7 | value = value[valid_mask] |
| 8 | if reduction == 'mean': |
| 9 | return torch.mean(value) |
| 10 | return value |
| 11 | |
| 12 | def psnr(image_pred, image_gt, valid_mask=None, reduction='mean'): |
| 13 | return -10*torch.log10(mse(image_pred, image_gt, valid_mask, reduction)) |
no outgoing calls
no test coverage detected