torchvision.utils.draw_keypoints(image: torch.Tensor, keypoints: torch.Tensor, connectivity: Optional[List[Tuple[int, int]]] = None, colors: Optional[Union[str, Tuple[int, int, int]]] = None, radius: int = 2, width: int = 3)torch.Tensor[source]

Draws Keypoints on given RGB image. The values of the input image should be uint8 between 0 and 255.

  • image (Tensor) – Tensor of shape (3, H, W) and dtype uint8.

  • keypoints (Tensor) – Tensor of shape (num_instances, K, 2) the K keypoints location for each of the N instances, in the format [x, y].

  • connectivity (List[Tuple[int, int]]]) – A List of tuple where, each tuple contains pair of keypoints to be connected.

  • colors (str, Tuple) – The color can be represented as PIL strings e.g. “red” or “#FF00FF”, or as RGB tuples e.g. (240, 10, 157).

  • radius (int) – Integer denoting radius of keypoint.

  • width (int) – Integer denoting width of line connecting keypoints.


Image Tensor of dtype uint8 with keypoints drawn.

Return type

img (Tensor[C, H, W])

Examples using draw_keypoints:

Visualization utilities

Visualization utilities

Visualization utilities


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources