js02vel commited on
Commit
b539384
·
verified ·
1 Parent(s): 8e2b12b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +113 -55
src/streamlit_app.py CHANGED
@@ -1,89 +1,147 @@
1
  import streamlit as st
2
 
 
3
  # Page Configuration
4
- st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered")
 
 
 
 
 
5
 
6
- # Custom Styling
 
 
7
  st.markdown("""
8
- <style>
9
- .main {
10
- background-color: #f5f7f9;
11
- }
12
- .stButton>button {
13
- width: 100%;
14
- border-radius: 5px;
15
- height: 3em;
16
- background-color: #FF4B4B;
17
- color: white;
18
- }
19
- </style>
20
- """, unsafe_allow_html=True)
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  st.title("💪 FitPlan AI")
23
  st.subheader("Milestone 1: Fitness Profile & BMI Analysis")
24
- st.write("Complete the form below to begin your personalized fitness journey.")
25
 
26
- # --- Form Section ---
 
 
27
  with st.form("fitness_form"):
28
- st.header("1. Personal Information")
29
- name = st.text_input("Full Name*", placeholder="Enter your name")
30
-
 
 
31
  col1, col2 = st.columns(2)
32
  with col1:
33
- height = st.number_input("Height (cm)*", min_value=0.0, step=0.1, help="e.g., 175")
 
 
 
 
 
 
34
  with col2:
35
- weight = st.number_input("Weight (kg)*", min_value=0.0, step=0.1, help="e.g., 70")
 
 
 
 
 
36
 
37
  st.divider()
38
-
39
- st.header("2. Fitness Details")
40
- goal = st.selectbox("Fitness Goal",
41
- ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"])
42
-
43
- level = st.select_slider("Fitness Level",
44
- options=["Beginner", "Intermediate", "Advanced"])
45
-
46
- equipment = st.multiselect("Available Equipment",
47
- ["Dumbbells", "Resistance Band", "Yoga Mat", "Kettlebell", "Pull-up Bar", "No Equipment"],
48
- default=["No Equipment"])
49
 
50
- submit_button = st.form_submit_button("Generate Profile")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- # --- Logic & Results ---
53
- if submit_button:
54
- # 5. Input Validation
 
 
 
 
 
55
  if not name.strip():
56
- st.error("Please enter your name.")
57
- elif height <= 0 or weight <= 0:
58
- st.error("Height and weight must be greater than zero.")
 
 
 
 
 
59
  else:
60
- # 3. Functional Requirements
61
  height_m = height / 100 # Convert cm to meters
62
  bmi = weight / (height_m ** 2)
63
- bmi_rounded = round(bmi, 2)
64
 
65
- # Classify BMI
66
  if bmi < 18.5:
67
  category = "Underweight"
68
  color = "blue"
69
  elif 18.5 <= bmi < 24.9:
70
  category = "Normal"
71
  color = "green"
72
- elif 25.0 <= bmi < 29.9:
73
  category = "Overweight"
74
  color = "orange"
75
  else:
76
  category = "Obese"
77
  color = "red"
78
 
79
- # 4. Display Results
80
- st.success(f"Profile Created Successfully for **{name}**!")
81
-
82
- res_col1, res_col2 = st.columns(2)
83
- with res_col1:
84
- st.metric("Your BMI", bmi_rounded)
85
- with res_col2:
86
- st.markdown(f"**Category:** :{color}[{category}]")
87
-
88
- st.info(f"**Goal:** {goal} | **Level:** {level}")
89
- st.write(f"**Equipment:** {', '.join(equipment)}")
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ # --------------------------------------------------
4
  # Page Configuration
5
+ # --------------------------------------------------
6
+ st.set_page_config(
7
+ page_title="FitPlan AI",
8
+ page_icon="💪",
9
+ layout="centered"
10
+ )
11
 
12
+ # --------------------------------------------------
13
+ # Custom Styling (HF Compatible)
14
+ # --------------------------------------------------
15
  st.markdown("""
16
+ <style>
17
+ .stApp {
18
+ background: linear-gradient(135deg, #e3f2fd, #f8fbff);
19
+ }
 
 
 
 
 
 
 
 
 
20
 
21
+ .block-container {
22
+ background-color: white;
23
+ padding: 2rem;
24
+ border-radius: 15px;
25
+ max-width: 850px;
26
+ }
27
+
28
+ .stButton > button {
29
+ width: 100%;
30
+ height: 3em;
31
+ border-radius: 8px;
32
+ background-color: #FF4B4B;
33
+ color: white;
34
+ font-size: 16px;
35
+ border: none;
36
+ }
37
+ </style>
38
+ """, unsafe_allow_html=True)
39
+
40
+ # --------------------------------------------------
41
+ # Title Section
42
+ # --------------------------------------------------
43
  st.title("💪 FitPlan AI")
44
  st.subheader("Milestone 1: Fitness Profile & BMI Analysis")
45
+ st.write("Fill in your details to generate your BMI profile.")
46
 
47
+ # --------------------------------------------------
48
+ # Fitness Profile Form
49
+ # --------------------------------------------------
50
  with st.form("fitness_form"):
51
+
52
+ st.header("1️⃣ Personal Information")
53
+
54
+ name = st.text_input("Full Name *")
55
+
56
  col1, col2 = st.columns(2)
57
  with col1:
58
+ height = st.number_input(
59
+ "Height (cm) *",
60
+ min_value=0.0,
61
+ step=0.1,
62
+ format="%.2f"
63
+ )
64
+
65
  with col2:
66
+ weight = st.number_input(
67
+ "Weight (kg) *",
68
+ min_value=0.0,
69
+ step=0.1,
70
+ format="%.2f"
71
+ )
72
 
73
  st.divider()
 
 
 
 
 
 
 
 
 
 
 
74
 
75
+ st.header("2️⃣ Fitness Details")
76
+
77
+ goal = st.selectbox(
78
+ "Fitness Goal",
79
+ ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
80
+ )
81
+
82
+ equipment = st.multiselect(
83
+ "Available Equipment",
84
+ ["Dumbbells", "Resistance Band", "Yoga Mat",
85
+ "Kettlebell", "Pull-up Bar", "No Equipment"]
86
+ )
87
+
88
+ level = st.radio(
89
+ "Fitness Level",
90
+ ["Beginner", "Intermediate", "Advanced"]
91
+ )
92
 
93
+ submit = st.form_submit_button("Generate Profile")
94
+
95
+ # --------------------------------------------------
96
+ # Processing Logic
97
+ # --------------------------------------------------
98
+ if submit:
99
+
100
+ # -------- Input Validation --------
101
  if not name.strip():
102
+ st.error("Please enter your name.")
103
+
104
+ elif height <= 0:
105
+ st.error("⚠ Height must be greater than 0 cm.")
106
+
107
+ elif weight <= 0:
108
+ st.error("⚠ Weight must be greater than 0 kg.")
109
+
110
  else:
111
+ # -------- BMI Calculation --------
112
  height_m = height / 100 # Convert cm to meters
113
  bmi = weight / (height_m ** 2)
114
+ bmi = round(bmi, 2)
115
 
116
+ # -------- BMI Classification --------
117
  if bmi < 18.5:
118
  category = "Underweight"
119
  color = "blue"
120
  elif 18.5 <= bmi < 24.9:
121
  category = "Normal"
122
  color = "green"
123
+ elif 25 <= bmi < 29.9:
124
  category = "Overweight"
125
  color = "orange"
126
  else:
127
  category = "Obese"
128
  color = "red"
129
 
130
+ # -------- Display Results --------
131
+ st.success(f"Profile successfully created for {name}!")
132
+
133
+ colA, colB = st.columns(2)
134
+
135
+ with colA:
136
+ st.metric("Your BMI", bmi)
137
+
138
+ with colB:
139
+ st.markdown(f"**BMI Category:** :{color}[{category}]")
140
+
141
+ st.info(f"🎯 Goal: {goal} | 📈 Level: {level}")
142
+
143
+ if equipment:
144
+ st.write("🏋 Available Equipment:", ", ".join(equipment))
145
+ else:
146
+ st.write("🏋 Available Equipment: None selected")
147
+