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,
)
| 67 | |
| 68 | |
| 69 | def 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 | ) |
nothing calls this directly
no outgoing calls
no test coverage detected