Gets the batch size of the output given the batch size of the input prompts.
(
self,
points: Optional[Tuple[torch.Tensor, torch.Tensor]],
boxes: Optional[torch.Tensor],
masks: Optional[torch.Tensor],
)
| 107 | return mask_embedding |
| 108 | |
| 109 | def _get_batch_size( |
| 110 | self, |
| 111 | points: Optional[Tuple[torch.Tensor, torch.Tensor]], |
| 112 | boxes: Optional[torch.Tensor], |
| 113 | masks: Optional[torch.Tensor], |
| 114 | ) -> int: |
| 115 | """ |
| 116 | Gets the batch size of the output given the batch size of the input prompts. |
| 117 | """ |
| 118 | if points is not None: |
| 119 | return points[0].shape[0] |
| 120 | elif boxes is not None: |
| 121 | return boxes.shape[0] |
| 122 | elif masks is not None: |
| 123 | return masks.shape[0] |
| 124 | else: |
| 125 | return 1 |
| 126 | |
| 127 | def _get_device(self) -> torch.device: |
| 128 | return self.point_embeddings[0].weight.device |