MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / UpBlock3D

Class UpBlock3D

diffusers/src/diffusers/models/unets/unet_3d_blocks.py:796–896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794
795
796class UpBlock3D(nn.Module):
797 def __init__(
798 self,
799 in_channels: int,
800 prev_output_channel: int,
801 out_channels: int,
802 temb_channels: int,
803 dropout: float = 0.0,
804 num_layers: int = 1,
805 resnet_eps: float = 1e-6,
806 resnet_time_scale_shift: str = "default",
807 resnet_act_fn: str = "swish",
808 resnet_groups: int = 32,
809 resnet_pre_norm: bool = True,
810 output_scale_factor: float = 1.0,
811 add_upsample: bool = True,
812 resolution_idx: Optional[int] = None,
813 ):
814 super().__init__()
815 resnets = []
816 temp_convs = []
817
818 for i in range(num_layers):
819 res_skip_channels = in_channels if (i == num_layers - 1) else out_channels
820 resnet_in_channels = prev_output_channel if i == 0 else out_channels
821
822 resnets.append(
823 ResnetBlock2D(
824 in_channels=resnet_in_channels + res_skip_channels,
825 out_channels=out_channels,
826 temb_channels=temb_channels,
827 eps=resnet_eps,
828 groups=resnet_groups,
829 dropout=dropout,
830 time_embedding_norm=resnet_time_scale_shift,
831 non_linearity=resnet_act_fn,
832 output_scale_factor=output_scale_factor,
833 pre_norm=resnet_pre_norm,
834 )
835 )
836 temp_convs.append(
837 TemporalConvLayer(
838 out_channels,
839 out_channels,
840 dropout=0.1,
841 norm_num_groups=resnet_groups,
842 )
843 )
844
845 self.resnets = nn.ModuleList(resnets)
846 self.temp_convs = nn.ModuleList(temp_convs)
847
848 if add_upsample:
849 self.upsamplers = nn.ModuleList([Upsample2D(out_channels, use_conv=True, out_channels=out_channels)])
850 else:
851 self.upsamplers = None
852
853 self.gradient_checkpointing = False

Callers 1

get_up_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected