sanitize_keypoints¶
- torchvision.transforms.v2.functional.sanitize_keypoints(key_points: Tensor, canvas_size: Optional[tuple[int, int]] = None) tuple[torch.Tensor, torch.Tensor] [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:
- Returns:
The subset of valid keypoints, and the corresponding indexing mask. The mask can then be used to subset other tensors (e.g. labels) that are associated with the keypoints.
- Return type:
out (tuple of Tensors)