Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +40 -7
src/streamlit_app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
def calculate_bmi(weight, height_cm):
|
| 5 |
# Convert height from cm to meters
|
|
@@ -21,13 +20,47 @@ def get_category(bmi):
|
|
| 21 |
# App UI
|
| 22 |
st.set_page_config(page_title="FitPlan-AI", page_icon="💪")
|
| 23 |
st.title("💪 FitPlan-AI: Personalized Fitness Profile")
|
| 24 |
-
|
| 25 |
-
return pipeline(
|
| 26 |
-
"text-generation",
|
| 27 |
-
model="google/flan-t5-base"
|
| 28 |
-
)
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
with st.form("fitness_form"):
|
| 33 |
st.header("Personal Information")
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
def calculate_bmi(weight, height_cm):
|
| 4 |
# Convert height from cm to meters
|
|
|
|
| 20 |
# App UI
|
| 21 |
st.set_page_config(page_title="FitPlan-AI", page_icon="💪")
|
| 22 |
st.title("💪 FitPlan-AI: Personalized Fitness Profile")
|
| 23 |
+
if st.button("Submit Profile"):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
if not name:
|
| 26 |
+
st.error("Please enter your name.")
|
| 27 |
+
|
| 28 |
+
elif not equipment:
|
| 29 |
+
st.error("Please select at least one equipment option.")
|
| 30 |
+
|
| 31 |
+
elif bmi is None:
|
| 32 |
+
st.error("Please enter valid height and weight.")
|
| 33 |
+
|
| 34 |
+
else:
|
| 35 |
+
st.success("✅ Profile Submitted Successfully!")
|
| 36 |
+
|
| 37 |
+
bmi_status = bmi_category(bmi)
|
| 38 |
+
equipment_list = ", ".join(equipment)
|
| 39 |
+
|
| 40 |
+
prompt = f"""
|
| 41 |
+
Generate a 5-day structured workout plan.
|
| 42 |
+
|
| 43 |
+
User Details:
|
| 44 |
+
Name: {name}
|
| 45 |
+
Gender: {gender}
|
| 46 |
+
BMI: {bmi:.2f} ({bmi_status})
|
| 47 |
+
Goal: {goal}
|
| 48 |
+
Fitness Level: {fitness_level}
|
| 49 |
+
Available Equipment: {equipment_list}
|
| 50 |
+
|
| 51 |
+
Requirements:
|
| 52 |
+
- Include warmup
|
| 53 |
+
- Include exercises with sets and reps
|
| 54 |
+
- Include rest time
|
| 55 |
+
- Adjust intensity based on BMI and fitness level
|
| 56 |
+
- Keep it structured day-wise
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
with st.spinner("Generating your AI workout plan..."):
|
| 60 |
+
result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
|
| 61 |
+
|
| 62 |
+
st.subheader("🏋️ Your Personalized Workout Plan")
|
| 63 |
+
st.write(result)
|
| 64 |
|
| 65 |
with st.form("fitness_form"):
|
| 66 |
st.header("Personal Information")
|