|
11 | 11 | class KeyPoints(TVTensor): |
12 | 12 | """:class:`torch.Tensor` subclass for tensors with shape ``[..., 2]`` that represent points in an image. |
13 | 13 |
|
14 | | - Each point is represented by its XY coordinates. |
| 14 | + Each point is represented by its X and Y coordinates along the width and height dimensions, respectively. |
15 | 15 |
|
16 | 16 | KeyPoints can be converted from :class:`torchvision.tv_tensors.BoundingBoxes` |
17 | 17 | by :func:`torchvision.transforms.v2.functional.convert_bounding_boxes_to_points`. |
18 | 18 |
|
19 | 19 | KeyPoints may represent any object that can be represented by sequences of 2D points: |
20 | | - - `Polygonal chains<https://en.wikipedia.org/wiki/Polygonal_chain>`, including polylines, Bézier curves, etc., |
21 | | - which should be of shape ``[N_chains, N_points, 2]``, which is equal to ``[N_chains, N_segments + 1, 2]`` |
22 | | - - Polygons, which should be of shape ``[N_polygons, N_points, 2]``, which is equal to ``[N_polygons, N_sides, 2]`` |
23 | | - - Skeletons, which could be of shape ``[N_skeletons, N_bones, 2, 2]`` for pose-estimation models |
24 | 20 |
|
25 | | - .. note:: |
| 21 | + - `Polygonal chains <https://en.wikipedia.org/wiki/Polygonal_chain>`_, |
| 22 | + including polylines, Bézier curves, etc., which should be of shape |
| 23 | + ``[N_chains, N_points, 2]``, which is equal to ``[N_chains, N_segments + |
| 24 | + 1, 2]`` |
| 25 | + - Polygons, which should be of shape ``[N_polygons, N_points, 2]``, which is |
| 26 | + equal to ``[N_polygons, N_sides, 2]`` |
| 27 | + - Skeletons, which could be of shape ``[N_skeletons, N_bones, 2, 2]`` for |
| 28 | + pose-estimation models |
26 | 29 |
|
27 | | - Like for :class:`torchvision.tv_tensors.BoundingBoxes`, there should only ever be a single |
28 | | - instance of the :class:`torchvision.tv_tensors.KeyPoints` class per sample |
29 | | - e.g. ``{"img": img, "poins_of_interest": KeyPoints(...)}``, |
30 | | - although one :class:`torchvision.tv_tensors.KeyPoints` object can contain multiple key points |
| 30 | + .. note:: |
| 31 | + Like for :class:`torchvision.tv_tensors.BoundingBoxes`, there should |
| 32 | + only be a single instance of the |
| 33 | + :class:`torchvision.tv_tensors.KeyPoints` class per sample e.g. |
| 34 | + ``{"img": img, "poins_of_interest": KeyPoints(...)}``, although one |
| 35 | + :class:`torchvision.tv_tensors.KeyPoints` object can contain multiple |
| 36 | + key points |
31 | 37 |
|
32 | 38 | Args: |
33 | | - data: Any data that can be turned into a tensor with :func:`torch.as_tensor`. |
34 | | - canvas_size (two-tuple of ints): Height and width of the corresponding image or video. |
35 | | - dtype (torch.dtype, optional): Desired data type of the bounding box. If omitted, will be inferred from |
36 | | - ``data``. |
37 | | - device (torch.device, optional): Desired device of the bounding box. If omitted and ``data`` is a |
38 | | - :class:`torch.Tensor`, the device is taken from it. Otherwise, the bounding box is constructed on the CPU. |
39 | | - requires_grad (bool, optional): Whether autograd should record operations on the bounding box. If omitted and |
40 | | - ``data`` is a :class:`torch.Tensor`, the value is taken from it. Otherwise, defaults to ``False``. |
| 39 | + data: Any data that can be turned into a tensor with |
| 40 | + :func:`torch.as_tensor`. |
| 41 | + canvas_size (two-tuple of ints): Height and width of the corresponding |
| 42 | + image or video. |
| 43 | + dtype (torch.dtype, optional): Desired data type of the bounding box. If |
| 44 | + omitted, will be inferred from ``data``. |
| 45 | + device (torch.device, optional): Desired device of the bounding box. If |
| 46 | + omitted and ``data`` is a :class:`torch.Tensor`, the device is taken |
| 47 | + from it. Otherwise, the bounding box is constructed on the CPU. |
| 48 | + requires_grad (bool, optional): Whether autograd should record |
| 49 | + operations on the bounding box. If omitted and ``data`` is a |
| 50 | + :class:`torch.Tensor`, the value is taken from it. Otherwise, |
| 51 | + defaults to ``False``. |
41 | 52 | """ |
42 | 53 |
|
43 | 54 | canvas_size: tuple[int, int] |
|
0 commit comments