dgs.utils.validation.validate_key_points

dgs.utils.validation.validate_key_points(key_points: torch.Tensor, length: int | None = None, dims: int | None = 3, nof_joints: int | None = None, joint_dim: int | None = None) torch.Tensor[source]

Given a tensor of key points, validate them and return them as torch tensor of the correct shape.

Parameters:
  • key_points – One torch.tensor or any similarly structured data.

  • length – The number of items or batch-size the tensor should have. Default None does not validate the length.

  • dims – The number of dimensions key_points should have. Use None to not force any number of dimensions. Defaults to three dimensions with the key point dimensions as [B x J x 2|3].

  • nof_joints – The number of joints key_points should have (J). Default None does not validate the number of joints at all.

  • joint_dim – The dimensionality the joint dimension should have (2|3). Default None does not validate the dimensionality additionally to being two or three.

Returns:

The key points as a single torch.tensor with exactly the requested number of dimensions like [... x nof_joints x joint_dim].

Return type:

torch.Tensor

Raises:
  • TypeError – If the key point input is not a Tensor.

  • ValueError – If the key points or joints have the wrong dimensionality.