From fd97573085ebf311983722f8a8dbdf6b5e03d61a Mon Sep 17 00:00:00 2001 From: James Betker Date: Wed, 11 Nov 2020 21:49:06 -0700 Subject: [PATCH] Fixes --- codes/models/archs/RRDBNet_arch.py | 3 ++- codes/models/archs/discriminator_vgg_arch.py | 6 +++--- codes/models/archs/rrdb_with_adain_latent.py | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/codes/models/archs/RRDBNet_arch.py b/codes/models/archs/RRDBNet_arch.py index 965f0c2c..5118f345 100644 --- a/codes/models/archs/RRDBNet_arch.py +++ b/codes/models/archs/RRDBNet_arch.py @@ -206,5 +206,6 @@ class RRDBNet(nn.Module): def visual_dbg(self, step, path): for i, bm in enumerate(self.body): - torchvision.utils.save_image(bm.bypass_map.cpu().float(), os.path.join(path, "%i_bypass_%i.png" % (step, i+1))) + if hasattr(bm, 'bypass_map'): + torchvision.utils.save_image(bm.bypass_map.cpu().float(), os.path.join(path, "%i_bypass_%i.png" % (step, i+1))) diff --git a/codes/models/archs/discriminator_vgg_arch.py b/codes/models/archs/discriminator_vgg_arch.py index 731f2ffc..9c1d12d7 100644 --- a/codes/models/archs/discriminator_vgg_arch.py +++ b/codes/models/archs/discriminator_vgg_arch.py @@ -675,9 +675,9 @@ class PyramidDiscriminator(nn.Module): ResidualBlockGN(nf), ResidualBlockGN(nf), ResidualBlockGN(nf), - ConvGnLelu(nf, nf // 2, kernel_size=1, activation=True, norm=True, bias=True), - ConvGnLelu(nf // 2, nf // 4, kernel_size=1, activation=True, norm=True, bias=True), - ConvGnLelu(nf // 4, 1, activation=False, norm=False, bias=True)]) + ConvGnLelu(nf, nf // 2, kernel_size=1, activation=True, norm=False, bias=True), + ConvGnLelu(nf // 2, nf // 4, kernel_size=1, activation=True, norm=False, bias=True), + ConvGnLelu(nf // 4, 1, kernel_size=1, activation=False, norm=False, bias=True)]) def forward(self, x): fea = self.initial_conv(x) diff --git a/codes/models/archs/rrdb_with_adain_latent.py b/codes/models/archs/rrdb_with_adain_latent.py index e0a3373c..afaae256 100644 --- a/codes/models/archs/rrdb_with_adain_latent.py +++ b/codes/models/archs/rrdb_with_adain_latent.py @@ -146,6 +146,11 @@ class AdaRRDBNet(nn.Module): self.conv_up2, self.conv_hr, self.conv_last ]: default_init_weights(m, 0.1) + self.latent_mean = 0 + self.latent_std = 0 + self.latent_var = 0 + self.block_residual_means = [] + self.block_residual_stds = [] def forward(self, x, latent=None, ref=None): latent_was_none = latent