A real-time exercise detection and form analysis system using pose estimation and deep learning. This project can identify different exercise types, analyze form correctness, and count repetitions with high accuracy, optimized for edge devices.
- Real-time Exercise Recognition: Identifies 7 distinct exercises with high accuracy
- Form Analysis: Evaluates exercise form correctness using biomechanical rules
- Repetition Counting: Automatically counts repetitions for each exercise
- Edge-Optimized: Lightweight model suitable for mobile and low-end devices
- Multi-Exercise Support: Detects deadlifts, hammer curls, lateral raises, planks, push-ups, Russian twists, and squats
- Source: Labeled exercise videos from Kaggle
- Exercises Covered:
- Deadlift
- Hammer Curl
- Lateral Raise
- Plank
- Push-up
- Russian Twist
- Squat
- Preprocessing:
- Keypoint extraction using MediaPipe
- Angle and distance calculations
- Outlier removal and data scaling
- Data augmentation for improved generalization
- Developed
mediapipe.pyscript to extract pose keypoints from raw videos - Generated custom dataset with video IDs and exercise labels
- Extracted 33 body landmarks per frame using MediaPipe
- Calculated joint angles and distances between keypoints
- Detected and removed outliers using statistical methods
- Applied feature scaling for normalization
- Performed data augmentation (light and hard) to improve model robustness
Trained multiple GRU (Gated Recurrent Unit) models with different architectures:
| Model | Architecture | Validation Accuracy | Test Accuracy | Notes |
|---|---|---|---|---|
gru_model.h5 |
Basic GRU | 88.40% | 46.46% | Baseline model |
gru_model_2.h5 |
Bidirectional GRU + BatchNorm | 90.91% | 48.48% | Best initial performer |
GRU_moodel.5 |
Simple GRU (64,32) | 79.07% | 48.11% | Dropout 0.3 |
GRU_MODEL_1.h5 |
Conv1D + GRU | 80.32% | - | Added 3 non-exercise classes |
GRU_MODEL_3.h5 |
Deep GRU (64,32) | 81.00% | - | Two GRU layers |
GRU_MODEL_4.h5 |
Bidirectional GRU + BatchNorm | 81.67% | - | Improved normalization |
GRU_MODEL_5.h5 |
Resampled + Light Aug | 83.03% | - | Selected for deployment |
GRU_MODEL_6.h5 |
Hard Augmentation | 83.94% | - | Slightly better validation |
- Developed
checkrules.pyscript to:- Verify exercise form correctness using biomechanical rules
- Count repetitions based on movement patterns
- Provide real-time feedback on exercise quality
- Real-time Accuracy: 99% on unseen real-world data
- Inference Speed: Optimized for real-time use (>30 FPS on edge devices)
- Model Size: Lightweight (<5MB) suitable for mobile deployment
- Latency: <50ms per frame on standard mobile devices
# Clone the repository
git clone https://github.com/yourusername/exercise-detector.git
cd exercise-detector
# Install dependencies
pip install -r requirements.txtfrom exercise_detector import ExerciseDetector
# Initialize detector
detector = ExerciseDetector(model_path='models/GRU_MODEL_5.h5')
# Process video stream
results = detector.detect_exercises(video_source=0) # 0 for webcamfrom checkrules import FormAnalyzer
analyzer = FormAnalyzer()
exercise = "squat"
form_feedback, rep_count = analyzer.analyze_form(keypoints, exercise)
print(f"Reps: {rep_count}, Form: {form_feedback}")- Python 3.8+
- OpenCV
- MediaPipe
- TensorFlow/Keras
- NumPy
- Scikit-learn
- Add support for more exercises
- Develop mobile application (Android/iOS)
- Implement voice feedback for form correction
- Create user profile system for progress tracking
- Add multi-person detection support
- Kaggle for the exercise video dataset
- MediaPipe team for the pose estimation framework
- TensorFlow team for the deep learning tools