Harry2406 commited on
Commit
36906ac
·
verified ·
1 Parent(s): 467c4ab

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +20 -40
src/streamlit_app.py CHANGED
@@ -99,44 +99,39 @@ st.markdown("---")
99
  # =========================
100
  # Submit Button
101
  # =========================
102
- # SUBMIT BUTTON
 
 
103
 
104
- if st.button(" Submit Profile"):
105
-
106
- if not name:
107
 
 
108
  st.error("Please enter your name.")
109
-
110
- elif height <= 0 or weight <= 0:
111
 
 
112
  st.error("Please enter valid height and weight.")
113
-
114
- elif not equipment:
115
 
 
116
  st.error("Please select at least one equipment option.")
117
-
118
  else:
 
119
 
120
- st.success(" Profile Submitted Successfully!")
121
-
122
  bmi_status = bmi_category(bmi)
123
-
124
  equipment_list = ", ".join(equipment)
125
-
126
- prompt = f"""
127
 
128
- prompt = f"""
129
  You are a certified professional fitness trainer.
130
-
131
  Generate a structured 5-day workout plan based on the following user profile.
132
-
133
  User Profile:
134
  - Gender: {gender}
135
  - BMI: {bmi:.2f} ({bmi_status})
136
- - Goal: {goal}
137
  - Fitness Level: {fitness_level}
138
  - Available Equipment: {equipment_list}
139
-
140
  Instructions:
141
  1. Divide the plan clearly into Day 1, Day 2, Day 3, Day 4, and Day 5.
142
  2. Under each day, list 4-6 exercises.
@@ -149,37 +144,22 @@ Instructions:
149
  5. Avoid medical or dietary advice.
150
  6. Keep the output clean, structured, and easy to read.
151
  7. Do NOT include explanations outside the workout plan.
152
-
153
- Format Example:
154
-
155
- Day 1: Upper Body Strength
156
- 1. Push-Ups
157
- Sets: 3
158
- Reps: 12
159
- Rest: 60 seconds
160
-
161
  Only return the workout plan.
162
  """
163
-
164
  with st.spinner("Generating your AI workout plan..."):
165
-
166
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
167
-
168
- outputs = model.generate(
169
 
 
170
  **inputs,
171
-
172
  max_new_tokens=600,
173
-
174
  temperature=0.7,
175
-
176
  do_sample=True
177
-
178
  )
179
-
180
  result = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
181
-
182
- st.subheader(" Your Personalized Workout Plan")
183
 
 
184
  st.write(result)
185
-
 
99
  # =========================
100
  # Submit Button
101
  # =========================
102
+ # =========================
103
+ # Submit Button
104
+ # =========================
105
 
106
+ if st.button("Submit Profile"):
 
 
107
 
108
+ if not name:
109
  st.error("Please enter your name.")
 
 
110
 
111
+ elif height_cm <= 0 or weight_kg <= 0:
112
  st.error("Please enter valid height and weight.")
 
 
113
 
114
+ elif not equipment:
115
  st.error("Please select at least one equipment option.")
116
+
117
  else:
118
+ st.success("Profile Submitted Successfully!")
119
 
 
 
120
  bmi_status = bmi_category(bmi)
 
121
  equipment_list = ", ".join(equipment)
 
 
122
 
123
+ prompt = f"""
124
  You are a certified professional fitness trainer.
125
+
126
  Generate a structured 5-day workout plan based on the following user profile.
127
+
128
  User Profile:
129
  - Gender: {gender}
130
  - BMI: {bmi:.2f} ({bmi_status})
131
+ - Goal: {fitness_goal}
132
  - Fitness Level: {fitness_level}
133
  - Available Equipment: {equipment_list}
134
+
135
  Instructions:
136
  1. Divide the plan clearly into Day 1, Day 2, Day 3, Day 4, and Day 5.
137
  2. Under each day, list 4-6 exercises.
 
144
  5. Avoid medical or dietary advice.
145
  6. Keep the output clean, structured, and easy to read.
146
  7. Do NOT include explanations outside the workout plan.
147
+
 
 
 
 
 
 
 
 
148
  Only return the workout plan.
149
  """
150
+
151
  with st.spinner("Generating your AI workout plan..."):
152
+
153
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
 
 
154
 
155
+ outputs = model.generate(
156
  **inputs,
 
157
  max_new_tokens=600,
 
158
  temperature=0.7,
 
159
  do_sample=True
 
160
  )
161
+
162
  result = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
 
 
163
 
164
+ st.subheader("Your Personalized Workout Plan")
165
  st.write(result)