Personalized Workout AI with 1,500+ Exercises & Natural Language Interface
An intelligent fitness planning system that generates personalized workout routines using machine learning, trained on 57,861 real workout records with 80.37% prediction accuracy.
- π― Personalized Workouts: ML-powered recommendations based on goals, experience, and equipment
- οΏ½ Natural Language Interface: "28 year old male, muscle gain, gym access, 4 days per week"
- πͺ 1,500+ Exercise Database: Comprehensive exercise library with equipment variations
- οΏ½ Multi-Output Prediction: Sets, reps, intensity, weight, and RPE in one model
- οΏ½ Safety First: Expert rules and constraints for injury prevention
- β‘ Fast API: RESTful API with <50ms response times
- π CORS Ready: Easy integration with web/mobile applications
- π« No API Keys Required: Works completely offline with intelligent systems
- Clone the repository:
git clone <repository-url>
cd personal_fitness_ai- Create a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Train the model (required first time):
python train_model.pyNote: The model file (219MB) is excluded from GitHub due to size limits. This step recreates it locally.
- Start the API server:
python api_server.pyThe server will start at http://localhost:8000
| Metric | Score | Description |
|---|---|---|
| Overall RΒ² | 80.37% | Excellent variance explanation |
| Weight Prediction | 93.82% | Near-perfect weight progression |
| Intensity Prediction | 91.12% | Superior intensity targeting |
| Reps Prediction | 84.01% | Strong rep range optimization |
| RPE Prediction | 77.98% | Good subjective measure accuracy |
- 95.3% within Β±1 set (excellent for training)
- 94.1% within Β±3 reps (highly practical)
- 99.9% within Β±10% intensity (outstanding)
The model achieves human-level consistency with superior reliability.
curl -X POST "http://localhost:8000/plan" \
-H "Content-Type: application/json" \
-d '{"message": "25 year old female, weight loss, home workout, 3 days per week"}'http://localhost:8000
Creates a personalized workout plan from natural language input.
Request:
{
"message": "28 year old male, muscle gain, gym access, 4 days per week",
"weeks": 4,
"use_natural_language": true
}Response:
{
"plan": "Here's your 4-week workout plan! As a 28-year-old male focused on muscle gain...",
"profile": {
"Age": 28,
"Gender": "Male",
"Goal": "Muscle Gain",
"Fitness_Level": "Intermediate",
"Days_per_Week": 4,
"Equipment": "Gym",
"Body_Type": "Mesomorph",
"Injuries": []
},
"source": "expert_rules",
"structured_data": null
}Extracts structured profile data from natural language.
Request:
{
"message": "30 year old female, wants to lose weight, 3 days per week, has knee injury"
}Response:
{
"profile": {
"Age": 30,
"Gender": "Female",
"Goal": "Weight Loss",
"Fitness_Level": "Intermediate",
"Days_per_Week": 3,
"Equipment": "Gym",
"Body_Type": "Mesomorph",
"Injuries": ["knee"]
}
}Returns system status and component availability.
Basic API information and version.
Visit http://localhost:8000/docs for interactive API documentation powered by Swagger UI.
import requests
response = requests.post("http://localhost:8000/plan", json={
"message": "22 year old male, wants to build muscle, gym access, 4 days per week",
"weeks": 6
})
plan = response.json()
print(plan["plan"])response = requests.post("http://localhost:8000/plan", json={
"message": "35 year old female, weight loss, home workouts only, 3 days per week",
"weeks": 4
})response = requests.post("http://localhost:8000/plan", json={
"message": "40 year old male, strength training, gym access, has back injury, 3 days per week"
})- Extracts age, gender, goals, equipment, training frequency
- Identifies injuries and physical limitations
- Maps to structured profile format
- Uses trained Random Forest models (RΒ² 0.44-0.92 performance)
- Predicts optimal sets, reps, and intensity for each exercise
- Based on 57,000+ real workout records
- Equipment Substitution: Replaces unavailable exercises
- Injury Safety: Avoids contraindicated movements
- Progressive Overload: Increases volume and intensity over time
- Smart Scheduling: Distributes exercises across training days
- 1,500+ exercises from comprehensive fitness database
- Categorized by muscle groups, equipment, and difficulty
- Includes bodyweight, dumbbell, barbell, machine, and cable exercises
personal_fitness_ai/
βββ api_server.py # FastAPI server and main endpoints
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ start.sh # Easy startup script
βββ test_api.py # API test suite
βββ .gitignore # Git ignore patterns
βββ data/
β βββ exercises.json # 1,500+ exercise database
β βββ workout_comprehensive.csv # Training data (57K+ records)
β βββ muscles.json # Muscle group mappings
β βββ bodyparts.json # Body part categories
β βββ equipments.json # Equipment types
βββ model/
βββ predict_sets.py # ML prediction engine
βββ nl_parser.py # Natural language processing
βββ llm_planner.py # Workout plan generation
βββ expert_rules.py # Safety rules and substitutions
βββ comprehensive_model.pkl # Trained ML model
βββ model_info.json # Model metadata
const generateWorkout = async (userMessage) => {
const response = await fetch('http://localhost:8000/plan', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: userMessage,
weeks: 4,
use_natural_language: true
})
});
const data = await response.json();
return data.plan;
};
// Usage
const plan = await generateWorkout("25 year old, wants to get fit, 3 days per week");import requests
class FitnessPlanner:
def __init__(self, base_url="http://localhost:8000"):
self.base_url = base_url
def create_plan(self, message, weeks=4):
response = requests.post(f"{self.base_url}/plan", json={
"message": message,
"weeks": weeks,
"use_natural_language": True
})
return response.json()
def parse_profile(self, message):
response = requests.post(f"{self.base_url}/parse", json={
"message": message
})
return response.json()
# Usage
planner = FitnessPlanner()
plan = planner.create_plan("30 year old, muscle building, 4 days per week")// Flutter/Dart example
Future<Map<String, dynamic>> generateWorkoutPlan(String userInput) async {
final response = await http.post(
Uri.parse('http://localhost:8000/plan'),
headers: {'Content-Type': 'application/json'},
body: json.encode({
'message': userInput,
'weeks': 4,
'use_natural_language': true,
}),
);
return json.decode(response.body);
}# Install test dependencies if needed
pip install requests
# Run the test suite
python test_api.py- Edit
data/exercises.json - Follow the existing format:
{
"name": "Custom Exercise",
"targetMuscles": ["chest", "triceps"],
"equipments": ["dumbbell"],
"bodyParts": ["upper body"],
"category": "strength"
}# Update training data in data/workout_comprehensive.csv
# Run model training
python -c "from model.predict_sets import ComprehensiveFitnessPredictor; ComprehensiveFitnessPredictor().train_model()"- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Exercise database sourced from comprehensive fitness resources
- ML models trained on anonymized workout data
- Built with FastAPI, scikit-learn, and modern Python stack
- Create an issue for bug reports or feature requests
- Check the API documentation at
/docsendpoint - Review example integrations in this README
Ready to revolutionize fitness planning? π
Start the server with python api_server.py and send your first natural language workout request!