MCPcopy
hub / github.com/richzhang/PerceptualSimilarity / forward

Method forward

models/networks_basic.py:152–165  ·  view source on GitHub ↗
(self, in0, in1, retPerLayer=None)

Source from the content-addressed store, hash-verified

150class L2(FakeNet):
151
152 def forward(self, in0, in1, retPerLayer=None):
153 assert(in0.size()[0]==1) # currently only supports batchSize 1
154
155 if(self.colorspace=='RGB'):
156 (N,C,X,Y) = in0.size()
157 value = torch.mean(torch.mean(torch.mean((in0-in1)**2,dim=1).view(N,1,X,Y),dim=2).view(N,1,1,Y),dim=3).view(N)
158 return value
159 elif(self.colorspace=='Lab'):
160 value = util.l2(util.tensor2np(util.tensor2tensorlab(in0.data,to_norm=False)),
161 util.tensor2np(util.tensor2tensorlab(in1.data,to_norm=False)), range=100.).astype('float')
162 ret_var = Variable( torch.Tensor((value,) ) )
163 if(self.use_gpu):
164 ret_var = ret_var.cuda()
165 return ret_var
166
167class DSSIM(FakeNet):
168

Callers 8

compute_dists.pyFile · 0.45
test_network.pyFile · 0.45
perceptual_loss.pyFile · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected