Spaces:
Sleeping
Sleeping
File size: 4,607 Bytes
1f6d7ba 8dedb65 1f6d7ba 7f56c8a b8f77e5 1f6d7ba 8dedb65 2cf4a4b c704836 7f56c8a 2cf4a4b 7f56c8a 850b633 7f56c8a 444c89f 2cf4a4b 444c89f 850b633 2cf4a4b 850b633 2cf4a4b 850b633 7f56c8a 444c89f 7f56c8a 850b633 8dedb65 850b633 2cf4a4b 850b633 8d6f3e2 850b633 8d6f3e2 444c89f 6178398 8e4ec5e 6178398 444c89f 6178398 444c89f 8d6f3e2 6178398 7f56c8a 8d6f3e2 7f56c8a 850b633 8d6f3e2 8dedb65 2cf4a4b 7f56c8a 8dedb65 7f56c8a 8d6f3e2 8dedb65 8d6f3e2 2cf4a4b 8dedb65 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 115 116 117 118 119 120 121 122 123 124 125 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | import streamlit as st
from transformers import pipeline
# ---------------------------------------------------
# PAGE CONFIG
# ---------------------------------------------------
st.set_page_config(page_title="FitPlan AI", layout="centered")
@st.cache_resource
def load_model():
return pipeline(
"text-generation",
model="google/flan-t5-base"
)
generator = load_model()
st.title(" FitPlan AI β User Fitness Profile")
# ---------------------------------------------------
# PERSONAL INFORMATION
# ---------------------------------------------------
st.subheader("π€ Personal Information")
name = st.text_input("Enter Your Name")
st.subheader("Gender")
gender = st.radio(
"",
["Male", "Female"],
horizontal=True,index=0
)
col1, col2 = st.columns(2)
with col1:
height = st.number_input("Height (in cm)", min_value=100, max_value=250)
with col2:
weight = st.number_input("Weight (in kg)", min_value=30, max_value=200)
# ---------------------------------------------------
# BMI CALCULATION
# ---------------------------------------------------
bmi = None
if height > 0 and weight > 0:
height_m = height / 100
bmi = weight / (height_m ** 2)
st.write(f"### π Your BMI: {bmi:.2f}")
def bmi_category(bmi):
if bmi < 18.5:
return "Underweight"
elif 18.5 <= bmi < 25:
return "Normal weight"
elif 25 <= bmi < 30:
return "Overweight"
else:
return "Obese"
# ---------------------------------------------------
# FITNESS GOAL
# ---------------------------------------------------
st.subheader("π― Fitness Goal")
goal = st.selectbox(
"",
[
"Flexible",
"Weight Loss",
"Build Muscle",
"Strength Gaining",
"Abs Building"
]
)
st.subheader("ποΈ Available Equipment")
equipment_map = {}
col1, col2, col3 = st.columns(3)
with col1:
equipment_map["No Equipment"] = st.checkbox("No Equipment")
equipment_map["Pull-up Bar"] = st.checkbox("Pull-up Bar")
equipment_map["Dip Bars"] = st.checkbox("Dip Bars")
equipment_map["Push-up Handles"] = st.checkbox("Push-up Handles")
equipment_map["Dumbbells"] = st.checkbox("Dumbbells")
equipment_map["Adjustable Dumbbells"] = st.checkbox("Adjustable Dumbbells")
with col2:
equipment_map["Barbell"] = st.checkbox("Barbell")
equipment_map["Weight Plates"] = st.checkbox("Weight Plates")
equipment_map["Kettlebells"] = st.checkbox("Kettlebells")
equipment_map["Medicine Ball"] = st.checkbox("Medicine Ball")
equipment_map["Yoga Mat"] = st.checkbox("Yoga Mat")
equipment_map["Resistance Band"] = st.checkbox("Resistance Band")
with col3:
equipment_map["Bosu Ball"] = st.checkbox("Bosu Ball")
equipment_map["Stability Ball"] = st.checkbox("Stability Ball")
equipment_map["Foam Roller"] = st.checkbox("Foam Roller")
equipment_map["Treadmill"] = st.checkbox("Treadmill")
equipment_map["Exercise Bike"] = st.checkbox("Exercise Bike")
equipment_map["Skipping Rope"] = st.checkbox("Skipping Rope")
# Convert selected to list
equipment = [item for item, selected in equipment_map.items() if selected]
# ---------------------------------------------------
# FITNESS LEVEL
# ---------------------------------------------------
st.subheader("π Fitness Level")
fitness_level = st.radio(
"",
["Beginner", "Intermediate", "Advanced"],
horizontal=True
)
if st.button("Submit Profile"):
if not name:
st.error("Please enter your name.")
elif not equipment:
st.error("Please select at least one equipment option.")
elif bmi is None:
st.error("Please enter valid height and weight.")
else:
st.success("β
Profile Submitted Successfully!")
bmi_status = bmi_category(bmi)
equipment_list = ", ".join(equipment)
prompt = f"""
Generate a 5-day structured workout plan.
User Details:
Name: {name}
Gender: {gender}
BMI: {bmi:.2f} ({bmi_status})
Goal: {goal}
Fitness Level: {fitness_level}
Available Equipment: {equipment_list}
Requirements:
- Include warmup
- Include exercises with sets and reps
- Include rest time
- Adjust intensity based on BMI and fitness level
- Keep it structured day-wise
"""
with st.spinner("Generating your AI workout plan..."):
result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
st.subheader("ποΈ Your Personalized Workout Plan")
st.write(result) |