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, whereKisdataset.keypoints, so every line has5 + 3 x Kvalues. All the coordinates are normalized to [0, 1], andv > 0marks a labeled keypoint. The services stop with an error if the number of values does not matchdataset.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 |
|---|---|
|
|
|
|
|
Optional. With
|
|
|
Number of keypoints per pose, a strictly positive integer. Required for
|
|
|
Name of the class, for example
|
|
|
Folder of the training set. Required for training. |
|
|
Folder of the validation set. If it is not set,
|
|
|
Fraction of the training set used for validation when
|
|
|
Folder of the test set. The evaluation uses it if it is set, otherwise the validation set. |
|
|
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. |
|
|
Fraction of the calibration set to use, above 0 and up to 1. |
|
|
Folder of the images to predict. Required for prediction. |
|
|
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 therandom_flipdata augmentation, whereflip_indices[i]is the index of the keypoint that becomes keypointi. It must contain every index from 0 tokeypoints - 1once and swap the keypoints by pairs. Use[0, 1, ..., K-1]if the keypoints have no left/right counterparts. It is required to train withrandom_flipfor 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 value1 / keypointsfor all the keypoints otherwise.skeleton_connections: the connections drawn between the keypoints by thepredictionservice and by the deployed application, as a list of[i, j]or[i, j, color]withiandjthe keypoint indices starting at 0. The color is one ofUTIL_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, orUTIL_LCD_COLOR_CYAN. An empty list draws no connection. Without this attribute, the built-in skeleton of theclass_namesandkeypointsis 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.