-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise_tracker.py
More file actions
88 lines (74 loc) · 4.44 KB
/
exercise_tracker.py
File metadata and controls
88 lines (74 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import streamlit as st
import google.generativeai as genai
# Configure Gemini API key (use your actual key here)
genai.configure(api_key="AIzaSyCYSlWGpX0BzDiXH_S9tWC9lxXiivt5k88")
# Initialize session state for workout list if not already initialized
if "workout_list" not in st.session_state:
st.session_state.workout_list = []
# AI workout generator function
def generate_ai_workout(goal, experience):
prompt = f"""
Create a personalized gym workout routine for a person whose goal is {goal} and has {experience} experience level.
- Include push, pull, and legs movements based on days like monday, tuesday, wednesday, and so on excluding sunday.
- Suggest 6-8 exercises.
- Include sets and reps.
- Format it in clean bullet points or table.
- Do not give extra notes or alternatives.
- Display it in a tabular format.
- Do not show any warnings or any other text rather than the table.
"""
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content(prompt)
return response.text
# Main app function
def exercise_tracker():
st.header("🏋️ Exercise Planner")
# Create tabs for adding exercises and generating AI workouts
tab1, tab2 = st.tabs(["➕ Add Exercises", "🤖 AI-Generated Workout"])
with tab1:
st.subheader("Manually Add Exercises")
# Muscle groups for the exercise
muscle_group = st.selectbox("Target Muscle Group", [
"Chest", "Back", "Legs", "Shoulders", "Biceps", "Triceps", "Abs"
])
exercises = {
"Chest": ["Flat Bench Press", "Incline Bench Press", "Decline Bench Press", "Dumbbell Fly", "Cable Crossover", "Chest Dips", "Push-Ups", "Incline Dumbbell Press"],
"Back": ["Deadlift", "Lat Pulldown", "Seated Cable Row", "Bent-over Barbell Row", "Pull-Ups", "T-Bar Row", "One-Arm Dumbbell Row", "Hyperextensions"],
"Legs": ["Barbell Squats", "Leg Press", "Walking Lunges", "Leg Extension (Machine)", "Hamstring Curl (Machine)", "Romanian Deadlifts", "Bulgarian Split Squats", "Standing Calf Raises"],
"Shoulders": ["Overhead Press", "Arnold Press", "Lateral Raise", "Front Raise", "Rear Delt Fly", "Upright Row", "Dumbbell Shoulder Press", "Face Pulls"],
"Biceps": ["Barbell Curl", "EZ Bar Curl", "Dumbbell Hammer Curl", "Concentration Curl", "Preacher Curl", "Cable Curl", "Incline Dumbbell Curl", "Spider Curl"],
"Triceps": ["Close-Grip Bench Press", "Skull Crushers", "Tricep Dips", "Tricep Pushdown (Cable)", "Overhead Dumbbell Extension", "Rope Pushdown", "Kickbacks", "Diamond Push-Ups"],
"Abs": ["Crunches", "Hanging Leg Raises", "Plank", "Russian Twists", "Bicycle Crunches", "Cable Crunches", "Mountain Climbers", "Toe Touches"]
}
# Select exercise and input sets/reps
selected_exercise = st.selectbox("Choose Exercise", exercises[muscle_group])
sets = st.number_input("Sets", min_value=1, max_value=6, value=3)
reps = st.number_input("Reps", min_value=1, max_value=20, value=12)
if st.button("Add to Workout"):
exercise_entry = f"{selected_exercise} - {sets} sets x {reps} reps"
st.session_state.workout_list.append(exercise_entry)
st.success(f"✅ Added: {exercise_entry}")
if st.session_state.workout_list:
st.write("### 📝 Current Workout Plan")
for i, entry in enumerate(st.session_state.workout_list, 1):
st.write(f"{i}. {entry}")
# Option to clear the workout list
if st.button("Clear Workout"):
st.session_state.workout_list.clear()
st.success("🗑️ Cleared workout list.")
else:
st.write("No workouts added yet.")
with tab2:
st.subheader("AI Workout Generator")
# AI workout settings
goal = st.selectbox("Fitness Goal", ["Weight Loss", "Muscle Gain", "Endurance"])
experience = st.radio("Experience Level", ["Beginner", "Intermediate", "Advanced"])
# Generate AI workout on button click
if st.button("Generate AI Workout"):
with st.spinner("Generating workout plan..."):
plan = generate_ai_workout(goal, experience)
st.markdown("### 💡 Your AI-Generated Workout Plan")
st.markdown(plan)
# Run app
if __name__ == "__main__":
exercise_tracker()