Encode a set of proposals with respect to some ground truth (gt) boxes. Args: gt_boxes: list of gt boxes, Nx4 or Nx6 torch tensor. The box mode is assumed to be ``StandardMode`` proposals: list of boxes to be encoded, each element is Mx4 or Mx6 torch tensor.
(self, gt_boxes: Sequence[Tensor], proposals: Sequence[Tensor])
| 130 | self.boxes_xform_clip = boxes_xform_clip |
| 131 | |
| 132 | def encode(self, gt_boxes: Sequence[Tensor], proposals: Sequence[Tensor]) -> tuple[Tensor]: |
| 133 | """ |
| 134 | Encode a set of proposals with respect to some ground truth (gt) boxes. |
| 135 | |
| 136 | Args: |
| 137 | gt_boxes: list of gt boxes, Nx4 or Nx6 torch tensor. The box mode is assumed to be ``StandardMode`` |
| 138 | proposals: list of boxes to be encoded, each element is Mx4 or Mx6 torch tensor. |
| 139 | The box mode is assumed to be ``StandardMode`` |
| 140 | |
| 141 | Return: |
| 142 | A tuple of encoded gt, target of box regression that is used to |
| 143 | convert proposals into gt_boxes, Nx4 or Nx6 torch tensor. |
| 144 | """ |
| 145 | boxes_per_image = [len(b) for b in gt_boxes] |
| 146 | # concat the lists to do computation |
| 147 | concat_gt_boxes = torch.cat(tuple(gt_boxes), dim=0) |
| 148 | concat_proposals = torch.cat(tuple(proposals), dim=0) |
| 149 | concat_targets = self.encode_single(concat_gt_boxes, concat_proposals) |
| 150 | # split to tuple |
| 151 | targets: tuple[Tensor] = concat_targets.split(boxes_per_image, 0) |
| 152 | return targets |
| 153 | |
| 154 | def encode_single(self, gt_boxes: Tensor, proposals: Tensor) -> Tensor: |
| 155 | """ |
nothing calls this directly
no test coverage detected