All projects
AI & CV

FormCheck

A local-first exercise assessment app that extracts MediaPipe pose sequences from uploaded videos, routes to specialist form models across six exercises, and pairs frame-by-frame skeleton overlays with optional local LLM feedback.

Overview

FormCheck is a team-built local exercise-assessment application designed for lifters and home exercisers who want understandable form feedback without sending workout videos to external servers.

Upload a single MP4 or MOV repetition (or timestamped pose JSON) and FormCheck extracts 33-landmark MediaPipe poses at 10 FPS inside Docker, automatically routes the clip to the matching exercise specialist (or honors manual selection), and evaluates form across six exercises: right-arm abduction, squat, right-shoulder extension, overhead press, forward lunge, and incline push-up.

The interface pairs the structured finding and joint measurements with a live skeleton video scrubber, five-step repetition frames beside a view-matched correct example repetition (for squat and upper-body exercises), and optional local LLM coaching (Qwen2.5-1.5B-Instruct via llama.cpp) that falls back to reviewed templates. Uploaded clips are deleted after processing, and every reported metric below reflects participant-grouped development validation rather than an independent new-user guarantee.

Key features

  1. Assess uploaded videos locally. Upload a single MP4 or MOV repetition (up to 15 seconds / 100 MB) or timestamped pose JSON (up to 10 MB). Bundled ffmpeg samples at 10 FPS and MediaPipe extracts 33-landmark sequences inside Docker, then request cleanup deletes the raw clip.

  2. Route exercises automatically. A four-class temporal 1D-CNN router (served via an exported NumPy forward pass) plus a geometric knee-height split distinguishes right-arm abduction, squat, right-shoulder extension, overhead press, and forward lunge. Ambiguous top-two matches request confirmation instead of forcing a verdict; incline push-up uses manual selection.

  3. Evaluate six exercises with specialist models. Each exercise runs its own quality checks, shared geometry, and released specialist classifier—covering six-class primary errors on REHAB26 (abduction, squat, shoulder extension), independent knee/elbow binary checks on FitnessAQA overhead press, three-class form on EC3D lunge, and binary form on REHAB24-6 incline push-up.

  4. Inspect movement frame by frame. A video scrubber overlays the extracted skeleton and live measurements on every sampled frame. For squat and the two arm exercises, the app also extracts up to five repetition steps (start, halfway, peak, return, finish) and displays a view-matched correct example repetition side by side.

  5. Explain verdicts with optional local LLM coaching. After the structured assessment renders, a separate request to a local llama.cpp server (Qwen2.5-1.5B-Instruct GGUF) turns the finding, selected measurements, and reviewed template cue into 2–3 encouraging sentences without sending raw video or model scores. Disabling or losing the LLM falls back cleanly to templates.

  6. Withhold verdicts when evidence is weak. Exercise-specific visibility, coverage, finite-feature, and geometric camera-view checks surface recording warnings or abstain instead of fabricating a diagnosis from occluded footage.

Engineering

Implemented architecture

FormCheck runs as a Docker-first local stack: a React and TypeScript interface, a FastAPI assessment service with bundled ffmpeg and MediaPipe PoseLandmarker, an optional local llama.cpp server for coaching explanations, and a separate CPU PyTorch image for offline neural and router experiments.

LayerResponsibility
Interface (web/src/)Video/pose upload, automatic or manual exercise selection, skeleton video scrubber, five-step repetition strip beside example reps, /dev cached-sample view, and model status page
API & runtime (app/api/, app/core/)FastAPI assessment, routing, explanation, and example-repetition endpoints; startup release verification; aggregate SQLite/SQLModel request logging without raw clips
Pose & quality (app/pose/)10-FPS ffmpeg sampling, pinned MediaPipe landmark extraction, shared geometry, movement-phase analysis, and visibility/tracking checks
Routing & specialists (app/routing/, app/exercises/)Exported NumPy four-class temporal CNN router with temperature scaling and geometric lunge/squat split, plus per-exercise feature and inference modules
Feedback (app/feedback/)Reviewed template cues plus optional local llama.cpp (Qwen2.5-1.5B-Instruct) coaching constrained to the structured finding
Training & evaluation (train/, eval/)Dataset-grouped classical, neural (MLP, 1D-CNN, Transformer), relative-depth, router, ensemble, and body-proportion augmentation pipelines importing shared features from app/exercises/

Served exercise lineup

Because public exercise datasets use different label schemas and camera conventions, each exercise keeps its own specialist model and contract rather than forcing one shared label space:

ExerciseSource datasetServed specialistSelection
Right-arm abductionREHAB26LightGBM, 6 classes (correct + 5 primary errors)Automatic or manual
SquatREHAB26LightGBM, 6 classes (correct + 5 primary errors)Automatic or manual
Right-shoulder extensionREHAB26Random Forest, 6 classes (correct + 5 primary errors)Automatic or manual
Overhead pressFitnessAQAKnee Logistic Regression + Elbow LightGBM (2 binary checks)Automatic or manual
Forward lungeEC3DLogistic Regression, 3 classesAutomatic or manual
Incline push-upREHAB24-6Logistic Regression, binary (correct/incorrect)Manual

Shared feature ownership and release verification

Training imports feature formulas directly from app/exercises/ so training and inference never drift. Checked-in releases under models/releases/ carry manifests pinning feature order, input coordinate space, class order, artifact checksums, executable-source hashes (mapped cleanly across refactors via app/core/provenance.py), and prediction probes verified at API startup.

Offline neural checkpoints (MLP, 1D-CNN, Transformer) and research studies never replace serving models automatically. Changing a feature formula or coordinate convention requires fitting, verifying, and explicitly activating a new release.

Evaluation methodology and experimentation

REHAB26 evaluation uses five-person leave-one-subject-out (LOSO) folds across 1,665 physical repetitions captured by three synchronized cameras, keeping all views of a participant together and weighting each repetition’s available views equally. EC3D lunge evaluation uses four-person LOSO across 20 projected views with noisy training and held-out copies. Preprocessing (median imputation and scaling) is fit strictly on training participants.

Across the project we benchmarked eight model families (Majority, Logistic Regression, RBF-SVM, Random Forest, LightGBM, MLP, 1D-CNN, and Transformer), nested participant hyperparameter searches, per-feature occlusion masking, geometric camera-view angle inputs, relative-depth (xyz vs. same-width z0 control) ablations, soft-voting ensembles, and body-proportion augmentation.

My contribution

My work spanned both the ML pipeline and the web application:

  • Exercise routing and overhead-press models. Built, evaluated, and integrated the temporal 1D-CNN exercise router (extended to four classes with overhead press) along with downstream routing comparison tests, and added the independently calibrated overhead-press knee and elbow models.
  • Local LLM explanation integration. Implemented the /analyze/exercise/explain FastAPI endpoint, request/response schemas, Docker Compose llama.cpp wiring, frontend feedback flow, and tests.
  • Frontend interface and tooling. Built and refactored the React/TypeScript application across LandingPage, ExerciseApp, StatusPage (service health and loaded-model monitoring), DepthLabeler (human-label review), client routing, measurement formatting, and custom interactive UI components.
  • Data foundations and quality audits. Built the initial Fitness-AQA ingestion and error-interval parsing pipeline, audited shallow-squat depth supervision, ran KIE coverage and early EC3D pose-preparation studies, and added checkpoint verification and model qualification checks.

Challenges and solutions

Generalize across small participant cohorts

The primary multi-error datasets contain only five participants (REHAB26) or four participants (EC3D), so inner-fold hyperparameter tuning and richer feature sets often overfit to seen subjects and fail to transfer to a held-out person.

We kept unchanged fixed controls inside every nested search, enforced participant-grouped outer splits, isolated relative-depth effects against same-width z0 controls, and tested ensembles and body-proportion augmentation against predeclared adoption gates. Candidates that reduced outer F1/F2 or raised correct-form false-positive rate (FPR) beyond tolerance were rejected rather than shipped.

Route exercises without merging incompatible contracts

REHAB26 models predict one of six mutually exclusive classes, FitnessAQA overhead press runs two independent binary checks, EC3D lunge uses three classes on projected skeletons, and REHAB24-6 incline push-up is binary.

Decoupling exercise routing from form classification kept every specialist clean. The four-class temporal 1D-CNN router uses temperature-scaled confidence thresholds (>= 0.5 with > 0.2 margin for top-1; combined mass >= 0.8 for conditional top-2 confirmation), paired with a geometric knee-height split to separate lunges from squats. Ambiguous top-two candidates return separate specialist assessments and withhold an overall verdict until confirmed.

Handle occlusion and camera-angle variation

Side and left-facing recordings frequently obscure joints, especially on right-arm exercises. Tight global frame filters drop usable clips, while naive zero-filling fabricates joint angles.

Missing measurements stay missing through feature computation and receive fold-local imputation with missingness indicators where needed. Switching shoulder extension to per-feature observation retention at 30% usable right-arm coverage recovered 163 camera views while lowering matched-cohort correct-form FPR. A geometric view-angle heuristic adds signed/absolute angle context and recording warnings without overclaiming full-circle or rear-view reliability.

Keep LLM explanations grounded in structured evidence

Free-form coaching risks contradicting the classifier or inventing clinical advice. The structured prediction renders first; the optional local LLM receives only the exercise, finding, checks, selected measurements, camera view, and reviewed template cue—never raw video, full landmark sequences, or model scores. Abstained or unsupported assessments skip generation, and unavailable or disabled LLM services fall back to reviewed templates.

Preserve honest boundaries on dataset limitations

Earlier auditing of FitnessAQA shallow-squat labels uncovered unresolved disagreement with extracted pose evidence; that legacy binary squat path stays isolated behind an uncalibrated geometric depth fallback, while the active REHAB26 squat specialist learns its own official shallow-squat class. Overhead-press elbow checks still carry a high false-alarm rate, and EC3D lunge models rely on projected OpenPose skeletons whose transfer to real MediaPipe uploads has not yet been validated.

Outcomes

FormCheck has grown from an initial squat-only pose-JSON prototype into a containerized local video-assessment application spanning six exercises, automatic CNN routing, live skeleton scrubbing, five-step repetition inspection beside example repetitions, and optional local LLM coaching.

Routing performance

Out-of-fold evaluation of the served four-class temporal CNN router (FormCheck_Router_CNN_4Class_20261124, combining participant-held-out REHAB26 and source-group-held-out FitnessAQA):

Router policyMacro F2Wrong-expert macro FPRTrue exercise selectedCoverageTop-2 rate
Top-10.98140.62%98.14%100.00%0.00%
Conditional top-20.98310.72%98.44%99.95%0.66%

In the earlier three-class REHAB26 downstream study across all 4,995 camera inputs (joint 18-class exercise and form evaluation), replacing geometry rules with conditional top-2 CNN routing raised joint form macro F2 from 0.4206 to 0.5769 (+0.1563) and verdict coverage from 72.87% to 86.33%, while reducing correct-form FPR from 22.76% to 19.39%.

Served specialist development metrics

These are development cross-validation or validation-split estimates—not independent new-user test scores—and cohorts differ across datasets:

Exercise (served specialist)Protocol / cohortMacro F1Macro F2Correct-form FPR
Right-arm abduction (LightGBM)REHAB26 5-person LOSO, 1,458 views0.5980.59531.3%
Squat (LightGBM)REHAB26 5-person LOSO, 1,662 views0.6090.61321.5%
Right-shoulder extension (Random Forest)REHAB26 5-person LOSO, 1,189 views0.7520.75214.6%
Forward lunge (Logistic Regression)EC3D 4-person LOSO, noisy projected poses0.7650.77319.7%
Incline push-up (Logistic Regression)REHAB24-6 pooled holdouts, 107 reps0.8040.804—

For FitnessAQA overhead press on assessed official validation clips, the knee Logistic Regression check reaches 0.952 F2 at 9.7% coverage (14.3% FPR), while the elbow LightGBM check reaches 0.637 F2 at 89.7% coverage with substantial false alarms (73.9% FPR).

What experiments ruled out

Across eight compared model families on REHAB26, tuned classical tree models consistently outperformed fixed and tuned neural baselines (MLP, 1D-CNN, Transformer). Relative-depth (+z vs. z0) ablations, nested relative-z tuning, external IntelliRehabDS correct-form additions, and a serving-compatible classical soft vote with body-proportion augmentation all failed to clear the predeclared serving adoption rules (either lowering F1/F2 or increasing correct-form FPR—by +6.4 percentage points on shoulder extension), so none replaced the active view-aware serving releases.

Remaining limits and open work

  • Validate generalization on independent new-user recordings beyond the 4–5 participant development cohorts, including real MediaPipe uploads for EC3D forward lunges.
  • Bring the checked-in router training CLI (currently three-class) up to parity with the served four-class release.
  • Improve overhead-press knee coverage and elbow precision, and evaluate on untouched test splits.
  • Support automatic multi-repetition segmentation for longer workout videos.
  • Have step-by-step technique wording and coaching usefulness reviewed with users and domain experts.