How adityasarsenal/yoga_trainer works
Main Components
• Inference/Live Yoga Trainer:
• Main Execution: The src/main.py file is the entry point for the yoga trainer. Other “main” scripts (e.g., downdog_main.py, goddess_main.py, warrior2_main.py) handle specialized yoga poses.
• Pose Detection: These components include both the MediaPipe-based detection as well as the fine-tuned MobileNetV2 model (loaded via live_cam_test.py).
• Voice Instruction Module: The auio_conv.py script integrates a text-to-speech model (pyttsx3), connecting detected pose outcomes with vocal instructions.
• Pose Checking Utilities: Files such as downdog_checks.py, goddness_checks.py, tree_checks.py, and worrior2_checks.py are used to verify the correctness of the pose.
• Training Pipeline:
• Data Processing: The train_n_test folder contains scripts for data sampling (_data_sampling.py), pre-processing (_pre_processing_data.py), and synthetic data generation (_synthatic_data_prodection.py), which prepare the dataset for fine-tuning.
• Fine-Tuning Steps: There are components dedicated to model training (_fine_tuneing.py), evaluation (_pre_train_eval.py), and post-training testing (_fine_tuned_model_testing.py and _sample_test_after_finetuned.py).
• Model Saving: The fine-tuned MobileNetV2 results in a saved .h5 model that is later loaded for inference.
Relationships and Interactions
• The Inference Module:
• The live_cam_test.py script loads the fine-tuned model (.h5) and uses the webcam feed to detect current yoga poses.
• Once a pose is detected, control flows to the corresponding “main” script (e.g., goddess_main.py for the goddess pose) which then calls on its paired “checks” script and ultimately invokes the auio_conv.py module to provide voice feedback.
• Directional flow: webcam feed → pose detection (MobileNetV2 & MediaPipe) → specific pose module → voice instruction.
• The Training Module:
• The pipeline begins with data ingestion and sampling. If the dataset is insufficient, synthetic augmentation is performed.
• The data then moves through pre-processing, after which fine-tuning is applied to MobileNetV2 for gesture recognition.
• The trained model is persisted as a .h5 file and later used by the inference module.
Architectural Patterns and Design Principles
• Modularity: The project is segregated into distinct modules or layers—separate scripts handling different poses and a dedicated training pipeline. This modularity makes it easier to scale or replace components.
• Reusability: The use of common utility scripts (e.g., for data sampling and voice instructions) helps in reusing code across both inference and training components.
• Clear Separation of Concerns: The inference layer (real-time pose detection and instruction) is clearly separated from the training pipeline (data preparation and model fine tuning).
Relevant Technologies and Frameworks
• Deep Learning: The fine-tuned MobileNetV2 model backbone.
• Computer Vision: MediaPipe for pose estimation.
• Text-to-Speech: The use of pyttsx3 in auio_conv.py.
• Data Processing: Python scripts for data sampling, pre-processing, and synthetic data generation.
• Environment & Dependencies: The README specifies dependency on Python 3.10.11 and specific library versions.