(self, use_dropout=True)
| 12 | class LPIPS(nn.Module): |
| 13 | # Learned perceptual metric |
| 14 | def __init__(self, use_dropout=True): |
| 15 | super().__init__() |
| 16 | self.scaling_layer = ScalingLayer() |
| 17 | self.chns = [64, 128, 256, 512, 512] # vg16 features |
| 18 | self.net = vgg16(pretrained=True, requires_grad=False) |
| 19 | self.lin0 = NetLinLayer(self.chns[0], use_dropout=use_dropout) |
| 20 | self.lin1 = NetLinLayer(self.chns[1], use_dropout=use_dropout) |
| 21 | self.lin2 = NetLinLayer(self.chns[2], use_dropout=use_dropout) |
| 22 | self.lin3 = NetLinLayer(self.chns[3], use_dropout=use_dropout) |
| 23 | self.lin4 = NetLinLayer(self.chns[4], use_dropout=use_dropout) |
| 24 | self.load_from_pretrained() |
| 25 | for param in self.parameters(): |
| 26 | param.requires_grad = False |
| 27 | |
| 28 | def load_from_pretrained(self, name="vgg_lpips"): |
| 29 | ckpt = get_ckpt_path(name, "sgm/modules/autoencoding/lpips/loss") |
no test coverage detected