import streamlit as st from transformers import pipeline def load_model(): return pipeline( "text-generation", model="google/flan-t5-base" ) generator = load_model() import streamlit as st # 1. Basic Configuration st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered") # 2. Enhanced CSS st.markdown(""" """, unsafe_allow_html=True) # -------------------------------------------------- # UI Header Section # -------------------------------------------------- st.markdown('
💪 FitPlan AI
', unsafe_allow_html=True) st.markdown('Your personalized gym companion
', unsafe_allow_html=True) # -------------------------------------------------- # Fitness Profile Form # -------------------------------------------------- with st.form("fitness_form", clear_on_submit=False): st.markdown('🧍♂️ 1. PERSONAL INFORMATION
', unsafe_allow_html=True) name = st.text_input("Full Name *", placeholder="Enter your full name") col1, col2 = st.columns(2) with col1: height = st.number_input("Height (cm) *", min_value=0.0, step=1.0, value=0.0) with col2: weight = st.number_input("Weight (kg) *", min_value=0.0, step=0.1, value=0.0) st.markdown("🏋️ 2. FITNESS DETAILS
', unsafe_allow_html=True) 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"], default=["No Equipment"]) level = st.radio("Fitness Level", ["Beginner", "Intermediate", "Advanced"], horizontal=True) # Submission Button submit = st.form_submit_button("GENERATE MY PLAN") # -------------------------------------------------- # Logic & Calculation # -------------------------------------------------- if submit: if not name.strip() or height <= 50 or weight <= 10: st.error("🚨 Please provide a valid name, height, and weight.") else: # BMI Calculation height_m = height / 100 bmi = round(weight / (height_m ** 2), 2) if bmi < 18.5: cat, color = "Underweight", "blue" elif 18.5 <= bmi < 25: cat, color = "Normal", "green" elif 25 <= bmi < 30: cat, color = "Overweight", "orange" else: cat, color = "Obese", "red" # Results Display st.balloons() st.success(f"✅ Profile created for {name}") c1, c2 = st.columns(2) with c1: st.metric("Calculated BMI", bmi) with c2: st.markdown(f"### Status: :{color}[{cat}]") st.info(f"*Goal:* {goal} | *Experience:* {level}")