js02vel commited on
Commit
a108538
·
verified ·
1 Parent(s): 8c9e059

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- # Submission Button
111
- submit = st.form_submit_button("GENERATE MY PLAN")
112
-
113
- # --------------------------------------------------
114
- # Logic & Calculation
115
- # --------------------------------------------------
116
- if submit:
117
- if not name.strip() or height <= 50 or weight <= 10:
118
- st.error("🚨 Please provide a valid name, height, and weight.")
 
 
119
  else:
120
- # BMI Calculation
121
- height_m = height / 100
122
- bmi = round(weight / (height_m ** 2), 2)
123
-
124
- if bmi < 18.5:
125
- cat, color = "Underweight", "blue"
126
- elif 18.5 <= bmi < 25:
127
- cat, color = "Normal", "green"
128
- elif 25 <= bmi < 30:
129
- cat, color = "Overweight", "orange"
130
- else:
131
- cat, color = "Obese", "red"
132
-
133
- # Results Display
134
- st.balloons()
135
- st.success(f"✅ Profile created for {name}")
136
-
137
- c1, c2 = st.columns(2)
138
- with c1:
139
- st.metric("Calculated BMI", bmi)
140
- with c2:
141
- st.markdown(f"### Status: :{color}[{cat}]")
142
-
143
- st.info(f"*Goal:* {goal} | *Experience:* {level}")
 
 
 
 
 
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