Sub topic 3
Datasets, Annotations and Visibility Flags
This chapter assumes basic Python and NumPy, familiarity with convolutional neural networks, object detection, bounding boxes, training loss, and evaluation metrics.
What a pose annotation contains
A pose dataset labels each person instance in an image. An instance is one person together with that person's bounding box and body keypoints. The labels allow a model to learn where body parts appear and how they relate to one another.
The COCO keypoint layout uses 17 named points in a fixed order:
- Nose
- Left eye and right eye
- Left ear and right ear
- Left shoulder and right shoulder
- Left elbow and right elbow
- Left wrist and right wrist
- Left hip and right hip
- Left knee and right knee
- Left ankle and right ankle
The names are not enough by themselves. The order must remain consistent between the dataset, the model output, and evaluation code. If index 7 means left elbow during training but right elbow during inference, every prediction will be mislabeled.
A skeleton adds connections between keypoints. For example, it can connect the shoulder to the elbow and the elbow to the wrist. These connections describe the body structure, but the model usually predicts the keypoints first.
COCO-style annotation fields
A COCO annotation commonly stores one dictionary for each person. Important fields include:
| Field | Meaning | Typical form |
|---|---|---|
| `image_id` | Image containing the person | Integer |
| `category_id` | Object category, usually person | Integer |
| `bbox` | Person box as x, y, width, height | Four numbers |
| `area` | Annotated person area | Number |
| `keypoints` | 17 triples of x, y, visibility | 51 numbers |
| `num_keypoints` | Number of labeled keypoints | Integer |
| `iscrowd` | Whether the annotation represents a crowd region | 0 or 1 |
The keypoints field is flattened. A sequence such as x1, y1, v1, x2, y2, v2 represents two keypoints. The coordinates are image pixel coordinates, usually measured from the top-left corner.
The visibility value has three meanings:
| Value | Meaning | How to use it |
|---|---|---|
| 0 | Not labeled | Do not use this point as a target |
| 1 | Labeled but not visible | Use its annotated location, but recognize that the point is occluded |
| 2 | Labeled and visible | Use its location as a visible target |
A point with visibility 1 might be behind another person or hidden by clothing. It still has a useful estimated location, even though image pixels do not clearly show it. A point with visibility 0 has no reliable labeled location. Its stored coordinates should not be treated as a real target.
Why annotations affect training and evaluation
For a heatmap model, each labeled keypoint becomes a target centered at its annotated coordinate. Keypoints with visibility 0 are masked from the loss. Points with visibility 1 can remain training targets, depending on the dataset and implementation.
The bounding box and area also matter. They identify the person instance and help evaluation normalize errors across people of different sizes. The iscrowd field prevents ambiguous crowd regions from being treated like ordinary individual instances.
When building a dataset, validate that every keypoint uses the same order, coordinates stay within the image convention, and left and right labels are correct after horizontal flipping. A flip must exchange left-eye with right-eye, left-shoulder with right-shoulder, and every other paired landmark.
Exercise
A keypoint has coordinates (120, 80) and visibility value 1. Should a training pipeline discard it because the point is hidden?
Show answer
Not necessarily. Visibility 1 means the point is labeled but not visible, so the pipeline may use its annotated location as a target while treating it differently from a visible point. Visibility 0 is the value that indicates no labeled target.