image_utils.py 554 B

12345678910111213141516171819
  1. #
  2. # Copyright (C) 2023, Inria
  3. # GRAPHDECO research group, https://team.inria.fr/graphdeco
  4. # All rights reserved.
  5. #
  6. # This software is free for non-commercial, research and evaluation use
  7. # under the terms of the LICENSE.md file.
  8. #
  9. # For inquiries contact george.drettakis@inria.fr
  10. #
  11. import torch
  12. def mse(img1, img2):
  13. return (((img1 - img2)) ** 2).view(img1.shape[0], -1).mean(1, keepdim=True)
  14. def psnr(img1, img2):
  15. mse = (((img1 - img2)) ** 2).view(img1.shape[0], -1).mean(1, keepdim=True)
  16. return 20 * torch.log10(1.0 / torch.sqrt(mse))