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

Method __init__

src/diffusers/models/brushnet.py:138–449  ·  view source on GitHub ↗
(
        self,
        in_channels: int = 4,
        conditioning_channels: int = 5,
        flip_sin_to_cos: bool = True,
        freq_shift: int = 0,
        down_block_types: Tuple[str, ...] = (
            "DownBlock2D",
            "DownBlock2D",
            "DownBlock2D",
            "DownBlock2D",
        ),
        mid_block_type: Optional[str] = "UNetMidBlock2D",
        up_block_types: Tuple[str, ...] = (
            "UpBlock2D", 
            "UpBlock2D", 
            "UpBlock2D", 
            "UpBlock2D",
        ),
        only_cross_attention: Union[bool, Tuple[bool]] = False,
        block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280),
        layers_per_block: int = 2,
        downsample_padding: int = 1,
        mid_block_scale_factor: float = 1,
        act_fn: str = "silu",
        norm_num_groups: Optional[int] = 32,
        norm_eps: float = 1e-5,
        cross_attention_dim: int = 1280,
        transformer_layers_per_block: Union[int, Tuple[int, ...]] = 1,
        encoder_hid_dim: Optional[int] = None,
        encoder_hid_dim_type: Optional[str] = None,
        attention_head_dim: Union[int, Tuple[int, ...]] = 8,
        num_attention_heads: Optional[Union[int, Tuple[int, ...]]] = None,
        use_linear_projection: bool = False,
        class_embed_type: Optional[str] = None,
        addition_embed_type: Optional[str] = None,
        addition_time_embed_dim: Optional[int] = None,
        num_class_embeds: Optional[int] = None,
        upcast_attention: bool = False,
        resnet_time_scale_shift: str = "default",
        projection_class_embeddings_input_dim: Optional[int] = None,
        brushnet_conditioning_channel_order: str = "rgb",
        conditioning_embedding_out_channels: Optional[Tuple[int, ...]] = (16, 32, 96, 256),
        global_pool_conditions: bool = False,
        addition_embed_type_num_heads: int = 64,
    )

Source from the content-addressed store, hash-verified

136
137 @register_to_config
138 def __init__(
139 self,
140 in_channels: int = 4,
141 conditioning_channels: int = 5,
142 flip_sin_to_cos: bool = True,
143 freq_shift: int = 0,
144 down_block_types: Tuple[str, ...] = (
145 "DownBlock2D",
146 "DownBlock2D",
147 "DownBlock2D",
148 "DownBlock2D",
149 ),
150 mid_block_type: Optional[str] = "UNetMidBlock2D",
151 up_block_types: Tuple[str, ...] = (
152 "UpBlock2D",
153 "UpBlock2D",
154 "UpBlock2D",
155 "UpBlock2D",
156 ),
157 only_cross_attention: Union[bool, Tuple[bool]] = False,
158 block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280),
159 layers_per_block: int = 2,
160 downsample_padding: int = 1,
161 mid_block_scale_factor: float = 1,
162 act_fn: str = "silu",
163 norm_num_groups: Optional[int] = 32,
164 norm_eps: float = 1e-5,
165 cross_attention_dim: int = 1280,
166 transformer_layers_per_block: Union[int, Tuple[int, ...]] = 1,
167 encoder_hid_dim: Optional[int] = None,
168 encoder_hid_dim_type: Optional[str] = None,
169 attention_head_dim: Union[int, Tuple[int, ...]] = 8,
170 num_attention_heads: Optional[Union[int, Tuple[int, ...]]] = None,
171 use_linear_projection: bool = False,
172 class_embed_type: Optional[str] = None,
173 addition_embed_type: Optional[str] = None,
174 addition_time_embed_dim: Optional[int] = None,
175 num_class_embeds: Optional[int] = None,
176 upcast_attention: bool = False,
177 resnet_time_scale_shift: str = "default",
178 projection_class_embeddings_input_dim: Optional[int] = None,
179 brushnet_conditioning_channel_order: str = "rgb",
180 conditioning_embedding_out_channels: Optional[Tuple[int, ...]] = (16, 32, 96, 256),
181 global_pool_conditions: bool = False,
182 addition_embed_type_num_heads: int = 64,
183 ):
184 super().__init__()
185
186 # If `num_attention_heads` is not defined (which is the case for most models)
187 # it will default to `attention_head_dim`. This looks weird upon first reading it and it is.
188 # The reason for this behavior is to correct for incorrectly named variables that were introduced
189 # when this library was created. The incorrect naming was only discovered much later in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131
190 # Changing `attention_head_dim` to `num_attention_heads` for 40,000+ configurations is too backwards breaking
191 # which is why we correct for the naming here.
192 num_attention_heads = num_attention_heads or attention_head_dim
193
194 # Check inputs
195 if len(down_block_types) != len(up_block_types):

Callers

nothing calls this directly

Calls 11

TimestepsClass · 0.85
TimestepEmbeddingClass · 0.85
TextImageProjectionClass · 0.85
TextTimeEmbeddingClass · 0.85
register_to_configMethod · 0.80
infoMethod · 0.80
zero_moduleFunction · 0.70
get_down_blockFunction · 0.70
get_mid_blockFunction · 0.70
get_up_blockFunction · 0.70

Tested by

no test coverage detected