Pose Estimation datasets

This guide describes how the pose estimation services read a dataset: the file format, the dataset section attributes, and how the training, validation, test, quantization, and prediction sets are built. To create a dataset from COCO, see the dataset converter guide.

1. Dataset format

Every set (training, validation, test, quantization, and prediction) is one flat folder in which each image comes with a label file of the same name, in the YOLO Darknet pose format:

my_dataset/
   train/
      train_image_1.jpg
      train_image_1.txt
      train_image_2.jpg
      train_image_2.txt
   val/
      val_image_1.jpg
      val_image_1.txt
   test/
      test_image_1.jpg
      test_image_1.txt
  • Images: .jpg, .jpeg, .png, .bmp, or .gif, directly in the folder (no sub-folders).

  • Labels: one line per pose, class_id x_center y_center width height x_1 y_1 v_1 ... x_K y_K v_K, where K is dataset.keypoints, so every line has 5 + 3 x K values. All the coordinates are normalized to [0, 1], and v > 0 marks a labeled keypoint. The services stop with an error if the number of values does not match dataset.keypoints.

  • Images without a pose: an image without a label file, or with an empty one, is considered as an image without pose.

  • Prediction and quantization sets: the label files are not needed.

2. The dataset section

dataset:
  dataset_name: custom_coco                    # coco, custom_coco, or custom_dataset
  dataset_subsetname: person_17kpts            # Optional. With dataset_name, selects the pretrained weights.
  keypoints: 17                                # Number of keypoints per pose
  class_names: [person]                        # Name of the class
  training_path: <training-set-folder>
  validation_path: <validation-set-folder>     # Optional
  validation_split: 0.2                        # Used when validation_path is not set
  test_path: <test-set-folder>
  quantization_path: <quantization-set-folder>
  quantization_split: 0.3                      # Optional
  prediction_path: <prediction-set-folder>

Attribute

Description

dataset_name

coco, custom_coco, or custom_dataset: these are the only registered dataset names. They all read the format described above and differ only in the pretrained weights they select. It is needed whenever the dataset folders are read.

dataset_subsetname

Optional. With dataset_name, selects the pretrained weights of a model selected by name, for example custom_coco and person_17kpts. See the Models guide.

keypoints

Number of keypoints per pose, a strictly positive integer. Required for training, evaluation, prediction, and the chains that include them.

class_names

Name of the class, for example [person], [hand], or [head]. With keypoints, the first name selects the skeleton drawn by the prediction and deployment services.

training_path

Folder of the training set. Required for training.

validation_path

Folder of the validation set. If it is not set, validation_split of the training set is used.

validation_split

Fraction of the training set used for validation when validation_path is not set. Must be between 0 and 1 (excluded). Default: 0.2. The training set is shuffled with general.global_seed before the split.

test_path

Folder of the test set. The evaluation uses it if it is set, otherwise the validation set.

quantization_path

Folder of the calibration images. If it is not set, the training set is used. If there is no calibration data, the model is quantized with random data.

quantization_split

Fraction of the calibration set to use, above 0 and up to 1.

prediction_path

Folder of the images to predict. Required for prediction.

keypoints_file_path

Text file with the keypoint names loaded by the application. Required to deploy on STM32MPU, see the Deployment guide.

3. Using a number of keypoints different from 17 or 13

The number of keypoints only defines the size of the tensors. What the keypoints mean is defined by a keypoint schema, whose known presets are the COCO person with 17 or 13 keypoints, the hand with 21 keypoints, and the head with 468 or 478 keypoints. For your own keypoints, you can set the following optional attributes in the dataset section:

dataset:
  dataset_name: custom_dataset
  keypoints: 5
  class_names: [animal]
  keypoint_names: [nose, left_ear, right_ear, left_paw, right_paw]
  flip_indices: [0, 2, 1, 4, 3]
  oks_sigmas: [0.05, 0.05, 0.05, 0.08, 0.08]
  skeleton_connections:
    - [0, 1]
    - [0, 2]
    - [0, 3, UTIL_LCD_COLOR_ORANGE]
    - [0, 4, UTIL_LCD_COLOR_ORANGE]

The values of this example are only an illustration of the syntax.

  • flip_indices: the permutation of the keypoints applied by the random_flip data augmentation, where flip_indices[i] is the index of the keypoint that becomes keypoint i. It must contain every index from 0 to keypoints - 1 once and swap the keypoints by pairs. Use [0, 1, ..., K-1] if the keypoints have no left/right counterparts. It is required to train with random_flip for a number of keypoints other than 17 or 13.

  • oks_sigmas: the per-keypoint standard deviations used by the OKS metric, one strictly positive value per keypoint. Without it, the COCO values are used for 17 and 13 keypoints, and the same value 1 / keypoints for all the keypoints otherwise.

  • skeleton_connections: the connections drawn between the keypoints by the prediction service and by the deployed application, as a list of [i, j] or [i, j, color] with i and j the keypoint indices starting at 0. The color is one of UTIL_LCD_COLOR_ST_BLUE (default), UTIL_LCD_COLOR_BLUE, UTIL_LCD_COLOR_ORANGE, UTIL_LCD_COLOR_GREEN, UTIL_LCD_COLOR_MAGENTA, UTIL_LCD_COLOR_RED, UTIL_LCD_COLOR_YELLOW, or UTIL_LCD_COLOR_CYAN. An empty list draws no connection. Without this attribute, the built-in skeleton of the class_names and keypoints is used if there is one.

  • keypoint_names: an optional list of one unique name per keypoint, printed in the training log.

When the number of keypoints differs from the one of the pretrained weights, the weights are loaded except those of the output layers (see the Training guide). The converter only supports 17 and 13 keypoints: for another number, convert your annotations to the format of section 1 yourself.