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

Method forward

ldm/modules/diffusionmodules/model.py:758–795  ·  view source on GitHub ↗
(self, z, enc_fea)

Source from the content-addressed store, hash-verified

756 padding=1)
757
758 def forward(self, z, enc_fea):
759 #assert z.shape[1:] == self.z_shape[1:]
760 self.last_z_shape = z.shape
761
762 # timestep embedding
763 temb = None
764
765 # z to block_in
766 h = self.conv_in(z)
767
768 # middle
769 h = self.mid.block_1(h, temb)
770 h = self.mid.attn_1(h)
771 h = self.mid.block_2(h, temb)
772
773 # upsampling
774 for i_level in reversed(range(self.num_resolutions)):
775 for i_block in range(self.num_res_blocks+1):
776 h = self.up[i_level].block[i_block](h, temb)
777 if len(self.up[i_level].attn) > 0:
778 h = self.up[i_level].attn[i_block](h)
779
780 if i_level != self.num_resolutions-1 and i_level != 0:
781 cur_fuse_layer = getattr(self, 'fusion_layer_{}'.format(i_level))
782 h = cur_fuse_layer(enc_fea[i_level-1], h, self.fusion_w)
783
784 if i_level != 0:
785 h = self.up[i_level].upsample(h)
786 # end
787 if self.give_pre_end:
788 return h
789
790 h = self.norm_out(h)
791 h = nonlinearity(h)
792 h = self.conv_out(h)
793 if self.tanh_out:
794 h = torch.tanh(h)
795 return h
796
797class ResBlock(nn.Module):
798 def __init__(self, in_channels, out_channels=None):

Callers

nothing calls this directly

Calls 2

nonlinearityFunction · 0.85
upsampleMethod · 0.80

Tested by

no test coverage detected