Member-only story
YoloV8 Pose Estimation and Pose Keypoint Classification using Neural Net PyTorch

Introduction
Pose estimation is a task that involves identifying the location of specific points in an image, usually referred to as keypoints. The keypoints can represent various parts of the object such as joints, landmarks, or other distinctive features. The locations of the keypoints are usually represented as a set of 2D [x, y]
or 3D [x, y, visible]
coordinates.
The output of a pose estimation model is a set of points that represent the keypoints on an object in the image, usually along with the confidence scores for each point. Pose estimation is a good choice when you need to identify specific parts of an object in a scene, and their location in relation to each other.
YOLOV8 Pose
How to use YOLOv8 pretrained Pose models?

from ultralytics import YOLO
# Load a model
model = YOLO('yolov8n-pose.pt')
# Predict with the model
results = model('https://ultralytics.com/images/bus.jpg')
# Extract keypoint
result_keypoint = results.keypoints.xyn.cpu().numpy()[0]
Exploring Ouput Keypoint

In the output of YOLOv8 pose estimation, there are no keypoint names. Here’s sample output

To obtain the x, y coordinates by calling the keypoint name, you can create a Pydantic class with a “keypoint” attribute where the keys represent the keypoint names, and the values indicate the index of the keypoint in the YOLOv8 output.
from pydantic import BaseModel
class GetKeypoint(BaseModel):
NOSE: int = 0
LEFT_EYE: int = 1
RIGHT_EYE: int = 2
LEFT_EAR: int = 3
RIGHT_EAR: int = 4
LEFT_SHOULDER: int = 5
RIGHT_SHOULDER…