CoolFace
Apppublic

NIRAJz/InDiet

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
exercise.py99 linesDownload Raw Back to src
1import pandas as pd
2class ExerciseRecommender:
3    def __init__(self):
4        self.exercises = {
5            "Chest": [
6                {"Exercise Name": "Push-ups", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 167},
7                {"Exercise Name": "Bench Press", "Sets": 4, "Reps": "8-10", "Rest Period (seconds)": 90, "Calories Burned (30 mins)": 200},
8                {"Exercise Name": "Incline Dumbbell Press", "Sets": 3, "Reps": "10-12", "Rest Period (seconds)": 75, "Calories Burned (30 mins)": 180},
9                {"Exercise Name": "Chest Fly", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 150}
10            ],
11            "Core": [
12                {"Exercise Name": "Plank", "Sets": 3, "Reps": "30-60 sec", "Rest Period (seconds)": 45, "Calories Burned (30 mins)": 120},
13                {"Exercise Name": "Russian Twists", "Sets": 3, "Reps": "20/side", "Rest Period (seconds)": 45, "Calories Burned (30 mins)": 140},
14                {"Exercise Name": "Leg Raises", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 130},
15                {"Exercise Name": "Bicycle Crunches", "Sets": 3, "Reps": "20/side", "Rest Period (seconds)": 45, "Calories Burned (30 mins)": 150}
16            ],
17            "Back": [
18                {"Exercise Name": "Pull-ups", "Sets": 3, "Reps": "8-10", "Rest Period (seconds)": 90, "Calories Burned (30 mins)": 180},
19                {"Exercise Name": "Bent-over Rows", "Sets": 4, "Reps": "10-12", "Rest Period (seconds)": 75, "Calories Burned (30 mins)": 190},
20                {"Exercise Name": "Lat Pulldown", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 160},
21                {"Exercise Name": "Deadlifts", "Sets": 4, "Reps": "6-8", "Rest Period (seconds)": 120, "Calories Burned (30 mins)": 220}
22            ],
23            "Arms": [
24                {"Exercise Name": "Bicep Curls", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 120},
25                {"Exercise Name": "Tricep Dips", "Sets": 3, "Reps": "10-12", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 130},
26                {"Exercise Name": "Hammer Curls", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 120},
27                {"Exercise Name": "Skull Crushers", "Sets": 3, "Reps": "10-12", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 130}
28            ],
29            "Legs": [
30                {"Exercise Name": "Squats", "Sets": 4, "Reps": "10-12", "Rest Period (seconds)": 90, "Calories Burned (30 mins)": 200},
31                {"Exercise Name": "Lunges", "Sets": 3, "Reps": "12/side", "Rest Period (seconds)": 75, "Calories Burned (30 mins)": 180},
32                {"Exercise Name": "Leg Press", "Sets": 4, "Reps": "12-15", "Rest Period (seconds)": 75, "Calories Burned (30 mins)": 190},
33                {"Exercise Name": "Calf Raises", "Sets": 3, "Reps": "15-20", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 120}
34            ],
35            "Shoulders": [
36                {"Exercise Name": "Overhead Press", "Sets": 4, "Reps": "8-10", "Rest Period (seconds)": 90, "Calories Burned (30 mins)": 170},
37                {"Exercise Name": "Lateral Raises", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 130},
38                {"Exercise Name": "Front Raises", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 130},
39                {"Exercise Name": "Shrugs", "Sets": 3, "Reps": "12-15", "Rest Period (seconds)": 60, "Calories Burned (30 mins)": 140}
40            ],
41            "Cardio": [
42                {"Exercise Name": "Running (6 mph)", "Sets": 1, "Reps": "20-30 min", "Rest Period (seconds)": 0, "Calories Burned (30 mins)": 300},
43                {"Exercise Name": "Cycling", "Sets": 1, "Reps": "30 min", "Rest Period (seconds)": 0, "Calories Burned (30 mins)": 250},
44                {"Exercise Name": "Jump Rope", "Sets": 1, "Reps": "15-20 min", "Rest Period (seconds)": 0, "Calories Burned (30 mins)": 280},
45                {"Exercise Name": "Swimming", "Sets": 1, "Reps": "30 min", "Rest Period (seconds)": 0, "Calories Burned (30 mins)": 270}
46            ]
47        }
48        
49        self.weekly_plan = {
50            "Monday": ["Chest", "Core"],
51            "Tuesday": ["Back", "Arms"],
52            "Wednesday": ["Legs", "Shoulders"],
53            "Thursday": ["Chest", "Core"],
54            "Friday": ["Back", "Arms"],
55            "Saturday": ["Legs", "Shoulders"],
56            "Sunday": ["Rest/Cardio"]
57        }
58        
59        self.expert_tips = {
60            "Chest": "Focus on full range of motion for chest exercises. Squeeze at the top of each rep for maximum contraction.",
61            "Core": "Engage your core throughout the day, not just during workouts. Maintain proper form to protect your lower back.",
62            "Back": "Pull with your elbows, not your hands. Retract your shoulder blades for proper back engagement.",
63            "Arms": "Control the eccentric (lowering) phase. Avoid swinging to isolate the biceps/triceps effectively.",
64            "Legs": "Keep your knees aligned with your toes during squats and lunges. Go deep but maintain proper form.",
65            "Shoulders": "Don't neglect rear delts. Balance front, side, and rear delt exercises for shoulder health.",
66            "Cardio": "Mix HIIT with steady-state cardio. Interval training boosts metabolism more effectively."
67        }
68
69    def recommend_full_body_workout(self, equipment, difficulty, calories_burned):
70        # This method can be used for general recommendations
71        return {
72            "Chest": pd.DataFrame(self.exercises["Chest"][:2]),
73            "Back": pd.DataFrame(self.exercises["Back"][:2]),
74            "Legs": pd.DataFrame(self.exercises["Legs"][:2]),
75            "Core": pd.DataFrame(self.exercises["Core"][:2])
76        }
77    
78    def get_weekly_plan(self):
79        """Returns the structured weekly workout plan"""
80        return self.weekly_plan
81    
82    def get_day_workout(self, day):
83        """Returns workout for specific day with proper error handling"""
84        muscle_groups = self.weekly_plan.get(day, [])
85        workout = {}
86        
87        for group in muscle_groups:
88            if group == "Rest/Cardio":
89                workout["Cardio"] = pd.DataFrame(self.exercises.get("Cardio", []))
90            else:
91                exercises = self.exercises.get(group, [])
92                if exercises:  # Only add if exercises exist
93                    workout[group] = pd.DataFrame(exercises)
94        
95        return workout if workout else {"Rest": pd.DataFrame([{"Note": "Rest day - active recovery recommended"}])}
96    
97    def get_expert_tips(self, muscle_group):
98        """Returns expert tips for specific muscle group"""
99        return self.expert_tips.get(muscle_group, "Focus on proper form and controlled movements.")