MCPcopy Create free account
hub / github.com/apple/ml-pointersect / ssim

Function ssim

plib/metrics.py:69–90  ·  view source on GitHub ↗

Convenient function to call skimage's ssim. Not differentiable. Args: rgb: (h, w, 3), in the range of [0, 1] gts: (h, w, 3), in the range of [0, 1] Returns: ssim value

(
        rgb: torch.Tensor,
        gts: torch.Tensor,
)

Source from the content-addressed store, hash-verified

67
68
69def ssim(
70 rgb: torch.Tensor,
71 gts: torch.Tensor,
72) -> float:
73 """
74 Convenient function to call skimage's ssim. Not differentiable.
75
76 Args:
77 rgb: (h, w, 3), in the range of [0, 1]
78 gts: (h, w, 3), in the range of [0, 1]
79
80 Returns:
81 ssim value
82 """
83 return skimage.metrics.structural_similarity(
84 rgb[..., :3].cpu().numpy(),
85 gts[..., :3].cpu().numpy(),
86 multichannel=True,
87 data_range=1,
88 gaussian_weights=True,
89 sigma=1.5,
90 )

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected