MCPcopy Create free account
hub / github.com/MeiGen-AI/MultiTalk / MLPProj

Class MLPProj

wan/modules/model.py:350–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348
349
350class MLPProj(torch.nn.Module):
351
352 def __init__(self, in_dim, out_dim, flf_pos_emb=False):
353 super().__init__()
354
355 self.proj = torch.nn.Sequential(
356 torch.nn.LayerNorm(in_dim), torch.nn.Linear(in_dim, in_dim),
357 torch.nn.GELU(), torch.nn.Linear(in_dim, out_dim),
358 torch.nn.LayerNorm(out_dim))
359 if flf_pos_emb: # NOTE: we only use this for `flf2v`
360 self.emb_pos = nn.Parameter(
361 torch.zeros(1, FIRST_LAST_FRAME_CONTEXT_TOKEN_NUMBER, 1280))
362
363 def forward(self, image_embeds):
364 if hasattr(self, 'emb_pos'):
365 bs, n, d = image_embeds.shape
366 image_embeds = image_embeds.view(-1, 2 * n, d)
367 image_embeds = image_embeds + self.emb_pos
368 clip_extra_context_tokens = self.proj(image_embeds)
369 return clip_extra_context_tokens
370
371
372class WanModel(ModelMixin, ConfigMixin):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected