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

Method __getitem__

detectron2/structures/keypoints.py:59–75  ·  view source on GitHub ↗

Create a new `Keypoints` by indexing on this `Keypoints`. The following usage are allowed: 1. `new_kpts = kpts[3]`: return a `Keypoints` which contains only one instance. 2. `new_kpts = kpts[2:10]`: return a slice of key points. 3. `new_kpts = kpts[vector]`

(self, item: Union[int, slice, torch.BoolTensor])

Source from the content-addressed store, hash-verified

57 return _keypoints_to_heatmap(self.tensor, boxes, heatmap_size)
58
59 def __getitem__(self, item: Union[int, slice, torch.BoolTensor]) -> "Keypoints":
60 """
61 Create a new `Keypoints` by indexing on this `Keypoints`.
62
63 The following usage are allowed:
64
65 1. `new_kpts = kpts[3]`: return a `Keypoints` which contains only one instance.
66 2. `new_kpts = kpts[2:10]`: return a slice of key points.
67 3. `new_kpts = kpts[vector]`, where vector is a torch.ByteTensor
68 with `length = len(kpts)`. Nonzero elements in the vector will be selected.
69
70 Note that the returned Keypoints might share storage with this Keypoints,
71 subject to Pytorch's indexing semantics.
72 """
73 if isinstance(item, int):
74 return Keypoints([self.tensor[item]])
75 return Keypoints(self.tensor[item])
76
77 def __repr__(self) -> str:
78 s = self.__class__.__name__ + "("

Callers

nothing calls this directly

Calls 1

KeypointsClass · 0.85

Tested by

no test coverage detected