FitCoach-AI is a small end-to-end system that uses phone motion sensors (accelerometer + gyroscope) and a machine learning model to give real-time feedback on bicep curl form. It tells you whether a rep looks CORRECT or INCORRECT and keeps basic rep statistics.
⚠️ Scope: Right now this project only supports bicep curls. The architecture is designed so more exercises (squats, push-ups, etc.) can be added later with new models and UI updates.
train_bicep_model.py,classify_new_session.py- Python scripts to train a RandomForest classifier from IMU CSVs and classify new sessions into CORRECT vs INCORRECT windows.
models/bicep_model.joblib- Trained model used by the backend API.
server.py- FastAPI backend that exposes
POST /classify_windowand returns{ "label": "CORRECT" | "INCORRECT", "confidence": float }for a window of IMU samples.
- FastAPI backend that exposes
android_app/- Android client (Kotlin) that reads accelerometer/gyroscope data, buffers it into sliding windows, sends them to the backend, and shows:
- Live status (CORRECT / INCORRECT).
- Total reps, correct reps, incorrect reps in a simple fitness-style UI.
- Android client (Kotlin) that reads accelerometer/gyroscope data, buffers it into sliding windows, sends them to the backend, and shows:
-
Backend (FastAPI + model)
-
Install Python dependencies.
-
Make sure
models/bicep_model.joblibexists (runpython train_bicep_model.pyif needed). -
Start the API:
uvicorn server:app --host 0.0.0.0 --port 8000 --reload
-
Open
http://127.0.0.1:8000/docsto see the API docs.
-
-
Android app (phone + sensors)
-
Open
android_appin Android Studio. -
Update the base URL in
MainActivity.kt:private const val BASE_URL = "http://YOUR_LAPTOP_IP:8000"
(Laptop and phone must be on the same Wi‑Fi network.)
-
Ensure
network_security_config.xmlallows HTTP to this IP for local development. -
Run the app on a real Android device, tap Start, and perform bicep curls with the phone/watch on your training arm.
-
- The Android app collects IMU samples, keeps a sliding 3‑second window, and periodically sends a window to the backend when:
- it has enough samples,
- there is enough change in acceleration to look like a rep, and
- at least ~1–1.5 seconds have passed since the last counted rep.
- The FastAPI service converts the window into features and calls the trained RandomForest model, which outputs CORRECT vs INCORRECT and a confidence score.
- The app updates:
- Status text (CORRECT / INCORRECT + confidence).
- Rep counters (total, correct, incorrect).
Planned extensions:
- Add more exercises (e.g., squats, push-ups) by training additional models or extending labels (BICEP_CORRECT, SQUAT_INCORRECT, etc.).
- Per-user calibration and better rep segmentation (per‑rep peak detection instead of simple sliding windows).
- More advanced UI with history, sets, and progress tracking similar to commercial fitness apps.