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

Method __init__

src/diffusers/models/embeddings.py:192–223  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        time_embed_dim: int,
        act_fn: str = "silu",
        out_dim: int = None,
        post_act_fn: Optional[str] = None,
        cond_proj_dim=None,
        sample_proj_bias=True,
    )

Source from the content-addressed store, hash-verified

190
191class TimestepEmbedding(nn.Module):
192 def __init__(
193 self,
194 in_channels: int,
195 time_embed_dim: int,
196 act_fn: str = "silu",
197 out_dim: int = None,
198 post_act_fn: Optional[str] = None,
199 cond_proj_dim=None,
200 sample_proj_bias=True,
201 ):
202 super().__init__()
203 linear_cls = nn.Linear if USE_PEFT_BACKEND else LoRACompatibleLinear
204
205 self.linear_1 = linear_cls(in_channels, time_embed_dim, sample_proj_bias)
206
207 if cond_proj_dim is not None:
208 self.cond_proj = nn.Linear(cond_proj_dim, in_channels, bias=False)
209 else:
210 self.cond_proj = None
211
212 self.act = get_activation(act_fn)
213
214 if out_dim is not None:
215 time_embed_dim_out = out_dim
216 else:
217 time_embed_dim_out = time_embed_dim
218 self.linear_2 = linear_cls(time_embed_dim, time_embed_dim_out, sample_proj_bias)
219
220 if post_act_fn is None:
221 self.post_act = None
222 else:
223 self.post_act = get_activation(post_act_fn)
224
225 def forward(self, sample, condition=None):
226 if condition is not None:

Callers

nothing calls this directly

Calls 2

get_activationFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected