MCPcopy
hub / github.com/hustvl/Vim / _convert_boxes_to_pooler_format

Function _convert_boxes_to_pooler_format

det/detectron2/modeling/poolers.py:64–69  ·  view source on GitHub ↗
(boxes: torch.Tensor, sizes: torch.Tensor)

Source from the content-addressed store, hash-verified

62# script the module to avoid hardcoded device type
63@torch.jit.script_if_tracing
64def _convert_boxes_to_pooler_format(boxes: torch.Tensor, sizes: torch.Tensor) -> torch.Tensor:
65 sizes = sizes.to(device=boxes.device)
66 indices = torch.repeat_interleave(
67 torch.arange(len(sizes), dtype=boxes.dtype, device=boxes.device), sizes
68 )
69 return cat([indices[:, None], boxes], dim=1)
70
71
72def convert_boxes_to_pooler_format(box_lists: List[Boxes]):

Callers 1

Calls 2

catFunction · 0.90
toMethod · 0.45

Tested by

no test coverage detected