(case: PromptCase)
| 128 | |
| 129 | |
| 130 | def build_point_inputs(case: PromptCase): |
| 131 | coords: List[List[float]] = [] |
| 132 | labels: List[int] = [] |
| 133 | |
| 134 | if case.box: |
| 135 | coords.append([case.box[0], case.box[1]]) |
| 136 | coords.append([case.box[2], case.box[3]]) |
| 137 | labels.extend([2, 3]) |
| 138 | |
| 139 | coords.extend(case.pos_points) |
| 140 | labels.extend([1] * len(case.pos_points)) |
| 141 | |
| 142 | coords.extend(case.neg_points) |
| 143 | labels.extend([0] * len(case.neg_points)) |
| 144 | |
| 145 | coords_t = torch.tensor([coords], dtype=torch.float32) if coords else torch.zeros(1, 0, 2) |
| 146 | labels_t = torch.tensor([labels], dtype=torch.int64) if labels else torch.zeros(1, 0, dtype=torch.int64) |
| 147 | return coords_t, labels_t |
| 148 | |
| 149 | |
| 150 | def position_encode(coords_norm: torch.Tensor, pe_gaussian: torch.Tensor) -> torch.Tensor: |
no outgoing calls
no test coverage detected