Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +40 -40
src/streamlit_app.py
CHANGED
|
@@ -72,43 +72,43 @@ with st.form("fitness_form"):
|
|
| 72 |
# HANDLE SUBMISSION
|
| 73 |
# -------------------------
|
| 74 |
if submit:
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
| 72 |
# HANDLE SUBMISSION
|
| 73 |
# -------------------------
|
| 74 |
if submit:
|
| 75 |
+
# Validation
|
| 76 |
+
if not name.strip():
|
| 77 |
+
st.error("Please enter your name.")
|
| 78 |
+
elif height <= 0 or weight <= 0:
|
| 79 |
+
st.error("Height and Weight must be positive values.")
|
| 80 |
+
elif not equipment:
|
| 81 |
+
st.error("Please select at least one equipment option.")
|
| 82 |
+
else:
|
| 83 |
+
# Calculate BMI
|
| 84 |
+
user_bmi = calculate_bmi(weight, height)
|
| 85 |
+
bmi_status = get_category(user_bmi)
|
| 86 |
+
|
| 87 |
+
st.success(f"✅ Profile Created Successfully for {name}!")
|
| 88 |
+
st.metric("Your BMI", user_bmi)
|
| 89 |
+
st.info(f"Health Category: **{bmi_status}**")
|
| 90 |
+
|
| 91 |
+
equipment_list = ", ".join(equipment)
|
| 92 |
+
|
| 93 |
+
# Prepare AI prompt
|
| 94 |
+
prompt = f"""
|
| 95 |
+
Create a professional 5-day structured workout plan.
|
| 96 |
+
User Details:
|
| 97 |
+
Name: {name}
|
| 98 |
+
BMI: {user_bmi} ({bmi_status})
|
| 99 |
+
Goal: {goal}
|
| 100 |
+
Fitness Level: {level}
|
| 101 |
+
Equipment: {equipment_list}
|
| 102 |
+
Include:
|
| 103 |
+
- Warm-up
|
| 104 |
+
- Exercises with sets and reps
|
| 105 |
+
- Rest time
|
| 106 |
+
- Intensity adjustment
|
| 107 |
+
- Day-wise structure
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
with st.spinner("Generating your AI workout plan..."):
|
| 111 |
+
result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
|
| 112 |
+
|
| 113 |
+
st.subheader("🏋️ Your Personalized Workout Plan")
|
| 114 |
+
st.write(result)
|