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

Method __init__

src/diffusers/models/unets/unet_3d_blocks.py:1435–1502  ·  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_groups: int = 32,
        resnet_pre_norm: bool = True,
        output_scale_factor: float = 1.0,
        add_upsample: bool = True,
        temporal_norm_num_groups: int = 32,
        temporal_cross_attention_dim: Optional[int] = None,
        temporal_num_attention_heads: int = 8,
        temporal_max_seq_length: int = 32,
    )

Source from the content-addressed store, hash-verified

1433
1434class UpBlockMotion(nn.Module):
1435 def __init__(
1436 self,
1437 in_channels: int,
1438 prev_output_channel: int,
1439 out_channels: int,
1440 temb_channels: int,
1441 resolution_idx: Optional[int] = None,
1442 dropout: float = 0.0,
1443 num_layers: int = 1,
1444 resnet_eps: float = 1e-6,
1445 resnet_time_scale_shift: str = "default",
1446 resnet_act_fn: str = "swish",
1447 resnet_groups: int = 32,
1448 resnet_pre_norm: bool = True,
1449 output_scale_factor: float = 1.0,
1450 add_upsample: bool = True,
1451 temporal_norm_num_groups: int = 32,
1452 temporal_cross_attention_dim: Optional[int] = None,
1453 temporal_num_attention_heads: int = 8,
1454 temporal_max_seq_length: int = 32,
1455 ):
1456 super().__init__()
1457 resnets = []
1458 motion_modules = []
1459
1460 for i in range(num_layers):
1461 res_skip_channels = in_channels if (i == num_layers - 1) else out_channels
1462 resnet_in_channels = prev_output_channel if i == 0 else out_channels
1463
1464 resnets.append(
1465 ResnetBlock2D(
1466 in_channels=resnet_in_channels + res_skip_channels,
1467 out_channels=out_channels,
1468 temb_channels=temb_channels,
1469 eps=resnet_eps,
1470 groups=resnet_groups,
1471 dropout=dropout,
1472 time_embedding_norm=resnet_time_scale_shift,
1473 non_linearity=resnet_act_fn,
1474 output_scale_factor=output_scale_factor,
1475 pre_norm=resnet_pre_norm,
1476 )
1477 )
1478
1479 motion_modules.append(
1480 TransformerTemporalModel(
1481 num_attention_heads=temporal_num_attention_heads,
1482 in_channels=out_channels,
1483 norm_num_groups=temporal_norm_num_groups,
1484 cross_attention_dim=temporal_cross_attention_dim,
1485 attention_bias=False,
1486 activation_fn="geglu",
1487 positional_embeddings="sinusoidal",
1488 num_positional_embeddings=temporal_max_seq_length,
1489 attention_head_dim=out_channels // temporal_num_attention_heads,
1490 )
1491 )
1492

Callers

nothing calls this directly

Calls 4

ResnetBlock2DClass · 0.85
Upsample2DClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected