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

Method __init__

src/diffusers/models/unets/unet_2d_blocks.py:632–744  ·  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",  # default, spatial
        resnet_act_fn: str = "swish",
        resnet_groups: int = 32,
        attn_groups: Optional[int] = None,
        resnet_pre_norm: bool = True,
        add_attention: bool = True,
        attention_head_dim: int = 1,
        output_scale_factor: float = 1.0,
    )

Source from the content-addressed store, hash-verified

630 """
631
632 def __init__(
633 self,
634 in_channels: int,
635 temb_channels: int,
636 dropout: float = 0.0,
637 num_layers: int = 1,
638 resnet_eps: float = 1e-6,
639 resnet_time_scale_shift: str = "default", # default, spatial
640 resnet_act_fn: str = "swish",
641 resnet_groups: int = 32,
642 attn_groups: Optional[int] = None,
643 resnet_pre_norm: bool = True,
644 add_attention: bool = True,
645 attention_head_dim: int = 1,
646 output_scale_factor: float = 1.0,
647 ):
648 super().__init__()
649 resnet_groups = resnet_groups if resnet_groups is not None else min(in_channels // 4, 32)
650 self.add_attention = add_attention
651
652 if attn_groups is None:
653 attn_groups = resnet_groups if resnet_time_scale_shift == "default" else None
654
655 # there is always at least one resnet
656 if resnet_time_scale_shift == "spatial":
657 resnets = [
658 ResnetBlockCondNorm2D(
659 in_channels=in_channels,
660 out_channels=in_channels,
661 temb_channels=temb_channels,
662 eps=resnet_eps,
663 groups=resnet_groups,
664 dropout=dropout,
665 time_embedding_norm="spatial",
666 non_linearity=resnet_act_fn,
667 output_scale_factor=output_scale_factor,
668 )
669 ]
670 else:
671 resnets = [
672 ResnetBlock2D(
673 in_channels=in_channels,
674 out_channels=in_channels,
675 temb_channels=temb_channels,
676 eps=resnet_eps,
677 groups=resnet_groups,
678 dropout=dropout,
679 time_embedding_norm=resnet_time_scale_shift,
680 non_linearity=resnet_act_fn,
681 output_scale_factor=output_scale_factor,
682 pre_norm=resnet_pre_norm,
683 )
684 ]
685 attentions = []
686
687 if attention_head_dim is None:
688 logger.warn(
689 f"It is not recommend to pass `attention_head_dim=None`. Defaulting `attention_head_dim` to `in_channels`: {in_channels}."

Callers

nothing calls this directly

Calls 4

ResnetBlock2DClass · 0.85
AttentionClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected