Are you sure you want to delete this access key?
comments | description | keywords |
---|---|---|
true | Learn about Ultralytics YOLO format for pose estimation datasets, supported formats, COCO-Pose, COCO8-Pose, Tiger-Pose, and how to add your own dataset. | pose estimation, Ultralytics, YOLO format, COCO-Pose, COCO8-Pose, Tiger-Pose, dataset conversion, keypoints |
The dataset label format used for training YOLO pose models is as follows:
Here is an example of the label format for pose estimation task:
Format with Dim = 2
<class-index> <x> <y> <width> <height> <px1> <py1> <px2> <py2> ... <pxn> <pyn>
Format with Dim = 3
<class-index> <x> <y> <width> <height> <px1> <py1> <p1-visibility> <px2> <py2> <p2-visibility> <pxn> <pyn> <p2-visibility>
In this format, <class-index>
is the index of the class for the object,<x> <y> <width> <height>
are coordinates of bounding box, and <px1> <py1> <px2> <py2> ... <pxn> <pyn>
are the pixel coordinates of the keypoints. The coordinates are separated by spaces.
The Ultralytics framework uses a YAML file format to define the dataset and model configuration for training Detection Models. Here is an example of the YAML format used for defining a detection dataset:
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco8-pose # dataset root dir
train: images/train # train images (relative to 'path') 4 images
val: images/val # val images (relative to 'path') 4 images
test: # test images (optional)
# Keypoints
kpt_shape: [17, 3] # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
flip_idx: [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]
# Classes dictionary
names:
0: person
The train
and val
fields specify the paths to the directories containing the training and validation images, respectively.
names
is a dictionary of class names. The order of the names should match the order of the object class indices in the YOLO dataset files.
(Optional) if the points are symmetric then need flip_idx, like left-right side of human or face. For example if we assume five keypoints of facial landmark: [left eye, right eye, nose, left mouth, right mouth], and the original index is [0, 1, 2, 3, 4], then flip_idx is [1, 0, 2, 4, 3] (just exchange the left-right index, i.e. 0-1 and 3-4, and do not modify others like nose in this example).
!!! example
=== "Python"
```python
from ultralytics import YOLO
# Load a model
model = YOLO("yolov8n-pose.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data="coco8-pose.yaml", epochs=100, imgsz=640)
```
=== "CLI"
```bash
# Start training from a pretrained *.pt model
yolo pose train data=coco8-pose.yaml model=yolov8n-pose.pt epochs=100 imgsz=640
```
This section outlines the datasets that are compatible with Ultralytics YOLO format and can be used for training pose estimation models:
If you have your own dataset and would like to use it for training pose estimation models with Ultralytics YOLO format, ensure that it follows the format specified above under "Ultralytics YOLO format". Convert your annotations to the required format and specify the paths, number of classes, and class names in the YAML configuration file.
Ultralytics provides a convenient conversion tool to convert labels from the popular COCO dataset format to YOLO format:
!!! example
=== "Python"
```python
from ultralytics.data.converter import convert_coco
convert_coco(labels_dir="path/to/coco/annotations/", use_keypoints=True)
```
This conversion tool can be used to convert the COCO dataset or any dataset in the COCO format to the Ultralytics YOLO format. The use_keypoints
parameter specifies whether to include keypoints (for pose estimation) in the converted labels.
The Ultralytics YOLO format for pose estimation datasets involves labeling each image with a corresponding text file. Each row of the text file stores information about an object instance:
For 2D poses, keypoints include pixel coordinates. For 3D, each keypoint also has a visibility flag. For more details, see Ultralytics YOLO format.
To use the COCO-Pose dataset with Ultralytics YOLO:
Download the dataset and prepare your label files in the YOLO format.
Create a YAML configuration file specifying paths to training and validation images, keypoint shape, and class names.
Use the configuration file for training:
from ultralytics import YOLO
model = YOLO("yolov8n-pose.pt") # load pretrained model
results = model.train(data="coco-pose.yaml", epochs=100, imgsz=640)
To add your dataset:
Convert your annotations to the Ultralytics YOLO format.
Create a YAML configuration file specifying the dataset paths, number of classes, and class names.
Use the configuration file to train your model:
from ultralytics import YOLO
model = YOLO("yolov8n-pose.pt")
results = model.train(data="your-dataset.yaml", epochs=100, imgsz=640)
For complete steps, check the Adding your own dataset section.
The dataset YAML file in Ultralytics YOLO defines the dataset and model configuration for training. It specifies paths to training, validation, and test images, keypoint shapes, class names, and other configuration options. This structured format helps streamline dataset management and model training. Here is an example YAML format:
path: ../datasets/coco8-pose
train: images/train
val: images/val
names:
0: person
Read more about creating YAML configuration files in Dataset YAML format.
Ultralytics provides a conversion tool to convert COCO dataset labels to the YOLO format, including keypoint information:
from ultralytics.data.converter import convert_coco
convert_coco(labels_dir="path/to/coco/annotations/", use_keypoints=True)
This tool helps seamlessly integrate COCO datasets into YOLO projects. For details, refer to the Conversion Tool section.
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?