| 586 | |
| 587 | |
| 588 | class MLPProj(torch.nn.Module): |
| 589 | |
| 590 | def __init__(self, in_dim, out_dim): |
| 591 | super().__init__() |
| 592 | |
| 593 | self.proj = torch.nn.Sequential( |
| 594 | torch.nn.LayerNorm(in_dim), torch.nn.Linear(in_dim, in_dim), |
| 595 | torch.nn.GELU(), torch.nn.Linear(in_dim, out_dim), |
| 596 | torch.nn.LayerNorm(out_dim)) |
| 597 | |
| 598 | def forward(self, image_embeds): |
| 599 | clip_extra_context_tokens = self.proj(image_embeds) |
| 600 | return clip_extra_context_tokens |
| 601 | |
| 602 | |
| 603 |