Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +161 -127
src/streamlit_app.py
CHANGED
|
@@ -1,169 +1,203 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import time
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
st.markdown("""
|
| 8 |
<style>
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
padding: 25px;
|
| 15 |
border-radius: 15px;
|
| 16 |
-
box-shadow: 0px
|
| 17 |
-
margin-bottom: 25px;
|
| 18 |
-
}
|
| 19 |
-
h3 {
|
| 20 |
-
margin-top: 0px;
|
| 21 |
}
|
|
|
|
| 22 |
.stButton>button {
|
| 23 |
-
background
|
| 24 |
color: white;
|
| 25 |
border-radius: 10px;
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
font-weight: 600;
|
| 28 |
}
|
|
|
|
| 29 |
.stButton>button:hover {
|
| 30 |
-
background
|
| 31 |
}
|
| 32 |
-
</style>
|
| 33 |
-
""", unsafe_allow_html=True)
|
| 34 |
-
|
| 35 |
-
# ------------------ HEADER ------------------
|
| 36 |
-
st.title("πͺ FitPlan AI")
|
| 37 |
-
st.subheader("Complete Fitness Profile Setup")
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
-
st.markdown("### π€ Personal Information")
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
with col1:
|
| 50 |
name = st.text_input("Full Name")
|
| 51 |
-
age = st.number_input("Age",
|
| 52 |
-
gender = st.selectbox("Gender", ["
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
height = st.number_input("Height (cm)", 120, 220, 160)
|
| 56 |
-
weight = st.number_input("Weight (kg)", 30, 150, 55)
|
| 57 |
-
fitness_level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
|
| 58 |
-
|
| 59 |
-
st.divider()
|
| 60 |
-
|
| 61 |
-
st.markdown("### π― Fitness Goals")
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
["Build Muscle", "Lose Weight", "Fat Loss", "Endurance", "Flexibility", "General Fitness"]
|
| 66 |
-
)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
workout_days = st.slider("Workout Days per Week", 2, 7, 4)
|
| 70 |
|
| 71 |
-
st.divider()
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
["No Equipment", "Dumbbells", "Resistance Bands", "Barbell", "Full Gym"]
|
| 78 |
-
)
|
| 79 |
|
| 80 |
-
|
| 81 |
-
"
|
| 82 |
-
["30 mins", "45 mins", "60 mins", "90 mins"]
|
| 83 |
-
)
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
"Diet Preference",
|
| 96 |
-
["Vegetarian", "Non-Vegetarian", "Vegan", "Keto", "No Preference"]
|
| 97 |
-
)
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
|
| 103 |
-
|
| 104 |
-
"Stress Level",
|
| 105 |
-
["Low", "Moderate", "High"]
|
| 106 |
-
)
|
| 107 |
|
| 108 |
-
|
| 109 |
|
| 110 |
-
st.markdown("### β Health Conditions")
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
st.
|
|
|
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
# ------------------ AFTER SUBMISSION ------------------
|
| 120 |
-
|
| 121 |
-
if submitted:
|
| 122 |
-
|
| 123 |
-
if name == "":
|
| 124 |
-
st.error("Please enter your name.")
|
| 125 |
else:
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
st.
|
| 151 |
-
|
| 152 |
-
st.divider()
|
| 153 |
-
|
| 154 |
-
st.markdown("### π Complete Profile Details")
|
| 155 |
|
| 156 |
-
st.write({
|
| 157 |
-
"Name": name,
|
| 158 |
-
"Age": age,
|
| 159 |
-
"Gender": gender,
|
| 160 |
-
"Fitness Level": fitness_level,
|
| 161 |
-
"Goal": primary_goal,
|
| 162 |
-
"Equipment": equipment,
|
| 163 |
-
"Workout Duration": workout_duration,
|
| 164 |
-
"Preferred Time": preferred_time,
|
| 165 |
-
"Diet": diet_type,
|
| 166 |
-
"Stress Level": stress_level,
|
| 167 |
-
"Injuries": injuries,
|
| 168 |
-
"Medications": medications
|
| 169 |
-
})
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import time
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
# -----------------------
|
| 6 |
+
# PAGE CONFIG
|
| 7 |
+
# -----------------------
|
| 8 |
+
st.set_page_config(
|
| 9 |
+
page_title="FitPlan AI",
|
| 10 |
+
page_icon="πͺ",
|
| 11 |
+
layout="wide",
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# -----------------------
|
| 15 |
+
# CUSTOM CSS (MODERN UI)
|
| 16 |
+
# -----------------------
|
| 17 |
st.markdown("""
|
| 18 |
<style>
|
| 19 |
+
|
| 20 |
+
body {
|
| 21 |
+
background-color: #0E1117;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.main-title {
|
| 25 |
+
font-size: 42px;
|
| 26 |
+
font-weight: 700;
|
| 27 |
+
color: white;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.subtitle {
|
| 31 |
+
font-size: 18px;
|
| 32 |
+
color: #A0AEC0;
|
| 33 |
}
|
| 34 |
+
|
| 35 |
+
.card {
|
| 36 |
+
background-color: #1C1F26;
|
| 37 |
padding: 25px;
|
| 38 |
border-radius: 15px;
|
| 39 |
+
box-shadow: 0px 4px 20px rgba(0,0,0,0.4);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
+
|
| 42 |
.stButton>button {
|
| 43 |
+
background: linear-gradient(90deg, #4F46E5, #7C3AED);
|
| 44 |
color: white;
|
| 45 |
border-radius: 10px;
|
| 46 |
+
height: 3em;
|
| 47 |
+
width: 100%;
|
| 48 |
+
font-size: 16px;
|
| 49 |
font-weight: 600;
|
| 50 |
}
|
| 51 |
+
|
| 52 |
.stButton>button:hover {
|
| 53 |
+
background: linear-gradient(90deg, #6366F1, #8B5CF6);
|
| 54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
.plan-box {
|
| 57 |
+
background-color: #1F2937;
|
| 58 |
+
padding: 20px;
|
| 59 |
+
border-radius: 10px;
|
| 60 |
+
margin-bottom: 15px;
|
| 61 |
+
color: white;
|
| 62 |
+
}
|
| 63 |
|
| 64 |
+
</style>
|
| 65 |
+
""", unsafe_allow_html=True)
|
| 66 |
|
|
|
|
| 67 |
|
| 68 |
+
# -----------------------
|
| 69 |
+
# SIDEBAR NAVIGATION
|
| 70 |
+
# -----------------------
|
| 71 |
+
st.sidebar.title("πͺ FitPlan AI")
|
| 72 |
+
page = st.sidebar.radio(
|
| 73 |
+
"Navigate",
|
| 74 |
+
["π Home", "π€ User Profile", "π Fitness Details", "π
Generated Plan"]
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
# -----------------------
|
| 79 |
+
# HOME PAGE
|
| 80 |
+
# -----------------------
|
| 81 |
+
if page == "π Home":
|
| 82 |
+
st.markdown("<div class='main-title'>FitPlan AI</div>", unsafe_allow_html=True)
|
| 83 |
+
st.markdown("<div class='subtitle'>Your Personalized AI Fitness Planner</div>", unsafe_allow_html=True)
|
| 84 |
+
st.write("")
|
| 85 |
+
|
| 86 |
+
st.markdown("""
|
| 87 |
+
<div class='card'>
|
| 88 |
+
<h3 style='color:white;'>Why FitPlan AI?</h3>
|
| 89 |
+
<ul style='color:#A0AEC0;'>
|
| 90 |
+
<li>Personalized workout plans</li>
|
| 91 |
+
<li>AI-powered fitness recommendations</li>
|
| 92 |
+
<li>Structured sets, reps & rest periods</li>
|
| 93 |
+
<li>No expensive personal trainer needed</li>
|
| 94 |
+
</ul>
|
| 95 |
+
</div>
|
| 96 |
+
""", unsafe_allow_html=True)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
# -----------------------
|
| 100 |
+
# USER PROFILE PAGE
|
| 101 |
+
# -----------------------
|
| 102 |
+
elif page == "π€ User Profile":
|
| 103 |
+
|
| 104 |
+
st.markdown("<div class='main-title'>User Profile</div>", unsafe_allow_html=True)
|
| 105 |
+
st.write("")
|
| 106 |
+
|
| 107 |
+
with st.container():
|
| 108 |
+
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 109 |
|
|
|
|
| 110 |
name = st.text_input("Full Name")
|
| 111 |
+
age = st.number_input("Age", min_value=10, max_value=80)
|
| 112 |
+
gender = st.selectbox("Gender", ["Male", "Female", "Other"])
|
| 113 |
+
height = st.number_input("Height (cm)")
|
| 114 |
+
weight = st.number_input("Weight (kg)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
if st.button("Save Profile"):
|
| 117 |
+
st.success("Profile saved successfully!")
|
|
|
|
|
|
|
| 118 |
|
| 119 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
| 120 |
|
|
|
|
| 121 |
|
| 122 |
+
# -----------------------
|
| 123 |
+
# FITNESS DETAILS PAGE
|
| 124 |
+
# -----------------------
|
| 125 |
+
elif page == "π Fitness Details":
|
| 126 |
|
| 127 |
+
st.markdown("<div class='main-title'>Enter Your Fitness Details</div>", unsafe_allow_html=True)
|
| 128 |
+
st.write("")
|
|
|
|
|
|
|
| 129 |
|
| 130 |
+
with st.container():
|
| 131 |
+
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 132 |
|
| 133 |
+
goal = st.selectbox(
|
| 134 |
+
"Fitness Goal",
|
| 135 |
+
["Build Muscle", "Lose Weight", "Improve Cardio", "Increase Flexibility"]
|
| 136 |
+
)
|
| 137 |
|
| 138 |
+
fitness_level = st.selectbox(
|
| 139 |
+
"Fitness Level",
|
| 140 |
+
["Beginner", "Intermediate", "Advanced"]
|
| 141 |
+
)
|
| 142 |
|
| 143 |
+
equipment = st.multiselect(
|
| 144 |
+
"Available Equipment",
|
| 145 |
+
["No Equipment", "Dumbbells", "Barbell", "Resistance Bands", "Gym Access"]
|
| 146 |
+
)
|
| 147 |
|
| 148 |
+
days = st.slider("Workout Days per Week", 1, 7, 3)
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
+
if st.button("Generate Plan"):
|
| 151 |
+
if not equipment:
|
| 152 |
+
st.error("Please select at least one equipment option.")
|
| 153 |
+
else:
|
| 154 |
+
st.session_state["goal"] = goal
|
| 155 |
+
st.session_state["fitness_level"] = fitness_level
|
| 156 |
+
st.session_state["equipment"] = equipment
|
| 157 |
+
st.session_state["days"] = days
|
| 158 |
|
| 159 |
+
with st.spinner("AI is generating your personalized plan..."):
|
| 160 |
+
time.sleep(2)
|
| 161 |
|
| 162 |
+
st.success("Plan Generated! Go to 'Generated Plan' page.")
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 165 |
|
|
|
|
| 166 |
|
| 167 |
+
# -----------------------
|
| 168 |
+
# GENERATED PLAN PAGE
|
| 169 |
+
# -----------------------
|
| 170 |
+
elif page == "π
Generated Plan":
|
| 171 |
|
| 172 |
+
st.markdown("<div class='main-title'>Your Weekly Workout Plan</div>", unsafe_allow_html=True)
|
| 173 |
+
st.write("")
|
| 174 |
|
| 175 |
+
if "goal" not in st.session_state:
|
| 176 |
+
st.warning("Please fill Fitness Details first.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
else:
|
| 178 |
|
| 179 |
+
# MOCK PLAN (Replace with LLM output later)
|
| 180 |
+
plan = {
|
| 181 |
+
"Day 1": [
|
| 182 |
+
"Push-ups β 3 sets Γ 12 reps",
|
| 183 |
+
"Dumbbell Squats β 3 sets Γ 15 reps",
|
| 184 |
+
"Plank β 3 sets Γ 30 sec"
|
| 185 |
+
],
|
| 186 |
+
"Day 2": [
|
| 187 |
+
"Lunges β 3 sets Γ 12 reps",
|
| 188 |
+
"Shoulder Press β 3 sets Γ 10 reps",
|
| 189 |
+
"Jumping Jacks β 3 sets Γ 20 reps"
|
| 190 |
+
],
|
| 191 |
+
"Day 3": [
|
| 192 |
+
"Deadlifts β 3 sets Γ 10 reps",
|
| 193 |
+
"Bicep Curls β 3 sets Γ 12 reps",
|
| 194 |
+
"Mountain Climbers β 3 sets Γ 30 sec"
|
| 195 |
+
]
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
for day, exercises in plan.items():
|
| 199 |
+
st.markdown(f"<div class='plan-box'><h4>{day}</h4>", unsafe_allow_html=True)
|
| 200 |
+
for exercise in exercises:
|
| 201 |
+
st.write(f"β’ {exercise}")
|
| 202 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|