SanitizeKeyPoints¶
- class torchvision.transforms.v2.SanitizeKeyPoints(labels_getter: Optional[Union[Callable[[Any], Any], str]] = None)[source]¶
Remove keypoints outside of the image area and their corresponding labels (if any).
This transform removes keypoints or groups of keypoints and their associated labels that have coordinates outside of their corresponding image. If you would instead like to clamp such keypoints to the image edges, use
ClampKeyPoints
.It is recommended to call it at the end of a pipeline, before passing the input to the models.
Keypoints can be passed as a set of individual keypoints or as a set of objects (e.g., polygons or polygonal chains) consisting of a fixed number of keypoints of shape
[..., 2]
. When groups of keypoints are passed (i.e., an at least 3-dimensional tensor), this transform will only remove entire groups, not individual keypoints within a group.- Parameters:
labels_getter (callable or str or None, optional) –
indicates how to identify the labels in the input (or anything else that needs to be sanitized along with the keypoints). If set to the string
"default"
, this will try to find a “labels” key in the input (case-insensitive), if the input is a dict or it is a tuple whose second element is a dict.It can also be a callable that takes the same input as the transform, and returns either:
A single tensor (the labels)
A tuple/list of tensors, each of which will be subject to the same sanitization as the keypoints.
If
labels_getter
is None (the default), then only keypoints are sanitized.