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

Class UpDecoderBlock2D

diffusers/src/diffusers/models/unets/unet_2d_blocks.py:2682–2752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2680
2681
2682class UpDecoderBlock2D(nn.Module):
2683 def __init__(
2684 self,
2685 in_channels: int,
2686 out_channels: int,
2687 resolution_idx: Optional[int] = None,
2688 dropout: float = 0.0,
2689 num_layers: int = 1,
2690 resnet_eps: float = 1e-6,
2691 resnet_time_scale_shift: str = "default", # default, spatial
2692 resnet_act_fn: str = "swish",
2693 resnet_groups: int = 32,
2694 resnet_pre_norm: bool = True,
2695 output_scale_factor: float = 1.0,
2696 add_upsample: bool = True,
2697 temb_channels: Optional[int] = None,
2698 ):
2699 super().__init__()
2700 resnets = []
2701
2702 for i in range(num_layers):
2703 input_channels = in_channels if i == 0 else out_channels
2704
2705 if resnet_time_scale_shift == "spatial":
2706 resnets.append(
2707 ResnetBlockCondNorm2D(
2708 in_channels=input_channels,
2709 out_channels=out_channels,
2710 temb_channels=temb_channels,
2711 eps=resnet_eps,
2712 groups=resnet_groups,
2713 dropout=dropout,
2714 time_embedding_norm="spatial",
2715 non_linearity=resnet_act_fn,
2716 output_scale_factor=output_scale_factor,
2717 )
2718 )
2719 else:
2720 resnets.append(
2721 ResnetBlock2D(
2722 in_channels=input_channels,
2723 out_channels=out_channels,
2724 temb_channels=temb_channels,
2725 eps=resnet_eps,
2726 groups=resnet_groups,
2727 dropout=dropout,
2728 time_embedding_norm=resnet_time_scale_shift,
2729 non_linearity=resnet_act_fn,
2730 output_scale_factor=output_scale_factor,
2731 pre_norm=resnet_pre_norm,
2732 )
2733 )
2734
2735 self.resnets = nn.ModuleList(resnets)
2736
2737 if add_upsample:
2738 self.upsamplers = nn.ModuleList([Upsample2D(out_channels, use_conv=True, out_channels=out_channels)])
2739 else:

Callers 1

get_up_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected