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

Function sine_encode_boxes

tests/dump_geom_encoder_reference.py:107–111  ·  view source on GitHub ↗

Encode box (cx, cy, w, h) with sinusoidal PE. Returns [N, 258].

(cx, cy, w, h, num_pos_feats=128, temperature=10000)

Source from the content-addressed store, hash-verified

105
106
107def 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 ──────────────────────────────────────────────

Callers 1

dump_geometry_encoderFunction · 0.85

Calls 1

sine_encode_xyFunction · 0.85

Tested by

no test coverage detected