r"""Function that measures Learned Perceptual Image Patch Similarity (LPIPS). Arguments: x, y (torch.Tensor): the input tensors to compare. net_type (str): the network type to compare the features: 'alex' | 'squeeze' | 'vgg'. Default: 'alex'.
(x: torch.Tensor,
y: torch.Tensor,
net_type: str = 'alex',
version: str = '0.1')
| 4 | |
| 5 | |
| 6 | def lpips(x: torch.Tensor, |
| 7 | y: torch.Tensor, |
| 8 | net_type: str = 'alex', |
| 9 | version: str = '0.1'): |
| 10 | r"""Function that measures |
| 11 | Learned Perceptual Image Patch Similarity (LPIPS). |
| 12 | |
| 13 | Arguments: |
| 14 | x, y (torch.Tensor): the input tensors to compare. |
| 15 | net_type (str): the network type to compare the features: |
| 16 | 'alex' | 'squeeze' | 'vgg'. Default: 'alex'. |
| 17 | version (str): the version of LPIPS. Default: 0.1. |
| 18 | """ |
| 19 | device = x.device |
| 20 | criterion = LPIPS(net_type, version).to(device) |
| 21 | return criterion(x, y) |