(
self,
image: Optional[torch.Tensor],
text: Optional[torch.Tensor]
)
| 338 | return self.forward_reconstruction(reconstruction_image) |
| 339 | |
| 340 | def forward_clip( |
| 341 | self, |
| 342 | image: Optional[torch.Tensor], |
| 343 | text: Optional[torch.Tensor] |
| 344 | ): |
| 345 | image_features = self.encode_image(image, normalize=True) if image is not None else None |
| 346 | text_features = self.encode_text(text, normalize=True) if text is not None else None |
| 347 | |
| 348 | if self.output_dict: |
| 349 | out_dict = { |
| 350 | "image_features": image_features, |
| 351 | "text_features": text_features, |
| 352 | "logit_scale": self.logit_scale.exp() |
| 353 | } |
| 354 | if self.logit_bias is not None: |
| 355 | out_dict['logit_bias'] = self.logit_bias |
| 356 | return out_dict |
| 357 | |
| 358 | if self.logit_bias is not None: |
| 359 | return image_features, text_features, self.logit_scale.exp(), self.logit_bias |
| 360 | return image_features, text_features, self.logit_scale.exp() |
| 361 | |
| 362 | def forward_reconstruction(self, reconstruction_image: torch.Tensor): |
| 363 | return self.get_reconstruction_outputs(reconstruction_image) |
no test coverage detected