Views
No views yet
requirements.txt.pip install -r requirements.txtextract_images.py.pose_detection.py to generate per‑image pose landmark JSON files under PoseData/label_*.ml_pose_classifier.py. Optionally export to ONNX or TFLite.realtime_pose_classifier.py using your saved model.YogaDataSet/data/) and save them into folders by label for training and testing.YogaDataSet/data/train-00000-of-00001.parquet, YogaDataSet/data/test-00000-of-00001.parquetTrainData/train/label_* and/or TrainData/test/label_*1# Process both train and test (default behavior)
2python extract_images.py
3
4# Train only
5python extract_images.py --train --output TrainData
6
7# Test only to a custom folder
8python extract_images.py --test --output MyOutputDirlabel_0, label_1, … subfolders and writes image files with their original extensions.TrainData/train) organized as label_*/*.jpg|png|…PoseData/label_*/<image_name>.json1# Process images from default input into PoseData
2python pose_detection.py
3
4# Custom input and output
5python pose_detection.py --input TrainData/train --output PoseData --batch-size 100requirements.txt).PoseData/label_0/*.jsonPoseData/label_1/*.json--data/-d Pose JSON root (default: PoseData)--model/-m Model type: random_forest (default), svm, gradient_boost, logistic, distilled_rf--test-size/-t Test split ratio (default: 0.2)--save-model/-s Path to save the trained model (.pkl via joblib)--load-model/-l Path to load an existing model--predict/-p Predict a single JSON file--evaluate/-e Evaluate a folder of JSON files--export-onnx Export the trained model to ONNX (tree models or distilled MLP)--export-model-type Controls which model flavor to export--export-tflite Export distilled student MLP to TFLite (requires extra deps)1# 1) Train a Random Forest and save it
2python ml_pose_classifier.py \
3 --data PoseData \
4 --model random_forest \
5 --test-size 0.2 \
6 --save-model models/pose_classifier_random_forest.pkl
7
8# 2) Evaluate a saved model on a held‑out folder (e.g., TestData)
9python ml_pose_classifier.py \
10 --model random_forest \
11 --load-model models/pose_classifier_random_forest.pkl \
12 --evaluate TestData
13
14# 3) Export to ONNX (Random Forest or distilled MLP)
15python ml_pose_classifier.py \
16 --model random_forest \
17 --load-model models/pose_classifier_random_forest.pkl \
18 --export-onnx models/pose_classifier_random_forest.onnx
19
20# 4) Knowledge distillation: train RF teacher + MLP student
21python ml_pose_classifier.py \
22 --data PoseData \
23 --model distilled_rf \
24 --save-model models/pose_classifier_distilled_rf.pkl
25
26# 5) Export the student MLP to TFLite (extra packages required)
27python ml_pose_classifier.py \
28 --model distilled_rf \
29 --load-model models/pose_classifier_distilled_rf.pkl \
30 --export-tflite models/pose_classifier_distilled_mlp.tfliteskl2onnx and onnx. TFLite export additionally needs onnx-tf and tensorflow.svm, logistic) are not supported by Unity Barracuda. Prefer random_forest or the distilled MLP for deployment.--model is not provided, the script auto‑searches common filenames in the project root:
pose_classifier_random_forest.pklpose_classifier_logistic.pklpose_classifier_distilled_rf.pkl1# Auto‑detect a model and open the default camera (0)
2python realtime_pose_classifier.py
3
4# Specify a model file and camera index
5python realtime_pose_classifier.py \
6 --model models/pose_classifier_random_forest.pkl \
7 --camera 0YogaDataSet/data/ — Parquet files used by extract_images.py.TrainData/train|test/label_*/ — Image folders produced by extraction.PoseData/label_*/ — Landmark JSONs generated by pose_detection.py.models/ — Example trained/exported models and label mappings.confusion_matrix_*.png — Saved confusion matrix plots (when enabled in training script).mediapipe and opencv-python.--camera index, close other apps using the camera, or allow camera permissions for Python in macOS Privacy settings.--model with an explicit path to your .pkl file.