| import streamlit as st |
|
|
| |
| |
| |
| st.set_page_config( |
| page_title="FitPlan AI", |
| page_icon="πͺ", |
| layout="centered" |
| ) |
|
|
| |
| |
| |
| st.markdown(""" |
| <style> |
| .stApp { |
| background: linear-gradient(135deg, #e3f2fd, #f8fbff); |
| } |
| |
| .block-container { |
| background-color: white; |
| padding: 2rem; |
| border-radius: 15px; |
| max-width: 850px; |
| } |
| |
| .stButton > button { |
| width: 100%; |
| height: 3em; |
| border-radius: 8px; |
| background-color: #FF4B4B; |
| color: white; |
| font-size: 16px; |
| border: none; |
| } |
| </style> |
| """, unsafe_allow_html=True) |
|
|
| |
| |
| |
| st.title("πͺ FitPlan AI") |
| st.subheader("Milestone 1: Fitness Profile & BMI Analysis") |
| st.write("Fill in your details to generate your BMI profile.") |
|
|
| |
| |
| |
| with st.form("fitness_form"): |
|
|
| st.header("1οΈβ£ Personal Information") |
|
|
| name = st.text_input("Full Name *") |
|
|
| col1, col2 = st.columns(2) |
| with col1: |
| height = st.number_input( |
| "Height (cm) *", |
| min_value=0.0, |
| step=0.1, |
| format="%.2f" |
| ) |
|
|
| with col2: |
| weight = st.number_input( |
| "Weight (kg) *", |
| min_value=0.0, |
| step=0.1, |
| format="%.2f" |
| ) |
|
|
| st.divider() |
|
|
| st.header("2οΈβ£ Fitness Details") |
|
|
| goal = st.selectbox( |
| "Fitness Goal", |
| ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"] |
| ) |
|
|
| equipment = st.multiselect( |
| "Available Equipment", |
| ["Dumbbells", "Resistance Band", "Yoga Mat", |
| "Kettlebell", "Pull-up Bar", "No Equipment"] |
| ) |
|
|
| level = st.radio( |
| "Fitness Level", |
| ["Beginner", "Intermediate", "Advanced"] |
| ) |
|
|
| submit = st.form_submit_button("Generate Profile") |
|
|
| |
| |
| |
| if submit: |
|
|
| |
| if not name.strip(): |
| st.error("β Please enter your name.") |
| |
| elif height <= 0: |
| st.error("β Height must be greater than 0 cm.") |
| |
| elif weight <= 0: |
| st.error("β Weight must be greater than 0 kg.") |
| |
| else: |
| |
| height_m = height / 100 |
| bmi = weight / (height_m ** 2) |
| bmi = round(bmi, 2) |
|
|
| |
| if bmi < 18.5: |
| category = "Underweight" |
| color = "blue" |
| elif 18.5 <= bmi < 24.9: |
| category = "Normal" |
| color = "green" |
| elif 25 <= bmi < 29.9: |
| category = "Overweight" |
| color = "orange" |
| else: |
| category = "Obese" |
| color = "red" |
|
|
| |
| st.success(f"β
Profile successfully created for {name}!") |
|
|
| colA, colB = st.columns(2) |
|
|
| with colA: |
| st.metric("Your BMI", bmi) |
|
|
| with colB: |
| st.markdown(f"**BMI Category:** :{color}[{category}]") |
|
|
| st.info(f"π― Goal: {goal} | π Level: {level}") |
|
|
| if equipment: |
| st.write("π Available Equipment:", ", ".join(equipment)) |
| else: |
| st.write("π Available Equipment: None selected") |
|
|
|
|