Encode box (cx, cy, w, h) with sinusoidal PE. Returns [N, 258].
(cx, cy, w, h, num_pos_feats=128, temperature=10000)
| 105 | |
| 106 | |
| 107 | def sine_encode_boxes(cx, cy, w, h, num_pos_feats=128, temperature=10000): |
| 108 | """Encode box (cx, cy, w, h) with sinusoidal PE. Returns [N, 258].""" |
| 109 | pos_x, pos_y = sine_encode_xy(cx, cy, num_pos_feats, temperature) |
| 110 | pos = torch.cat((pos_y, pos_x, h[:, None], w[:, None]), dim=1) # [N, 258] |
| 111 | return pos |
| 112 | |
| 113 | |
| 114 | # ── Box coordinate conversion ────────────────────────────────────────────── |
no test coverage detected