summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/convnext/discriminator.py8
-rw-r--r--models/sparse.py2
2 files changed, 2 insertions, 8 deletions
diff --git a/models/convnext/discriminator.py b/models/convnext/discriminator.py
index 7dbbe3a..571b915 100644
--- a/models/convnext/discriminator.py
+++ b/models/convnext/discriminator.py
@@ -15,13 +15,7 @@ class ConvNeXtDiscriminator():
15 self.img_std = torch.tensor(IMAGENET_DEFAULT_STD).view(1, -1, 1, 1) 15 self.img_std = torch.tensor(IMAGENET_DEFAULT_STD).view(1, -1, 1, 1)
16 16
17 def get_score(self, img): 17 def get_score(self, img):
18 img_mean = self.img_mean.to(device=img.device, dtype=img.dtype) 18 pred = self.get_all(img)
19 img_std = self.img_std.to(device=img.device, dtype=img.dtype)
20
21 img = ((img+1.)/2.).sub(img_mean).div(img_std)
22
23 img = F.interpolate(img, size=(self.input_size, self.input_size), mode='bicubic', align_corners=True)
24 pred = self.net(img)
25 return torch.softmax(pred, dim=-1)[:, 1] 19 return torch.softmax(pred, dim=-1)[:, 1]
26 20
27 def get_all(self, img): 21 def get_all(self, img):
diff --git a/models/sparse.py b/models/sparse.py
index bcb2897..07b3413 100644
--- a/models/sparse.py
+++ b/models/sparse.py
@@ -15,7 +15,7 @@ class PseudoSparseEmbedding(nn.Module):
15 if dropout_p > 0.0: 15 if dropout_p > 0.0:
16 self.dropout = nn.Dropout(p=dropout_p) 16 self.dropout = nn.Dropout(p=dropout_p)
17 else: 17 else:
18 self.dropout = lambda x: x 18 self.dropout = nn.Identity()
19 19
20 self.register_buffer('mapping', torch.zeros(0, device=device, dtype=torch.long)) 20 self.register_buffer('mapping', torch.zeros(0, device=device, dtype=torch.long))
21 21