(self, in0, in1, retPerLayer=None)
| 150 | class 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 | |
| 167 | class DSSIM(FakeNet): |
| 168 |
no outgoing calls
no test coverage detected