(self, image, text, clamp_logit_scale_to=None)
| 439 | return x |
| 440 | |
| 441 | def forward(self, image, text, clamp_logit_scale_to=None): |
| 442 | if image is not None: |
| 443 | image_features = self.encode_image(image) |
| 444 | image_features = F.normalize(image_features, dim=-1) |
| 445 | else: |
| 446 | image_features = None |
| 447 | if text is not None: |
| 448 | text_features = self.encode_text(text) |
| 449 | text_features = F.normalize(text_features, dim=-1) |
| 450 | else: |
| 451 | text_features = None |
| 452 | if clamp_logit_scale_to is not None: |
| 453 | with torch.no_grad(): |
| 454 | self.logit_scale.data.clamp_(0, clamp_logit_scale_to) |
| 455 | return image_features, text_features, self.logit_scale.exp() |
| 456 | |
| 457 | |
| 458 | def convert_weights_to_fp16(model: nn.Module): |
nothing calls this directly
no test coverage detected