See this blog post (TBD) for a full guide on doing pose estimation and classification using TensorFlow Lite.
- Pose estimation: Detect keypoints, such as eye, ear, arm etc., from an input
image.
- Input: An image
- Output: A list of keypoint coordinates and confidence score.
- Pose classificaiton: Classify a human pose into predefined classes, such as
different yoga poses. Pose classification internally use pose estimation to
detect the keypoints, and use the keypoints to classify the pose.
- Input: An image
- Output: A list of predefined classes and their confidence score.
This sample can run on Raspberry Pi or any computer that has a camera. It uses OpenCV to capture images from the camera and TensorFlow Lite to run inference on the input image.
- Run this script to install the Python dependencies, and download the TFLite
models.
sh setup.sh
- Use this command to run the pose estimation sample using the default
movenet_lightning
model.
python3 pose_estimation.py
- You can optionally specify the
model_name
parameter to try other pose estimation models:- Use values:
- Single-pose:
posenet
,movenet_lightning
,movenet_thunder
- Multi-poses:
movenet_multipose
- Single-pose:
- The default value is
movenet_lightning
.
- Use values:
python3 pose_estimation.py --model_name movenet_thunder
- Use this command to run the pose estimation sample using the default
movenet_lightning
pose estimation model and theclassifier.tflite
yoga pose classification model.
python3 pose_estimation.py \
--classifier classifier
--label_file labels.txt
- If you want to train a custom pose classification model, check out this tutorial.
- Here is the full list of parameters supported by the sample:
python3 pose_classification.py
model
: Name of the TFLite pose estimation model to be used. * One of these values:posenet
,movenet_lightning
,movenet_thunder
,movenet_multipose
* Default value ismovenet_lightning
.tracker
: Type of tracker to track poses across frames. * One of these values:bounding_box
,keypoint
* Only supported in multi-poses models. * Default value isbounding_box
.classifier
: Name of the TFLite pose classification model to be used. * Default value is empty. * If no classification model specified, the sample will only run the pose estimation step.camera_id
: Specify the camera for OpenCV to capture images from. * Default value is0
.frameWidth
,frameHeight
: Resolution of the image to be captured from the camera. * Default value is(640, 480)
.
- Run this script to visualize the pose estimation on test data
python3 visualizer.py