(self, image_features, attention_mask)
| 1684 | |
| 1685 | @torch.no_grad |
| 1686 | def patch_merger_forward(self, image_features, attention_mask): |
| 1687 | h, w = attention_mask.shape[-2:] |
| 1688 | bs, n, d = image_features.shape |
| 1689 | image_grid = image_features.view(bs, h, w, d).permute(0, 3, 1, 2) |
| 1690 | image_features = torch.nn.functional.unfold(image_grid, 2, |
| 1691 | stride=2).transpose(1, 2) |
| 1692 | image_features = self.merging_layer(image_features) |
| 1693 | return image_features |
| 1694 | |
| 1695 | @torch.no_grad |
| 1696 | def mm_projector_forward(self, image_features, attention_mask): |