An intelligent fitness analysis application that uses computer vision (MediaPipe & OpenCV) to track exercise reps, analyze form, and provide real-time feedback.
- Real-time Pose Estimation: Tracks 33 3D body landmarks.
- Exercise Support:
- Dumbbell Curls:
- Independent Left/Right arm tracking.
- Counts full repetitions (< 80° flexion to > 140° extension).
- Auto-detects active arm.
- Squats:
- Depth analysis.
- Counts repetitions based on knee angles (< 100° down, > 160° up).
- Dumbbell Curls:
- Repetition Counting: Robust logic to prevent false positives and support partial reps.
- Feedback System:
- Displays repetition count.
- Visual overlays for joint angles and skeleton.
- Directional feedback (e.g., "Up (Right)", "Good Depth!").
- GPU Acceleration: Experimental support for hardware acceleration via MediaPipe Tasks API.
- Python 3.10 or higher.
- uv (Recommended package manager) or pip.
-
Clone the repository:
git clone <repository-url> cd ai-personal-trainer
-
Install dependencies:
uv pip install -r requirements.txt
Or with standard pip:
pip install -r requirements.txt
Run the application using the command line.
uv run python main.pyDefaults to Dumbbell Curl exercise.
Analyze Squats:
uv run python main.py --exercise squatAnalyze a pre-recorded video instead of webcam:
uv run python main.py --video path/to/video.mp4Use the modern MediaPipe Task API with GPU support:
uv run python main.py --gpumain.py: Application entry point. Handles video capture, UI drawing, and loop.pose_estimator.py:PoseDetector: Legacy CPU-based detector wrapper.GPUPoseDetector: GPU-accelerated detector using Tasks API.
exercises.py: Contains logic for specific exercises (DumbbellCurl,Squat).tests/: Unit tests for exercise logic.
- Python: Core language.
- MediaPipe: For pose detection and landmark extraction.
- OpenCV: For image processing and display.
- NumPy: For angle calculations.
- Fork the project.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.