| import math | |
| import torch | |
| from torch import nn | |
| class MMVisionProjector(nn.Module): | |
| def __init__(self, in_dim, out_dim, source_tokens=64, target_tokens=64): | |
| super().__init__() | |
| self.mlp = nn.Sequential( | |
| nn.LayerNorm(in_dim), | |
| nn.Linear(in_dim, out_dim), | |
| nn.GELU(), | |
| nn.Linear(out_dim, out_dim), | |
| ) | |
| def forward(self, x): | |
| return self.mlp(x) | |