Pose estimation

Pose estimation is the task of using an ML model to estimate the pose of a person from an image or a video by estimating the spatial locations of key body joints (keypoints).

Get started

If you are new to TensorFlow Lite and are working with Android or iOS, explore the following example applications that can help you get started.

Android example iOS example

If you are familiar with the TensorFlow Lite APIs, download the starter PoseNet model and supporting files.

Download starter model

If you want to try pose estimation on a web browser, check out the TensorFlow JS GitHub repository.

Model description

How it works

Pose estimation refers to computer vision techniques that detect human figures in images and videos, so that one could determine, for example, where someone’s elbow shows up in an image. It is important to be aware of the fact that pose estimation merely estimates where key body joints are and does not recognize who is in an image or video.

The PoseNet model takes a processed camera image as the input and outputs information about keypoints. The keypoints detected are indexed by a part ID, with a confidence score between 0.0 and 1.0. The confidence score indicates the probability that a keypoint exists in that position.

The various body joints detected by the PoseNet model are tabulated below:

Id Part
0 nose
1 leftEye
2 rightEye
3 leftEar
4 rightEar
5 leftShoulder
6 rightShoulder
7 leftElbow
8 rightElbow
9 leftWrist
10 rightWrist
11 leftHip
12 rightHip
13 leftKnee
14 rightKnee
15 leftAnkle
16 rightAnkle

An example output is shown below:

Animation showing pose estimation

Performance benchmarks

Performance varies based on your device and output stride (heatmaps and offset vectors). The PoseNet model is image size invariant, which means it can predict pose positions in the same scale as the original image regardless of whether the image is downscaled. This means that you configure the model to have a higher accuracy at the expense of performance.

The output stride determines how much the output is scaled down relative to the input image size. It affects the size of the layers and the model outputs.

The higher the output stride, the smaller the resolution of layers in the network and the outputs, and correspondingly their accuracy. In this implementation, the output stride can have values of 8, 16, or 32. In other words, an output stride of 32 will result in the fastest performance but lowest accuracy, while 8 will result in the highest accuracy but slowest performance. The recommended starting value is 16.

The following image shows how the output stride determines how much the output is scaled down relative to the input image size. A higher output stride is faster but results in lower accuracy.

Output stride and heatmap resolution

Performance benchmark numbers are generated with the tool described here.

Model Name Model size Device GPU CPU
Posenet 12.7 Mb Pixel 3 (Android 10) 12ms 31ms*
Pixel 4 (Android 10) 12ms 19ms*
iPhone XS (iOS 12.4.1) 4.8ms 22ms**

* 4 threads used.

** 2 threads used on iPhone for the best performance result.

Further reading and resources

  • Check out this blog post to learn more about pose estimation using TensorFlow Lite.
  • Check out this blog post to learn more about pose estimation using TensorFlow JS.
  • Read the PoseNet paper here

Also, check out these use cases of pose estimation.