An AI-powered web application that tracks your exercises using computer vision and provides real-time form feedback with scoring.
- π· Real-time Pose Estimation using MediaPipe
- π― 18 Built-in Exercises - Full body workout coverage
- π Form Score System (0-100) with A-F grading
- π Automatic Rep Counting with state machine logic
- π¬ Real-time Form Feedback - Instant correction tips
- π¬ Upload & Analyze Videos - Process pre-recorded workout videos
- 𦴠Skeleton Overlay - See your pose detection on processed video
- π Live Statistics Panel - Real-time rep count, form score, and state
- π₯οΈ Processing Terminal - Watch analysis progress with detailed logs
- πΎ H.264 Video Output - Browser-compatible processed videos with imageio-ffmpeg
- π Personal Information - Track your fitness journey
- π― Customizable Goals - Set weekly workout and rep targets
- π Achievement System - Unlock badges for milestones
- π Activity Charts - Visualize your workout history
- β€οΈ Favorite Exercises - Track your most-used exercises
- βοΈ Settings - Dark mode, notifications, units preference
- π Workout Statistics - Total workouts, reps, streaks
- π Weekly Activity Charts - Visualize your progress
- π₯§ Exercise Distribution - See which exercises you do most
- π Recent Workouts - Quick view of latest sessions
- π YAML-based Exercise Definitions - Add new exercises without writing code!
- π Three Exercise Types - Standard, Bilateral (left/right), Duration-based
- π¨ Customizable Visualization - Colors, highlighted joints per exercise
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (Web UI) β
β index.html β video stream (MJPEG) β form feedback β
ββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β HTTP/WebSocket
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β BACKEND (Flask) β
β app.py β
β β’ Video capture & streaming β
β β’ REST API endpoints β
β β’ Session management β
ββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β EXERCISE ENGINE β
β ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ β
β β BaseExercise β β Loader β β Engine β β
β β (FSM Core) β β (YAMLβObj) β β (Wrapper) β β
β β β β β β β β
β β β’ State Machineβ β β’ Parse YAML β β β’ process_frameβ β
β β β’ Rep Counter β β β’ Validate β β β’ draw_overlay β β
β β β’ Form Score β β β’ Create Obj β β β’ draw_score β β
β β β’ Feedback β β β β β β
β ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ β
β β² β
β β inheritance β
β ββββββββ΄ββββββββ ββββββββββββββββββ β
β β Bilateral β β Duration β β
β β Exercise β β Exercise β β
β β (L/R sides) β β (time-based) β β
β ββββββββββββββββ ββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β loads
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β YAML DEFINITIONS (18 exercises) β
β squat.yaml β push_up.yaml β plank.yaml β deadlift.yaml β ... β
β β
β Each YAML contains: β
β β’ Angle definitions (landmarks, ranges) β
β β’ State machine (states, transitions, conditions) β
β β’ Counter rules (when to count a rep) β
β β’ Form feedback rules (warnings, priorities) β
β β’ Tempo guidance (up/down/hold timing) β
β β’ Visualization config (colors, highlighted joints) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The app calculates a Form Score (0-100) for each exercise session:
| Component | Weight | Description |
|---|---|---|
| Angle Accuracy | 40% | How close your angles are to ideal |
| Tempo Compliance | 30% | Following the recommended speed |
| Form Feedback | 30% | Penalty for triggered warnings |
| Score | Grade | Color |
|---|---|---|
| 90-100 | A | π’ Green |
| 80-89 | B | π΅ Blue |
| 70-79 | C | π‘ Yellow |
| 60-69 | D | π Orange |
| 0-59 | F | π΄ Red |
- πͺ Hammer Curl - Bicep curl with neutral grip
- πͺ Bicep Curl - Classic bicep exercise (bilateral)
- πͺ Tricep Dip - Chair/bench dips for triceps
- πͺ Shoulder Press - Overhead pressing
- πͺ Lateral Raise - Side delt raises
- πͺ Push Up - Classic chest exercise
- 𦡠Squat - Bodyweight squat
- 𦡠Lunge - Forward lunge (bilateral)
- 𦡠Side Lunge - Lateral lunge
- 𦡠Deadlift - Romanian deadlift for hamstrings
- 𦡠Glute Bridge - Hip bridge for glutes
- 𦡠Calf Raise - Standing calf raises
- 𦡠Wall Sit - Isometric hold (duration)
- π₯ Mountain Climber - Dynamic core/cardio
- π₯ High Knees - Running in place
- π₯ Jumping Jack - Classic cardio move
- π₯ Leg Raise - Lying leg raises for abs
- π§ Plank - Core hold (duration)
git clone https://github.com/yourusername/fitness-trainer-pose-estimation.git
cd fitness-trainer-pose-estimation
# Create virtual environment (optional)
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtpython app.pyNavigate to: http://127.0.0.1:5000
No coding required! Just create a YAML file:
# exercises/definitions/my_new_exercise.yaml
name: "My New Exercise"
type: "standard" # or "bilateral" / "duration"
description: "Description of the exercise"
# Define body angles to track
angles:
primary_angle:
landmarks: [11, 13, 15] # MediaPipe landmark IDs
range: [30, 170] # Valid angle range
# State machine definition
states:
- name: "START"
condition:
angle: "primary_angle"
operator: ">"
value: 150
next_state: "MIDDLE"
feedback: "Starting position"
- name: "MIDDLE"
condition:
angle: "primary_angle"
operator: "<"
value: 60
next_state: "END"
feedback: "Good form!"
- name: "END"
condition:
angle: "primary_angle"
operator: ">"
value: 150
next_state: "START"
feedback: "Rep complete!"
# When to count a rep
counter:
increment_on: "END"
# Form warnings
feedback:
- name: "form_warning"
description: "Bad form detected"
angle: "primary_angle"
condition:
operator: "<"
value: 30
message: "Don't go too low!"
priority: 1
# Tempo in seconds
tempo:
up_seconds: 1.0
down_seconds: 2.0
hold_seconds: 0.5
# Display settings
visualization:
primary_angle: "primary_angle"
show_angles: ["primary_angle"]
highlight_landmarks: [11, 13, 15]
color_scheme: "green"python test_engine.pyRestart the app - your exercise is now available!
0 = NOSE
11 = LEFT_SHOULDER 12 = RIGHT_SHOULDER
13 = LEFT_ELBOW 14 = RIGHT_ELBOW
15 = LEFT_WRIST 16 = RIGHT_WRIST
23 = LEFT_HIP 24 = RIGHT_HIP
25 = LEFT_KNEE 26 = RIGHT_KNEE
27 = LEFT_ANKLE 28 = RIGHT_ANKLE
31 = LEFT_FOOT_INDEX 32 = RIGHT_FOOT_INDEX
fitness-trainer-pose-estimation/
βββ π app.py # Flask application + video streaming
βββ π video_processor.py # Standalone video analysis with skeleton overlay
βββ π main.py # CLI runner (standalone)
βββ π requirements.txt
β
βββ π exercises/
β βββ π base_exercise.py # FSM engine (BaseExercise, Bilateral, Duration)
β βββ π loader.py # YAML loader & validator
β βββ π engine.py # High-level API wrapper
β βββ π definitions/ # π― YAML exercise files (18 exercises)
β βββ squat.yaml
β βββ push_up.yaml
β βββ hammer_curl.yaml
β βββ bicep_curl.yaml
β βββ tricep_dip.yaml
β βββ shoulder_press.yaml
β βββ lateral_raise.yaml
β βββ lunge.yaml
β βββ side_lunge.yaml
β βββ deadlift.yaml
β βββ glute_bridge.yaml
β βββ calf_raise.yaml
β βββ wall_sit.yaml
β βββ plank.yaml
β βββ mountain_climber.yaml
β βββ high_knees.yaml
β βββ jumping_jack.yaml
β βββ leg_raise.yaml
β
βββ π pose_estimation/
β βββ π estimation.py # MediaPipe wrapper
β βββ π angle_calculation.py # Angle math
β
βββ π feedback/
β βββ π indicators.py # UI components
β βββ π information.py # Exercise metadata
β βββ π layout.py
β
βββ π db/
β βββ π workout_logger.py # Workout history logging
β
βββ π templates/
β βββ π index.html # Home - Real-time exercise tracking
β βββ π video_analysis.html # Video upload & analysis page
β βββ π dashboard.html # Stats dashboard
β βββ π profile.html # User profile & settings
β
βββ π static/
βββ π css/
β βββ π style.css # Global styles
β βββ π dashboard.css # Dashboard page styles
β βββ π profile.css # Profile page styles
β βββ π video_analysis.css # Video analysis styles
βββ π js/
β βββ π script.js # Main page JavaScript
β βββ π dashboard.js # Dashboard functionality
β βββ π profile.js # Profile page functionality
β βββ π video_analysis.js # Video analysis functionality
βββ π images/
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Home page - Real-time exercise tracking |
/video_analysis |
GET | Video upload & analysis page |
/dashboard |
GET | Workout statistics dashboard |
/profile |
GET | User profile & settings |
/video_feed |
GET | MJPEG video stream |
/start_exercise |
POST | Start tracking an exercise |
/stop_exercise |
POST | Stop current exercise |
/get_status |
GET | Get current rep count & form score |
/exercises |
GET | List all available exercises |
/api/video/upload |
POST | Upload video for analysis |
/api/video/status/<id> |
GET | Get video analysis status |
/api/video/processed/<id> |
GET | Download processed video |
/api/profile/update |
POST | Update user profile |
Real-time pose estimation with skeleton overlay and form feedback.
Upload videos, analyze with skeleton overlay, and download processed results.
Personal stats, achievements, goals tracking, and customizable settings.
- Flask - Web framework
- OpenCV - Computer vision & video processing
- MediaPipe - Google's pose estimation model
- imageio-ffmpeg - H.264 video encoding for browser compatibility
- PyYAML - Exercise definition parsing
- Chart.js - Interactive charts for dashboard
- HTML/CSS/JS - Modern responsive frontend
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-exercise) - Add your YAML exercise definition
- Run tests (
python test_engine.py) - Commit changes (
git commit -am 'Add new exercise') - Push to branch (
git push origin feature/new-exercise) - Create Pull Request
MIT License - see LICENSE file for details.
Made with β€οΈ for fitness enthusiasts