MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / IpAdapterImageProjModel

Class IpAdapterImageProjModel

diffsynth/models/sdxl_ipadapter.py:17–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class IpAdapterImageProjModel(torch.nn.Module):
18 def __init__(self, cross_attention_dim=2048, clip_embeddings_dim=1280, clip_extra_context_tokens=4):
19 super().__init__()
20 self.cross_attention_dim = cross_attention_dim
21 self.clip_extra_context_tokens = clip_extra_context_tokens
22 self.proj = torch.nn.Linear(clip_embeddings_dim, self.clip_extra_context_tokens * cross_attention_dim)
23 self.norm = torch.nn.LayerNorm(cross_attention_dim)
24
25 def forward(self, image_embeds):
26 clip_extra_context_tokens = self.proj(image_embeds).reshape(-1, self.clip_extra_context_tokens, self.cross_attention_dim)
27 clip_extra_context_tokens = self.norm(clip_extra_context_tokens)
28 return clip_extra_context_tokens
29
30
31class IpAdapterModule(torch.nn.Module):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected