MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / cat

Method cat

detectron2/structures/boxes.py:281–306  ·  view source on GitHub ↗

Concatenates a list of Boxes into a single Boxes Arguments: boxes_list (list[Boxes]) Returns: Boxes: the concatenated Boxes

(cls, boxes_list: List["Boxes"])

Source from the content-addressed store, hash-verified

279
280 @classmethod
281 def cat(cls, boxes_list: List["Boxes"]) -> "Boxes":
282 """
283 Concatenates a list of Boxes into a single Boxes
284
285 Arguments:
286 boxes_list (list[Boxes])
287
288 Returns:
289 Boxes: the concatenated Boxes
290 """
291 if torch.jit.is_scripting():
292 # https://github.com/pytorch/pytorch/issues/18627
293 # 1. staticmethod can be used in torchscript, But we can not use
294 # `type(boxes).staticmethod` because torchscript only supports function
295 # `type` with input type `torch.Tensor`.
296 # 2. classmethod is not fully supported by torchscript. We explicitly assign
297 # cls to Box as a workaround to get torchscript support.
298 cls = Boxes
299 assert isinstance(boxes_list, (list, tuple))
300 if len(boxes_list) == 0:
301 return cls(torch.empty(0))
302 assert all([isinstance(box, Boxes) for box in boxes_list])
303
304 # use torch.cat (v.s. layers.cat) so the returned boxes never share storage with input
305 cat_boxes = cls(torch.cat([b.tensor for b in boxes_list], dim=0))
306 return cat_boxes
307
308 @property
309 def device(self) -> device:

Callers 15

_get_augmented_boxesMethod · 0.45
forwardMethod · 0.45
__init__Method · 0.45
predict_boxesMethod · 0.45
_sample_proposalsMethod · 0.45
forwardMethod · 0.45
mask_rcnn_lossFunction · 0.45
lossesMethod · 0.45
label_anchorsMethod · 0.45

Calls

no outgoing calls

Tested by 8

_get_augmented_boxesMethod · 0.36
bbox_voteMethod · 0.36
get_soft_dets_sumMethod · 0.36
random_rotated_boxesFunction · 0.36
test_empty_catMethod · 0.36
test_empty_catMethod · 0.36
benchmark_pasteFunction · 0.36
funcFunction · 0.36