pose_format.tensorflow package

Tools for TensorFlow compatibility.

pose_format.tensorflow subpackages

pose_format.tensorflow.pose_body module

Classes:

TensorflowPoseBody(fps, data, confidence)

Representation of pose body data, optimized for TensorFlow operations.

class pose_format.tensorflow.pose_body.TensorflowPoseBody(fps, data, confidence)[source]

Bases: PoseBody

Representation of pose body data, optimized for TensorFlow operations.

  • Inherites from PoseBody

Parameters:
  • fps (float) – The frames per second for the pose data.

  • data (Union[MaskedTensor, tf.Tensor]) – The pose data.

  • confidence (tf.Tensor) – The confidence scores for the pose data.

Methods:

as_tfrecord()

Converts into TensorFlow (tf) record format

frame_dropout_given_percent(dropout_percent)

Remove some frames from the data at random from pose data.

frame_dropout_normal([dropout_mean, dropout_std])

Given mean and standard deviation, randomly drops out based on normal distribution.

frame_dropout_uniform([dropout_min, dropout_max])

Drops randomly frames based on a given uniform distribution

from_tfrecord(tfrecord_dict)

From a TensorFlow record dictionary, it creates a instance of TensorflowPoseBody

get_points(indexes)

Gets and returns points from pose data based on indexes

matmul(matrix)

Multiplies pose data with a given matrix.

points_perspective()

Returns perspective transformation of pose points.

select_frames(frame_indexes)

Selects and returns a subset of frames based on the frame indexes.

zero_filled()

Return an instance with zero-filled data.

Attributes:

tensor_reader

as_tfrecord()[source]

Converts into TensorFlow (tf) record format

Returns:

dictionary representation of TensorFlow (tf) record for the pose body

Return type:

dict

frame_dropout_given_percent(dropout_percent)[source]

Remove some frames from the data at random from pose data.

Parameters:

dropout_percent (float) – The percentage of frames to drop.

Returns:

A new instance with dropped frames and the selected frame indexes.

Return type:

TensorflowPoseBody, tf.Tensor

frame_dropout_normal(dropout_mean=0.5, dropout_std=0.1)[source]

Given mean and standard deviation, randomly drops out based on normal distribution.

Parameters:
  • dropout_mean (float, optional) – The mean for the normal distribution, by default 0.5.

  • dropout_std (float, optional) – The standard deviation for the normal distribution, by default 0.1.

Returns:

instance with frames dropped based on normal distribution.

Return type:

TensorflowPoseBody

frame_dropout_uniform(dropout_min=0.2, dropout_max=1.0)[source]

Drops randomly frames based on a given uniform distribution

Parameters:
  • dropout_min (float, optional) – minimum percentage for dropout, by default 0.2.

  • dropout_max (float, optional) – maximum percentage for dropout, by default 1.0.

Returns:

Instance with frames dropped based on a uniform distribution.

Return type:

TensorflowPoseBody

classmethod from_tfrecord(tfrecord_dict)[source]

From a TensorFlow record dictionary, it creates a instance of TensorflowPoseBody

Parameters:

tfrecord_dict (dict) – Dictionary representation of TensorFlow (tf) record data.

Returns:

An instance constructed from given TensorFlow record data

Return type:

TensorflowPoseBody

get_points(indexes)[source]

Gets and returns points from pose data based on indexes

Parameters:

indexes (List[int]) – List of point indexes to get.

Returns:

Instance containing only the gotten points.

Return type:

TensorflowPoseBody

matmul(matrix)[source]

Multiplies pose data with a given matrix.

Parameters:

matrix (np.ndarray) – Matrix to multiply with pose data.

Returns:

Instance with the pose data multiplied by the matrix.

Return type:

TensorflowPoseBody

points_perspective()[source]

Returns perspective transformation of pose points.

Returns:

Transformed pose data.

Return type:

MaskedTensor

select_frames(frame_indexes)[source]

Selects and returns a subset of frames based on the frame indexes.

Parameters:

frame_indexes (List[int]) – List of frame indexes

Returns:

Instance with the selected frames

Return type:

TensorflowPoseBody

tensor_reader = 'unpack_tensorflowstr: The method used to read the tensor data. (Type: str)'
zero_filled()[source]

Return an instance with zero-filled data.

pose_format.tensorflow.pose_body_test module

Classes:

TestTensorflowPoseBody([methodName])

TestsCases for the TensorflowPoseBody class.

class pose_format.tensorflow.pose_body_test.TestTensorflowPoseBody(methodName='runTest')[source]

Bases: TestCase

TestsCases for the TensorflowPoseBody class.

Methods:

test_tf_pose_body_zero_filled_fills_in_zeros()

Test the zero_filled method of TensorflowPoseBody class.

test_tf_pose_body_zero_filled_fills_in_zeros()[source]

Test the zero_filled method of TensorflowPoseBody class.

Test constructs a TensorflowPoseBody instance with specified fps, data (as a MaskedTensor), and confidence. It then calls zero_filled method and checks if data is filled with zeros.

Raises:

AssertionError – If sum of zero-filled body data is not equal to the expected sum.

pose_format.tensorflow.pose_representation module

Classes:

TensorflowPoseRepresentation(header[, ...])

Class for pose representations using TensorFlow tensors.

class pose_format.tensorflow.pose_representation.TensorflowPoseRepresentation(header, rep_modules1=[], rep_modules2=[], rep_modules3=[])[source]

Bases: PoseRepresentation

Class for pose representations using TensorFlow tensors.

  • Inherites from PoseRepresentation

This class extends PoseRepresentation and provides methods for manipulating pose representations using TensorFlow tensors.

Methods:

get_points(tensor, points)

Get specific points from a tensor.

group_embeds(embeds)

Group embeddings (list of tensors) along the first dimension.

permute(src, shape)

Permute dimensions of a tensor according to a given shape (tuple).

Parameters:
  • header (PoseHeader) –

  • rep_modules1 (List) –

  • rep_modules2 (List) –

  • rep_modules3 (List) –

get_points(tensor, points)[source]

Get specific points from a tensor.

Parameters:
  • tensor (tf.Tensor) – Tensor.

  • points (List[int]) – Indices/points needed from Tensor

Returns:

Get values from the tensor using the given indices/points

Return type:

tf.Tensor

group_embeds(embeds)[source]

Group embeddings (list of tensors) along the first dimension.

Parameters:

embeds (List[tf.Tensor]) – List of tensors, each with shape (embed_size, Batch, Len).

Returns:

Tensor with shape (Batch, Len, embed_size).

Return type:

tf.Tensor

permute(src, shape)[source]

Permute dimensions of a tensor according to a given shape (tuple).

Parameters:
  • src (tf.Tensor) – tensor to permute

  • shape (tuple) – Desired shape to permute to.

Returns:

The permuted tensor.

Return type:

tf.Tensor

pose_format.tensorflow.pose_representation_test module

Classes:

TestTensorflowPoseRepresentation([methodName])

Testcases for TensorflowPoseRepresentation class.

class pose_format.tensorflow.pose_representation_test.TestTensorflowPoseRepresentation(methodName='runTest')[source]

Bases: TestCase

Testcases for TensorflowPoseRepresentation class.

Validates the functionalities associated with the Tensorflow representation of pose data, such as ensuring that input sizes, output calculations, and representations are accurate.

Methods:

test_calc_output_size()

Checks that the output size is correct

test_call_return_shape()

Checks that the shape of the returned representation is correct

test_input_size()

Checks that the input size is correct

test_calc_output_size()[source]

Checks that the output size is correct

test_call_return_shape()[source]

Checks that the shape of the returned representation is correct

test_input_size()[source]

Checks that the input size is correct