From 186a69104530610f8c2b924f79a04f941e5238c8 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 22 Jun 2023 07:33:29 +0200 Subject: Remove convnext --- models/convnext/discriminator.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 models/convnext/discriminator.py (limited to 'models/convnext') diff --git a/models/convnext/discriminator.py b/models/convnext/discriminator.py deleted file mode 100644 index 5798bcf..0000000 --- a/models/convnext/discriminator.py +++ /dev/null @@ -1,34 +0,0 @@ -import torch -from timm.models import ConvNeXt -from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD - -from torch.nn import functional as F - - -class ConvNeXtDiscriminator: - def __init__(self, model: ConvNeXt, input_size: int) -> None: - self.net = model - - self.input_size = input_size - - self.img_mean = torch.tensor(IMAGENET_DEFAULT_MEAN).view(1, -1, 1, 1) - self.img_std = torch.tensor(IMAGENET_DEFAULT_STD).view(1, -1, 1, 1) - - def get_score(self, img): - pred = self.get_all(img) - return torch.softmax(pred, dim=-1)[:, 1] - - def get_all(self, img): - img_mean = self.img_mean.to(device=img.device, dtype=img.dtype) - img_std = self.img_std.to(device=img.device, dtype=img.dtype) - - img = ((img + 1.0) / 2.0).sub(img_mean).div(img_std) - - img = F.interpolate( - img, - size=(self.input_size, self.input_size), - mode="bicubic", - align_corners=True, - ) - pred = self.net(img) - return pred -- cgit v1.2.3-70-g09d2