MCPcopy Create free account
hub / github.com/IceClear/StableSR / __init__

Method __init__

ldm/modules/diffusionmodules/model.py:874–905  ·  view source on GitHub ↗
(self, in_channels, out_channels, ch, num_res_blocks, resolution,
                 ch_mult=(2,2), dropout=0.0)

Source from the content-addressed store, hash-verified

872
873class UpsampleDecoder(nn.Module):
874 def __init__(self, in_channels, out_channels, ch, num_res_blocks, resolution,
875 ch_mult=(2,2), dropout=0.0):
876 super().__init__()
877 # upsampling
878 self.temb_ch = 0
879 self.num_resolutions = len(ch_mult)
880 self.num_res_blocks = num_res_blocks
881 block_in = in_channels
882 curr_res = resolution // 2 ** (self.num_resolutions - 1)
883 self.res_blocks = nn.ModuleList()
884 self.upsample_blocks = nn.ModuleList()
885 for i_level in range(self.num_resolutions):
886 res_block = []
887 block_out = ch * ch_mult[i_level]
888 for i_block in range(self.num_res_blocks + 1):
889 res_block.append(ResnetBlock(in_channels=block_in,
890 out_channels=block_out,
891 temb_channels=self.temb_ch,
892 dropout=dropout))
893 block_in = block_out
894 self.res_blocks.append(nn.ModuleList(res_block))
895 if i_level != self.num_resolutions - 1:
896 self.upsample_blocks.append(Upsample(block_in, True))
897 curr_res = curr_res * 2
898
899 # end
900 self.norm_out = Normalize(block_in)
901 self.conv_out = torch.nn.Conv2d(block_in,
902 out_channels,
903 kernel_size=3,
904 stride=1,
905 padding=1)
906
907 def forward(self, x):
908 # upsampling

Callers

nothing calls this directly

Calls 4

ResnetBlockClass · 0.85
UpsampleClass · 0.70
NormalizeFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected