diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-05-27 17:13:26 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-05-27 17:13:26 +0000 |
commit | 50906bf78bce9cdb872a56d498000316ec2dfdcd (patch) | |
tree | 5811cd211f383f759120c80ed266ed0b1befbaf0 /extensions-builtin/ScuNET/scunet_model_arch.py | |
parent | 89f9faa63388756314e8a1d96cf86bf5e0663045 (diff) | |
parent | b186045fee0d384addcdc2a759fd33dba51b070e (diff) | |
download | stable-diffusion-webui-gfx803-50906bf78bce9cdb872a56d498000316ec2dfdcd.tar.gz stable-diffusion-webui-gfx803-50906bf78bce9cdb872a56d498000316ec2dfdcd.tar.bz2 stable-diffusion-webui-gfx803-50906bf78bce9cdb872a56d498000316ec2dfdcd.zip |
Merge branch 'release_candidate'
Diffstat (limited to 'extensions-builtin/ScuNET/scunet_model_arch.py')
-rw-r--r-- | extensions-builtin/ScuNET/scunet_model_arch.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/extensions-builtin/ScuNET/scunet_model_arch.py b/extensions-builtin/ScuNET/scunet_model_arch.py index 43ca8d36..b51a8806 100644 --- a/extensions-builtin/ScuNET/scunet_model_arch.py +++ b/extensions-builtin/ScuNET/scunet_model_arch.py @@ -61,7 +61,9 @@ class WMSA(nn.Module): Returns: output: tensor shape [b h w c] """ - if self.type != 'W': x = torch.roll(x, shifts=(-(self.window_size // 2), -(self.window_size // 2)), dims=(1, 2)) + if self.type != 'W': + x = torch.roll(x, shifts=(-(self.window_size // 2), -(self.window_size // 2)), dims=(1, 2)) + x = rearrange(x, 'b (w1 p1) (w2 p2) c -> b w1 w2 p1 p2 c', p1=self.window_size, p2=self.window_size) h_windows = x.size(1) w_windows = x.size(2) @@ -85,8 +87,9 @@ class WMSA(nn.Module): output = self.linear(output) output = rearrange(output, 'b (w1 w2) (p1 p2) c -> b (w1 p1) (w2 p2) c', w1=h_windows, p1=self.window_size) - if self.type != 'W': output = torch.roll(output, shifts=(self.window_size // 2, self.window_size // 2), - dims=(1, 2)) + if self.type != 'W': + output = torch.roll(output, shifts=(self.window_size // 2, self.window_size // 2), dims=(1, 2)) + return output def relative_embedding(self): @@ -262,4 +265,4 @@ class SCUNet(nn.Module): nn.init.constant_(m.bias, 0) elif isinstance(m, nn.LayerNorm): nn.init.constant_(m.bias, 0) - nn.init.constant_(m.weight, 1.0)
\ No newline at end of file + nn.init.constant_(m.weight, 1.0) |