MCPcopy Create free account
hub / github.com/bbaaii/DreamDiffusion / EncoderUNetModel

Class EncoderUNetModel

code/dc_ldm/modules/diffusionmodules/openaimodel.py:764–979  ·  view source on GitHub ↗

The half UNet model with attention and timestep embedding. For usage, see UNet.

Source from the content-addressed store, hash-verified

762
763
764class EncoderUNetModel(nn.Module):
765 """
766 The half UNet model with attention and timestep embedding.
767 For usage, see UNet.
768 """
769
770 def __init__(
771 self,
772 image_size,
773 in_channels,
774 model_channels,
775 out_channels,
776 num_res_blocks,
777 attention_resolutions,
778 dropout=0,
779 channel_mult=(1, 2, 4, 8),
780 conv_resample=True,
781 dims=2,
782 use_checkpoint=False,
783 use_fp16=False,
784 num_heads=1,
785 num_head_channels=-1,
786 num_heads_upsample=-1,
787 use_scale_shift_norm=False,
788 resblock_updown=False,
789 use_new_attention_order=False,
790 pool="adaptive",
791 *args,
792 **kwargs
793 ):
794 super().__init__()
795
796 if num_heads_upsample == -1:
797 num_heads_upsample = num_heads
798
799 self.in_channels = in_channels
800 self.model_channels = model_channels
801 self.out_channels = out_channels
802 self.num_res_blocks = num_res_blocks
803 self.attention_resolutions = attention_resolutions
804 self.dropout = dropout
805 self.channel_mult = channel_mult
806 self.conv_resample = conv_resample
807 self.use_checkpoint = use_checkpoint
808 self.dtype = th.float16 if use_fp16 else th.float32
809 self.num_heads = num_heads
810 self.num_head_channels = num_head_channels
811 self.num_heads_upsample = num_heads_upsample
812
813 time_embed_dim = model_channels * 4
814 self.time_embed = nn.Sequential(
815 linear(model_channels, time_embed_dim),
816 nn.SiLU(),
817 linear(time_embed_dim, time_embed_dim),
818 )
819
820 self.input_blocks = nn.ModuleList(
821 [

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected