MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / build_point_inputs

Function build_point_inputs

tests/dump_phase6_reference.py:130–147  ·  view source on GitHub ↗
(case: PromptCase)

Source from the content-addressed store, hash-verified

128
129
130def 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
150def position_encode(coords_norm: torch.Tensor, pe_gaussian: torch.Tensor) -> torch.Tensor:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected