mirror of
https://github.com/PrimitiveAnything/PrimitiveAnything.git
synced 2025-09-18 05:22:48 +08:00
13 lines
214 B
Python
Executable File
13 lines
214 B
Python
Executable File
# -*- coding: utf-8 -*-
|
|
|
|
import torch
|
|
|
|
|
|
def compute_psnr(x, y, data_range: float = 2, eps: float = 1e-7):
|
|
|
|
mse = torch.mean((x - y) ** 2)
|
|
psnr = 10 * torch.log10(data_range / (mse + eps))
|
|
|
|
return psnr
|
|
|