MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / __init__

Method __init__

ldm/modules/diffusionmodules/model.py:701–732  ·  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

699
700class UpsampleDecoder(nn.Module):
701 def __init__(self, in_channels, out_channels, ch, num_res_blocks, resolution,
702 ch_mult=(2,2), dropout=0.0):
703 super().__init__()
704 # upsampling
705 self.temb_ch = 0
706 self.num_resolutions = len(ch_mult)
707 self.num_res_blocks = num_res_blocks
708 block_in = in_channels
709 curr_res = resolution // 2 ** (self.num_resolutions - 1)
710 self.res_blocks = nn.ModuleList()
711 self.upsample_blocks = nn.ModuleList()
712 for i_level in range(self.num_resolutions):
713 res_block = []
714 block_out = ch * ch_mult[i_level]
715 for i_block in range(self.num_res_blocks + 1):
716 res_block.append(ResnetBlock(in_channels=block_in,
717 out_channels=block_out,
718 temb_channels=self.temb_ch,
719 dropout=dropout))
720 block_in = block_out
721 self.res_blocks.append(nn.ModuleList(res_block))
722 if i_level != self.num_resolutions - 1:
723 self.upsample_blocks.append(Upsample(block_in, True))
724 curr_res = curr_res * 2
725
726 # end
727 self.norm_out = Normalize(block_in)
728 self.conv_out = torch.nn.Conv2d(block_in,
729 out_channels,
730 kernel_size=3,
731 stride=1,
732 padding=1)
733
734 def forward(self, x):
735 # 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