﻿# ViTPose keypoints: keep person boxes and crop transforms attached to every pose

Integrate top-down ViTPose with detector boxes in the required format, decode heatmaps into the original image frame, and preserve person identity.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-vitpose-person-box-crop-keypoint-frame/
Language: en

## Begin with the top-down task boundary

ViTPose estimates body keypoints for person regions rather than discovering every person from an unconstrained scene in the same operation. The [paper](https://arxiv.org/abs/2204.12484) describes the vision-transformer pose estimator. In an application, a detector or another source first defines person boxes. This means missed people, duplicate boxes, and truncated limbs can originate upstream of pose estimation. Keep detector evidence separate so a pose failure is not automatically attributed to the keypoint model.

## Convert box formats explicitly

The [Transformers ViTPose processor](https://huggingface.co/docs/transformers/model_doc/vitpose) expects COCO-style person boxes containing a top-left position, width, and height. Its example converts corner-based detection boxes before preprocessing. Passing lower-right coordinates where width and height are expected can still produce numeric arrays with the correct shape while selecting the wrong visual region. Preserve the original detector format and the converted values together when diagnosing an unexpectedly stretched or displaced skeleton.

## Keep the inverse transform with the prediction

Person crops undergo geometric preparation before the network predicts heatmaps. A heatmap position therefore belongs to the prepared crop, not directly to the source image. The documented post_process_pose_estimation path uses the person boxes to transform predictions back into the image frame. Reuse the exact associated boxes in the same order. If batched crops are reordered for execution, carry their person identifiers through that permutation rather than reconnecting results by an assumed arrival order.

## Distinguish keypoint meaning from numerical location

A checkpoint's output schema defines what each keypoint index means. The [official ViTPose repository](https://github.com/ViTAE-Transformer/ViTPose) contains variants and task configurations; do not assume every pose head shares an identical skeleton. Confidence filtering does not change this identity. A precise point assigned to the wrong joint label remains a semantic error, and a low-confidence point should not silently become a confident body location simply because downstream code requires a complete coordinate array.

## Validate identity and geometry together

Use a test image with several people of different sizes, including overlapping boxes, and overlay predictions on the original image. Inspect left-right assignments, crop-edge limbs, and association with the intended person before evaluating speed. Existing guides on [image coordinate transformations](/journal/data-guide-image-exif-box-coordinate/) and [dataset identity relationships](/journal/data-guide-coco-instance-caption-identities/) provide context. ViTPose's distinctive contract is a chain from person detection to crop geometry, heatmap decoding, and joint identity; breaking any link can yield a plausible skeleton on the wrong evidence.
