yoga / core /README.md
randomshit11's picture
Upload 167 files
97e3689 verified

Build Machine Learning Model

Brief overview about the methodology of building models for exercise pose detection. To go in depth on each exercise, click the link below:

1. Simple error detection

For some simple errors (for example, the feet placement error in squat), the detection method is either measuring the distance/angle between different joints during the exercise with the coordinate outputs from MediaPipe Pose.

  • Distance Calculation Assume there are 2 points with the following coordinates: Point 1 (x1,y1) and Point 2 (x2,y2), below is the formula to calculate the distance between 2 points.

    distance= √((x1-x2)^2 +(y1-y2) ^2 )
    
  • Angle Calculation Assume there are 3 points with the following coordinates: Point 1 (x1,y1), Point 2 (x2,y2) and Point 3 (x3,y3), below is the formula to calculate the angle created by 3 points.

    angle_in_radian =arctan2⁡(y3-y2,x3-x2) -arctan2(y1-y2,x1-x2)
    angle_in_degree=(angle_in_rad \* 180)/Π
    

2. Model Training for Error Detection

1. Pick important landmarks

For each exercise, there will be different poses/body’s position, therefore it is essential to identify which parts (shoulder, hip, …) of a body are contribute to the exercise. The important landmarks identified for each exercise are utilized to extract body part’s position while exercising using MediaPipe.

2. Data Processing

Logo

3. Model training

There are 2 methods used in this thesis for model training. For each exercise, the models trained for each method will be compared and the best model will be chosen.

  • Classification with Scikit-learn. (Decision Tree/Random Forest (RF), K-Nearest Neighbors (KNN), C-Support Vector (SVC), Logistic Regression classifier (LR) and Stochastic Gradient Descent classifier (SGDC)).
  • Building a Neural Network for classification with Keras.

3. Evaluation results of all models

  1. Bicep Curl - lean back error

    Logo

  2. Plank - all errors

    Logo

  3. Basic Squat - stage

    Logo

  4. Lunge - knee over toe error

    Logo