(self)
| 51 | |
| 52 | class LPIPS(nn.Module): |
| 53 | def __init__(self): |
| 54 | super().__init__() |
| 55 | self.alexnet = AlexNet() |
| 56 | self.lpips_weights = nn.ModuleList() |
| 57 | for channels in self.alexnet.channels: |
| 58 | self.lpips_weights.append(Conv1x1(channels, 1)) |
| 59 | self._load_lpips_weights() |
| 60 | # imagenet normalization for range [-1, 1] |
| 61 | self.mu = torch.tensor([-0.03, -0.088, -0.188]).view(1, 3, 1, 1) # .cuda() |
| 62 | self.sigma = torch.tensor([0.458, 0.448, 0.450]).view(1, 3, 1, 1) # .cuda() |
| 63 | |
| 64 | def _load_lpips_weights(self): |
| 65 | own_state_dict = self.state_dict() |
no test coverage detected