Update src/streamlit_app.py
Browse files- src/streamlit_app.py +53 -33
src/streamlit_app.py
CHANGED
|
@@ -2,6 +2,19 @@ import streamlit as st
|
|
| 2 |
|
| 3 |
# 1. Basic Configuration
|
| 4 |
st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# 2. Enhanced CSS
|
| 7 |
st.markdown("""
|
|
@@ -107,40 +120,47 @@ with st.form("fitness_form", clear_on_submit=False):
|
|
| 107 |
|
| 108 |
level = st.radio("Fitness Level", ["Beginner", "Intermediate", "Advanced"], horizontal=True)
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
| 119 |
else:
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
with
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
|
| 146 |
|
|
|
|
| 2 |
|
| 3 |
# 1. Basic Configuration
|
| 4 |
st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered")
|
| 5 |
+
frpm transformers import pipeline
|
| 6 |
+
def load_model():
|
| 7 |
+
|
| 8 |
+
return pipeline(
|
| 9 |
+
|
| 10 |
+
"text-generation",
|
| 11 |
+
|
| 12 |
+
model="google/flan-t5-base"
|
| 13 |
+
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
generator = load_model()
|
| 17 |
+
|
| 18 |
|
| 19 |
# 2. Enhanced CSS
|
| 20 |
st.markdown("""
|
|
|
|
| 120 |
|
| 121 |
level = st.radio("Fitness Level", ["Beginner", "Intermediate", "Advanced"], horizontal=True)
|
| 122 |
|
| 123 |
+
if st.button("Submit Profile"):
|
| 124 |
+
|
| 125 |
+
if not name:
|
| 126 |
+
st.error("Please enter your name.")
|
| 127 |
+
|
| 128 |
+
elif not equipment:
|
| 129 |
+
st.error("Please select at least one equipment option.")
|
| 130 |
+
|
| 131 |
+
elif bmi is None:
|
| 132 |
+
st.error("Please enter valid height and weight.")
|
| 133 |
+
|
| 134 |
else:
|
| 135 |
+
st.success("✅ Profile Submitted Successfully!")
|
| 136 |
+
|
| 137 |
+
bmi_status = bmi_category(bmi)
|
| 138 |
+
equipment_list = ", ".join(equipment)
|
| 139 |
+
|
| 140 |
+
prompt = f"""
|
| 141 |
+
Generate a 5-day structured workout plan.
|
| 142 |
+
|
| 143 |
+
User Details:
|
| 144 |
+
Name: {name}
|
| 145 |
+
Gender: {gender}
|
| 146 |
+
BMI: {bmi:.2f} ({bmi_status})
|
| 147 |
+
Goal: {goal}
|
| 148 |
+
Fitness Level: {fitness_level}
|
| 149 |
+
Available Equipment: {equipment_list}
|
| 150 |
+
|
| 151 |
+
Requirements:
|
| 152 |
+
- Include warmup
|
| 153 |
+
- Include exercises with sets and reps
|
| 154 |
+
- Include rest time
|
| 155 |
+
- Adjust intensity based on BMI and fitness level
|
| 156 |
+
- Keep it structured day-wise
|
| 157 |
+
"""
|
| 158 |
+
|
| 159 |
+
with st.spinner("Generating your AI workout plan..."):
|
| 160 |
+
result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
|
| 161 |
+
|
| 162 |
+
st.subheader("🏋️ Your Personalized Workout Plan")
|
| 163 |
+
st.write(result)
|
| 164 |
|
| 165 |
|
| 166 |
|