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

Method __init__

src/diffusers/models/unets/unet_2d_blocks.py:1027–1080  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        temb_channels: int,
        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_groups: int = 32,
        resnet_pre_norm: bool = True,
        output_scale_factor: float = 1.0,
        use_linear_projection: bool = False,
    )

Source from the content-addressed store, hash-verified

1025
1026class MidBlock2D(nn.Module):
1027 def __init__(
1028 self,
1029 in_channels: int,
1030 temb_channels: int,
1031 dropout: float = 0.0,
1032 num_layers: int = 1,
1033 resnet_eps: float = 1e-6,
1034 resnet_time_scale_shift: str = "default",
1035 resnet_act_fn: str = "swish",
1036 resnet_groups: int = 32,
1037 resnet_pre_norm: bool = True,
1038 output_scale_factor: float = 1.0,
1039 use_linear_projection: bool = False,
1040 ):
1041 super().__init__()
1042
1043 self.has_cross_attention = False
1044 resnet_groups = resnet_groups if resnet_groups is not None else min(in_channels // 4, 32)
1045
1046 # there is always at least one resnet
1047 resnets = [
1048 ResnetBlock2D(
1049 in_channels=in_channels,
1050 out_channels=in_channels,
1051 temb_channels=temb_channels,
1052 eps=resnet_eps,
1053 groups=resnet_groups,
1054 dropout=dropout,
1055 time_embedding_norm=resnet_time_scale_shift,
1056 non_linearity=resnet_act_fn,
1057 output_scale_factor=output_scale_factor,
1058 pre_norm=resnet_pre_norm,
1059 )
1060 ]
1061
1062 for i in range(num_layers):
1063 resnets.append(
1064 ResnetBlock2D(
1065 in_channels=in_channels,
1066 out_channels=in_channels,
1067 temb_channels=temb_channels,
1068 eps=resnet_eps,
1069 groups=resnet_groups,
1070 dropout=dropout,
1071 time_embedding_norm=resnet_time_scale_shift,
1072 non_linearity=resnet_act_fn,
1073 output_scale_factor=output_scale_factor,
1074 pre_norm=resnet_pre_norm,
1075 )
1076 )
1077
1078 self.resnets = nn.ModuleList(resnets)
1079
1080 self.gradient_checkpointing = False
1081
1082 def forward(
1083 self,

Callers

nothing calls this directly

Calls 2

ResnetBlock2DClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected