import streamlit as st # -------------------------------------------------- # Page Configuration # -------------------------------------------------- st.set_page_config( page_title="FitPlan AI", page_icon="💪", layout="centered" ) # -------------------------------------------------- # Custom CSS (HF Compatible + Visible UI) # -------------------------------------------------- st.markdown(""" """, unsafe_allow_html=True) # -------------------------------------------------- # Title Section # -------------------------------------------------- st.title("💪 FitPlan AI") st.subheader("Milestone 1: Fitness Profile & BMI Analysis") st.write("Enter your details to calculate BMI and generate your fitness profile.") # -------------------------------------------------- # Fitness Profile Form # -------------------------------------------------- with st.form("fitness_form"): # -------- Section 1 -------- 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) with col2: weight = st.number_input("Weight (kg) *", min_value=0.0, step=0.1) st.divider() # -------- Section 2 -------- 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") # -------------------------------------------------- # Processing & Output # -------------------------------------------------- if submit: # -------- Validation -------- if not name.strip(): st.error("⚠ Please enter your name.") elif height <= 0 or weight <= 0: st.error("⚠ Height and weight must be greater than zero.") else: # -------- BMI Calculation -------- height_m = height / 100 bmi = round(weight / (height_m ** 2), 2) # -------- BMI Classification -------- if bmi < 18.5: category = "Underweight" color = "blue" progress = bmi / 18.5 elif 18.5 <= bmi < 24.9: category = "Normal" color = "green" progress = bmi / 24.9 elif 25 <= bmi < 29.9: category = "Overweight" color = "orange" progress = bmi / 29.9 else: category = "Obese" color = "red" progress = 1.0 # -------- Results Section -------- st.success(f"✅ Profile created successfully for **{name}**") colA, colB = st.columns(2) with colA: st.metric("Your BMI", bmi) with colB: st.markdown(f"**BMI Category:** :{color}[{category}]") # -------- BMI Progress Bar -------- st.markdown("### 📊 BMI Progress Indicator") st.progress(min(progress, 1.0)) # -------- Summary -------- st.info(f"🎯 Goal: {goal} | 📈 Level: {level}") if equipment: st.write("🧰 Equipment:", ", ".join(equipment)) else: st.write("🧰 Equipment: No equipment selected")