Spaces:
Sleeping
Sleeping
File size: 2,428 Bytes
848cecc 45cabc8 055c690 45cabc8 055c690 45cabc8 055c690 45cabc8 055c690 45cabc8 055c690 45cabc8 055c690 45cabc8 055c690 45cabc8 848cecc 45cabc8 848cecc 45cabc8 1758e56 848cecc 45cabc8 848cecc 45cabc8 848cecc 45cabc8 848cecc 45cabc8 848cecc 45cabc8 848cecc 1758e56 45cabc8 848cecc 45cabc8 055c690 45cabc8 055c690 45cabc8 | 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 | import streamlit as st
st.set_page_config(page_title="FitPlan AI - BMI Calculator", page_icon="๐ช")
st.title("๐ช FitPlan AI - Fitness Profile & BMI Calculator")
st.write("Fill in your details to calculate your BMI and fitness category.")
# -------------------------
# 1. Personal Information
# -------------------------
name = st.text_input("Enter Your Name *")
height_cm = st.number_input("Enter Height (in centimeters) *", min_value=0.0, format="%.2f")
weight_kg = st.number_input("Enter Weight (in kilograms) *", min_value=0.0, format="%.2f")
# -------------------------
# 2. Fitness Details
# -------------------------
st.subheader("Fitness Details")
goal = st.selectbox(
"Select Your Fitness Goal",
["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
)
equipment = st.multiselect(
"Available Equipment (Select multiple if available)",
["Dumbbells", "Resistance Band", "Yoga Mat", "Skipping Rope",
"Weight Plates", "Cycling", "Inclined Bench", "Pullups Bar", "No Equipment"]
)
fitness_level = st.radio(
"Select Your Fitness Level",
["Beginner", "Intermediate", "Advanced"]
)
# -------------------------
# BMI Calculation Function
# -------------------------
def calculate_bmi(weight, height_cm):
height_m = height_cm / 100 # Convert cm to meters
bmi = weight / (height_m ** 2)
return round(bmi, 2)
def bmi_category(bmi):
if bmi < 18.5:
return "Underweight"
elif 18.5 <= bmi < 24.9:
return "Normal"
elif 25 <= bmi < 29.9:
return "Overweight"
else:
return "Obese"
# -------------------------
# Submit Button
# -------------------------
if st.button(" Generate 5-day workout plan"):
# Validation
if not name or height_cm <= 0 or weight_kg <= 0:
st.error("โ Please fill all required fields with valid values!")
else:
bmi = calculate_bmi(weight_kg, height_cm)
category = bmi_category(bmi)
st.success("โ
Calculation Successful!")
st.write(f"### ๐ค Name: {name}")
st.write(f"### ๐ Your BMI: {bmi}")
st.write(f"### ๐ท BMI Category: {category}")
st.write("---")
st.write("### ๐ Fitness Summary")
st.write(f"**Goal:** {goal}")
st.write(f"**Fitness Level:** {fitness_level}")
st.write(f"**Equipment Available:** {', '.join(equipment) if equipment else 'None selected'}") |