MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / __init__

Method __init__

src/diffusers/models/unets/unet_2d_blocks.py:3078–3147  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        prev_output_channel: int,
        out_channels: int,
        temb_channels: int,
        resolution_idx: Optional[int] = None,
        dropout: float = 0.0,
        num_layers: int = 1,
        resnet_eps: float = 1e-6,
        resnet_time_scale_shift: str = "default",
        resnet_act_fn: str = "swish",
        resnet_pre_norm: bool = True,
        output_scale_factor: float = np.sqrt(2.0),
        add_upsample: bool = True,
        upsample_padding: int = 1,
    )

Source from the content-addressed store, hash-verified

3076
3077class SkipUpBlock2D(nn.Module):
3078 def __init__(
3079 self,
3080 in_channels: int,
3081 prev_output_channel: int,
3082 out_channels: int,
3083 temb_channels: int,
3084 resolution_idx: Optional[int] = None,
3085 dropout: float = 0.0,
3086 num_layers: int = 1,
3087 resnet_eps: float = 1e-6,
3088 resnet_time_scale_shift: str = "default",
3089 resnet_act_fn: str = "swish",
3090 resnet_pre_norm: bool = True,
3091 output_scale_factor: float = np.sqrt(2.0),
3092 add_upsample: bool = True,
3093 upsample_padding: int = 1,
3094 ):
3095 super().__init__()
3096 self.resnets = nn.ModuleList([])
3097
3098 for i in range(num_layers):
3099 res_skip_channels = in_channels if (i == num_layers - 1) else out_channels
3100 resnet_in_channels = prev_output_channel if i == 0 else out_channels
3101
3102 self.resnets.append(
3103 ResnetBlock2D(
3104 in_channels=resnet_in_channels + res_skip_channels,
3105 out_channels=out_channels,
3106 temb_channels=temb_channels,
3107 eps=resnet_eps,
3108 groups=min((resnet_in_channels + res_skip_channels) // 4, 32),
3109 groups_out=min(out_channels // 4, 32),
3110 dropout=dropout,
3111 time_embedding_norm=resnet_time_scale_shift,
3112 non_linearity=resnet_act_fn,
3113 output_scale_factor=output_scale_factor,
3114 pre_norm=resnet_pre_norm,
3115 )
3116 )
3117
3118 self.upsampler = FirUpsample2D(in_channels, out_channels=out_channels)
3119 if add_upsample:
3120 self.resnet_up = ResnetBlock2D(
3121 in_channels=out_channels,
3122 out_channels=out_channels,
3123 temb_channels=temb_channels,
3124 eps=resnet_eps,
3125 groups=min(out_channels // 4, 32),
3126 groups_out=min(out_channels // 4, 32),
3127 dropout=dropout,
3128 time_embedding_norm=resnet_time_scale_shift,
3129 non_linearity=resnet_act_fn,
3130 output_scale_factor=output_scale_factor,
3131 pre_norm=resnet_pre_norm,
3132 use_in_shortcut=True,
3133 up=True,
3134 kernel="fir",
3135 )

Callers

nothing calls this directly

Calls 3

ResnetBlock2DClass · 0.85
FirUpsample2DClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected