MCPcopy Create free account
hub / github.com/CompVis/diff2flow / calculate_PSNR

Function calculate_PSNR

diff2flow/metrics.py:12–17  ·  view source on GitHub ↗
(img1, img2)

Source from the content-addressed store, hash-verified

10
11
12def calculate_PSNR(img1, img2):
13 img1 = torch.clamp(img1, 0, 1)
14 img2 = torch.clamp(img2, 0, 1)
15 mse = torch.mean((img1 - img2) ** 2, dim=[1,2,3])
16 psnrs = 20 * torch.log10(1 / torch.sqrt(mse))
17 return psnrs.mean()
18
19
20class ImageMetricTracker(nn.Module):

Callers 1

__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected