MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / compute_psnr

Function compute_psnr

utils/metrics.py:12–19  ·  view source on GitHub ↗
(
    ground_truth: Float[Tensor, "batch channel height width"],
    predicted: Float[Tensor, "batch channel height width"],
)

Source from the content-addressed store, hash-verified

10
11@torch.no_grad()
12def compute_psnr(
13 ground_truth: Float[Tensor, "batch channel height width"],
14 predicted: Float[Tensor, "batch channel height width"],
15) -> Float[Tensor, " batch"]:
16 ground_truth = ground_truth.clip(min=0, max=1)
17 predicted = predicted.clip(min=0, max=1)
18 mse = reduce((ground_truth - predicted) ** 2, "b c h w -> b", "mean")
19 return -10 * mse.log10()
20
21
22@cache

Callers 2

forwardMethod · 0.90
compute_lossesMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected