srbhavya01 commited on
Commit
7c9ec2f
Β·
verified Β·
1 Parent(s): 3d96c36

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +67 -87
src/streamlit_app.py CHANGED
@@ -1,101 +1,81 @@
1
  import streamlit as st
2
 
3
- st.set_page_config(page_title="AI Fitness Plan Generator", page_icon="πŸ’ͺ", layout="wide")
4
-
5
- st.markdown("""
6
- <style>
7
- .main {
8
- background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
9
- }
10
- label, .stTextInput label, .stSelectbox label {
11
- color: white !important;
12
- }
13
- </style>
14
- """, unsafe_allow_html=True)
15
-
16
- st.title("πŸ’ͺ AI Fitness Plan Generator")
17
- st.write("Get a personalized fitness plan based on your details")
18
-
19
- # User Inputs
20
- age = st.number_input("Age", min_value=10, max_value=100, step=1)
21
- gender = st.selectbox("Gender", ["Male", "Female", "Other"])
 
 
22
  goal = st.selectbox(
23
- "Fitness Goal",
24
- [
25
- "Flexibility",
26
- "Weight Loss",
27
- "Build Muscle",
28
- "Strength Gaining",
29
- "Abs Building"
30
- ]
31
- )
32
- fitness_level = st.selectbox(
33
- "Fitness Level",
34
- ["Beginner", "Intermediate", "Advanced"]
35
  )
36
 
37
  equipment = st.multiselect(
38
- "Available Equipment",
39
- [
40
- "Dumbbells",
41
- "Resistance Band",
42
- "Yoga Mat",
43
- "Inclined Bench",
44
- "Treadmill",
45
- "Cycle",
46
- "Skipping Rope",
47
- "Hand Gripper",
48
- "Pull-ups Bar",
49
- "Weight Plates",
50
- "Hula Hoop Ring",
51
- "Bosu Ball"
52
- ]
53
  )
54
 
55
- # Plan Logic
 
 
 
56
 
57
- def generate_plan(goal, fitness_level, equipment):
58
- plan = ""
 
59
 
60
- if goal == "Weight Loss":
61
- plan = "πŸƒ Focus on calorie-burning workouts with cardio and light strength training."
62
- elif goal == "Build Muscle":
63
- plan = "πŸ‹οΈ Progressive strength training with adequate protein intake."
64
- elif goal == "Strength Gaining":
65
- plan = "πŸ’ͺ Heavy compound lifts with longer rest periods."
66
- elif goal == "Abs Building":
67
- plan = "πŸ”₯ Core-focused workouts combined with fat-loss strategies."
68
- else:
69
- plan = "🧘 Flexibility and mobility routines with stretching and yoga."
70
 
71
- if fitness_level == "Beginner":
72
- plan += " Start slow, focus on form, and train 3–4 days/week."
73
- elif fitness_level == "Intermediate":
74
- plan += " Increase intensity and volume, train 4–5 days/week."
 
 
 
75
  else:
76
- plan += " High-intensity training with structured programming, 5–6 days/week."
77
 
78
- if equipment:
79
- plan += f" Use available equipment: {', '.join(equipment)}."
 
 
 
 
 
 
 
80
  else:
81
- plan += " Bodyweight exercises will be emphasized."
82
-
83
- return plan
84
-
85
- # Button
86
- if st.button("Generate Fitness Plan"):
87
- plan = generate_plan(goal, fitness_level, equipment)
88
- st.success("Your Personalized Fitness Plan")
89
- st.markdown(f"""
90
- **Age:** {age}
91
- **Gender:** {gender}
92
- **Goal:** {goal}
93
- **Fitness Level:** {fitness_level}
94
- **Equipment:** {', '.join(equipment) if equipment else 'None'}
95
-
96
- ---
97
- {plan}
98
- """)
99
-
100
- st.markdown("---")
101
- st.caption("πŸš€ Built with Streamlit | Ready for AI integration")
 
1
  import streamlit as st
2
 
3
+ st.set_page_config(page_title="FitPlan AI - BMI Calculator", page_icon="πŸ’ͺ")
4
+
5
+ st.title("πŸ’ͺ FitPlan AI - Fitness Profile & BMI Calculator")
6
+
7
+ st.write("Fill in your details to calculate your BMI and fitness category.")
8
+
9
+ # -------------------------
10
+ # 1. Personal Information
11
+ # -------------------------
12
+
13
+ name = st.text_input("Enter Your Name *")
14
+
15
+ height_cm = st.number_input("Enter Height (in centimeters) *", min_value=0.0, format="%.2f")
16
+ weight_kg = st.number_input("Enter Weight (in kilograms) *", min_value=0.0, format="%.2f")
17
+
18
+ # -------------------------
19
+ # 2. Fitness Details
20
+ # -------------------------
21
+
22
+ st.subheader("Fitness Details")
23
+
24
  goal = st.selectbox(
25
+ "Select Your Fitness Goal",
26
+ ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
 
 
 
 
 
 
 
 
 
 
27
  )
28
 
29
  equipment = st.multiselect(
30
+ "Available Equipment (Select multiple if available)",
31
+ ["Dumbbells", "Resistance Band", "Yoga Mat", "No Equipment"]
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  )
33
 
34
+ fitness_level = st.radio(
35
+ "Select Your Fitness Level",
36
+ ["Beginner", "Intermediate", "Advanced"]
37
+ )
38
 
39
+ # -------------------------
40
+ # BMI Calculation Function
41
+ # -------------------------
42
 
43
+ def calculate_bmi(weight, height_cm):
44
+ height_m = height_cm / 100 # Convert cm to meters
45
+ bmi = weight / (height_m ** 2)
46
+ return round(bmi, 2)
 
 
 
 
 
 
47
 
48
+ def bmi_category(bmi):
49
+ if bmi < 18.5:
50
+ return "Underweight"
51
+ elif 18.5 <= bmi < 24.9:
52
+ return "Normal"
53
+ elif 25 <= bmi < 29.9:
54
+ return "Overweight"
55
  else:
56
+ return "Obese"
57
 
58
+ # -------------------------
59
+ # Submit Button
60
+ # -------------------------
61
+
62
+ if st.button("Calculate BMI"):
63
+
64
+ # Validation
65
+ if not name or height_cm <= 0 or weight_kg <= 0:
66
+ st.error("⚠ Please fill all required fields with valid values!")
67
  else:
68
+ bmi = calculate_bmi(weight_kg, height_cm)
69
+ category = bmi_category(bmi)
70
+
71
+ st.success("βœ… Calculation Successful!")
72
+
73
+ st.write(f"### πŸ‘€ Name: {name}")
74
+ st.write(f"### πŸ“Š Your BMI: {bmi}")
75
+ st.write(f"### 🏷 BMI Category: {category}")
76
+
77
+ st.write("---")
78
+ st.write("### πŸ‹ Fitness Summary")
79
+ st.write(f"**Goal:** {goal}")
80
+ st.write(f"**Fitness Level:** {fitness_level}")
81
+ st.write(f"**Equipment Available:** {', '.join(equipment) if equipment else 'None selected'}")