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.
- 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).
- 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).
- 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.
Install dependencies from the project root:
pip install -r requirements.txtNotes:
- MediaPipe will auto-download a pose model on first run (~30 MB).
- A working webcam is required for live demos.
python main.pyThis opens the webcam, detects the exercise, counts reps, and overlays live quality feedback. Press q to quit.
streamlit run m5/app.pyThe dashboard shows the live video feed, rep counts, and quality metrics.
If the classifier model is missing, train it from a dataset:
- Build
data/feature_vectors.csvfrom videos:
python m6/extract_dataset.py --video_dir videos --output_csv data/feature_vectors.csv --augmentExpected folder structure:
videos/
squat/
pushup/
shoulder_press/
- Train the classifier:
python m1/classifier.pyThis saves model artifacts to models/.
- 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- Squat
- Push-up
- Shoulder press
- 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.