Skip to content

Mayur-Shashidhar/Gym-Bro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gym Bro

Gym Bro is a real-time exercise analyzer that combines pose estimation, rep counting, exercise classification, and movement quality scoring. It supports a CLI pipeline and a Streamlit dashboard for live coaching-style feedback with accuracy reaching 0.9677.

What it does

  • Tracks a full-body skeleton with MediaPipe (M2).
  • Computes joint angles and rep counts with a signal-based state machine (M3).
  • Classifies exercises from per-frame feature vectors (M1).
  • Scores rep quality with an explainable rule-based scorer (M4).
  • Offers a live Streamlit dashboard UI (M5).
  • Builds training datasets from videos (M6).

Project layout

  • main.py: End-to-end live pipeline (M2 -> M3 -> M1 -> M4) using the webcam.
  • m1/: Exercise classifier (RandomForest) and fatigue detection.
  • m2/: Pose tracking and landmark utilities (MediaPipe Tasks API).
  • m3/: Angle extraction and rep counting.
  • m4/: Movement quality scoring rules.
  • m5/: Streamlit dashboard UI and styling.
  • m6/: Dataset extraction from exercise videos.
  • data/: feature_vectors.csv (training data).
  • models/: saved classifier artifacts (generated).

Tech stack

  • Language: Python 3.
  • Pose tracking: MediaPipe Tasks API.
  • Computer vision: OpenCV.
  • ML: scikit-learn (RandomForest) with joblib serialization.
  • Data: NumPy and pandas.
  • UI: Streamlit with Plotly charts.

Requirements

Install dependencies from the project root:

pip install -r requirements.txt

Notes:

  • MediaPipe will auto-download a pose model on first run (~30 MB).
  • A working webcam is required for live demos.

Quick start

1) Run the CLI pipeline

python main.py

This opens the webcam, detects the exercise, counts reps, and overlays live quality feedback. Press q to quit.

2) Run the Streamlit dashboard

streamlit run m5/app.py

The dashboard shows the live video feed, rep counts, and quality metrics.

Train the classifier (M1)

If the classifier model is missing, train it from a dataset:

  1. Build data/feature_vectors.csv from videos:
python m6/extract_dataset.py --video_dir videos --output_csv data/feature_vectors.csv --augment

Expected folder structure:

videos/
  squat/
  pushup/
  shoulder_press/
  1. Train the classifier:
python m1/classifier.py

This saves model artifacts to models/.

Tests and utilities

  • M2 landmark utilities tests:
python m2/test_m2.py
  • M3 rep counter tests:
python m3/test_m3.py
  • Quick webcam sanity check:
python m5/test_cam.py

Supported exercises

  • Squat
  • Push-up
  • Shoulder press

Troubleshooting

  • If the classifier cannot load, run the training step above to create models/exercise_classifier.pkl.
  • If the webcam cannot open, verify permissions and try the camera test script.

About

Gym Bro is a real-time exercise analyzer that combines pose estimation, rep counting, exercise classification, and movement quality scoring. It supports a CLI pipeline and a Streamlit dashboard for live coaching-style feedback.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 72.4%
  • Python 26.3%
  • CSS 1.3%