Get the image feature on the input batch.
(self, img_batch: torch.Tensor)
| 461 | ) |
| 462 | |
| 463 | def forward_image(self, img_batch: torch.Tensor): |
| 464 | """Get the image feature on the input batch.""" |
| 465 | backbone_out = self.image_encoder(img_batch) |
| 466 | if self.use_high_res_features_in_sam: |
| 467 | # precompute projected level 0 and level 1 features in SAM decoder |
| 468 | # to avoid running it again on every SAM click |
| 469 | backbone_out["backbone_fpn"][0] = self.sam_mask_decoder.conv_s0( |
| 470 | backbone_out["backbone_fpn"][0] |
| 471 | ) |
| 472 | backbone_out["backbone_fpn"][1] = self.sam_mask_decoder.conv_s1( |
| 473 | backbone_out["backbone_fpn"][1] |
| 474 | ) |
| 475 | return backbone_out |
| 476 | |
| 477 | def _prepare_backbone_features(self, backbone_out): |
| 478 | """Prepare and flatten visual features.""" |
no outgoing calls
no test coverage detected