MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / get_reference_points

Method get_reference_points

models/aios/transformer.py:555–578  ·  view source on GitHub ↗
(spatial_shapes, valid_ratios, device)

Source from the content-addressed store, hash-verified

553
554 @staticmethod
555 def get_reference_points(spatial_shapes, valid_ratios, device):
556 reference_points_list = []
557 for lvl, (H_, W_) in enumerate(spatial_shapes):
558
559 ref_y, ref_x = torch.meshgrid(
560 torch.linspace(0.5,
561 H_ - 0.5,
562 H_,
563 dtype=torch.float32,
564 device=device),
565 torch.linspace(0.5,
566 W_ - 0.5,
567 W_,
568 dtype=torch.float32,
569 device=device))
570 ref_y = ref_y.reshape(-1)[None] / (valid_ratios[:, None, lvl, 1] *
571 H_)
572 ref_x = ref_x.reshape(-1)[None] / (valid_ratios[:, None, lvl, 0] *
573 W_)
574 ref = torch.stack((ref_x, ref_y), -1)
575 reference_points_list.append(ref)
576 reference_points = torch.cat(reference_points_list, 1)
577 reference_points = reference_points[:, :, None] * valid_ratios[:, None]
578 return reference_points
579
580 def forward(self,
581 src: Tensor,

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected