MCPcopy Create free account
hub / github.com/OpenGVLab/DragGAN / __init__

Method __init__

draggan/deprecated/stylegan2/lpips/networks_basic.py:29–63  ·  view source on GitHub ↗
(self, pnet_type='vgg', pnet_rand=False, pnet_tune=False, use_dropout=True, spatial=False, version='0.1', lpips=True)

Source from the content-addressed store, hash-verified

27# Learned perceptual metric
28class PNetLin(nn.Module):
29 def __init__(self, pnet_type='vgg', pnet_rand=False, pnet_tune=False, use_dropout=True, spatial=False, version='0.1', lpips=True):
30 super(PNetLin, self).__init__()
31
32 self.pnet_type = pnet_type
33 self.pnet_tune = pnet_tune
34 self.pnet_rand = pnet_rand
35 self.spatial = spatial
36 self.lpips = lpips
37 self.version = version
38 self.scaling_layer = ScalingLayer()
39
40 if(self.pnet_type in ['vgg','vgg16']):
41 net_type = pn.vgg16
42 self.chns = [64,128,256,512,512]
43 elif(self.pnet_type=='alex'):
44 net_type = pn.alexnet
45 self.chns = [64,192,384,256,256]
46 elif(self.pnet_type=='squeeze'):
47 net_type = pn.squeezenet
48 self.chns = [64,128,256,384,384,512,512]
49 self.L = len(self.chns)
50
51 self.net = net_type(pretrained=not self.pnet_rand, requires_grad=self.pnet_tune)
52
53 if(lpips):
54 self.lin0 = NetLinLayer(self.chns[0], use_dropout=use_dropout)
55 self.lin1 = NetLinLayer(self.chns[1], use_dropout=use_dropout)
56 self.lin2 = NetLinLayer(self.chns[2], use_dropout=use_dropout)
57 self.lin3 = NetLinLayer(self.chns[3], use_dropout=use_dropout)
58 self.lin4 = NetLinLayer(self.chns[4], use_dropout=use_dropout)
59 self.lins = [self.lin0,self.lin1,self.lin2,self.lin3,self.lin4]
60 if(self.pnet_type=='squeeze'): # 7 layers for squeezenet
61 self.lin5 = NetLinLayer(self.chns[5], use_dropout=use_dropout)
62 self.lin6 = NetLinLayer(self.chns[6], use_dropout=use_dropout)
63 self.lins+=[self.lin5,self.lin6]
64
65 def forward(self, in0, in1, retPerLayer=False):
66 # v0.0 - original release had a bug, where input was not scaled

Callers 5

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

ScalingLayerClass · 0.85
NetLinLayerClass · 0.85

Tested by

no test coverage detected