Concatenates a list of Boxes into a single Boxes Arguments: boxes_list (list[Boxes]) Returns: Boxes: the concatenated Boxes
(cls, boxes_list: List["Boxes"])
| 277 | |
| 278 | @classmethod |
| 279 | def cat(cls, boxes_list: List["Boxes"]) -> "Boxes": |
| 280 | """ |
| 281 | Concatenates a list of Boxes into a single Boxes |
| 282 | |
| 283 | Arguments: |
| 284 | boxes_list (list[Boxes]) |
| 285 | |
| 286 | Returns: |
| 287 | Boxes: the concatenated Boxes |
| 288 | """ |
| 289 | assert isinstance(boxes_list, (list, tuple)) |
| 290 | if len(boxes_list) == 0: |
| 291 | return cls(torch.empty(0)) |
| 292 | assert all([isinstance(box, Boxes) for box in boxes_list]) |
| 293 | |
| 294 | # use torch.cat (v.s. layers.cat) so the returned boxes never share storage with input |
| 295 | cat_boxes = cls(torch.cat([b.tensor for b in boxes_list], dim=0)) |
| 296 | return cat_boxes |
| 297 | |
| 298 | @property |
| 299 | def device(self) -> device: |
no outgoing calls