srbhavya01 commited on
Commit
07ef3a1
·
verified ·
1 Parent(s): 1ea5222

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -46
app.py CHANGED
@@ -1,75 +1,58 @@
1
  import streamlit as st
 
 
 
2
 
3
- st.set_page_config(page_title="FitPlan AI - BMI Calculator", page_icon="💪")
4
 
5
- st.title("💪 FitPlan AI - Fitness Profile & BMI Calculator")
6
 
7
- st.write("Fill in your details to calculate your BMI and fitness category.")
 
8
 
9
  # -------------------------
10
- # 1. Personal Information
11
  # -------------------------
12
 
13
- name = st.text_input("Enter Your Name *")
 
14
 
15
- height_cm = st.number_input("Enter Height (in centimeters) *", min_value=0.0, format="%.2f")
16
- weight_kg = st.number_input("Enter Weight (in kilograms) *", min_value=0.0, format="%.2f")
17
-
18
- # -------------------------
19
- # 2. Fitness Details
20
- # -------------------------
21
-
22
- st.subheader("Fitness Details")
23
 
24
  goal = st.selectbox(
25
- "Select Your Fitness Goal",
26
  ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
27
  )
28
 
29
  equipment = st.multiselect(
30
- "Available Equipment (Select multiple if available)",
31
- ["Dumbbells", "Resistance Band", "Yoga Mat", "Skipping Rope",
32
- "Weight Plates", "Cycling", "Inclined Bench", "Pullups Bar", "No Equipment"]
33
  )
34
 
35
  fitness_level = st.radio(
36
- "Select Your Fitness Level",
37
  ["Beginner", "Intermediate", "Advanced"]
38
  )
39
 
40
  # -------------------------
41
- # BMI Calculation Function
42
- # -------------------------
43
-
44
- def calculate_bmi(weight, height_cm):
45
- height_m = height_cm / 100 # Convert cm to meters
46
- bmi = weight / (height_m ** 2)
47
- return round(bmi, 2)
48
-
49
- def bmi_category(bmi):
50
- if bmi < 18.5:
51
- return "Underweight"
52
- elif 18.5 <= bmi < 24.9:
53
- return "Normal"
54
- elif 25 <= bmi < 29.9:
55
- return "Overweight"
56
- else:
57
- return "Obese"
58
-
59
- # -------------------------
60
- # Submit Button
61
  # -------------------------
62
 
63
  if st.button("Generate Workout Plan"):
64
 
65
- bmi = calculate_bmi(weight_kg, height_cm)
66
- category = bmi_category(bmi)
 
 
 
 
 
67
 
68
- st.success(f"BMI: {bmi} ({category})")
69
 
70
- workout_plan = generate_5day_plan(
71
- name, bmi, category, fitness_level, equipment
72
- )
73
 
74
- st.subheader("🏋️ Your Personalized Workout Plan")
75
- st.text(workout_plan)
 
1
  import streamlit as st
2
+ from prompt.bmi import calculate_bmi, bmi_category
3
+ from prompt.prompt_builder import build_prompt
4
+ from prompt.generator import load_model, generate_plan
5
 
6
+ st.set_page_config(page_title="FitPlan AI", page_icon="💪")
7
 
8
+ st.title("💪 FitPlan AI - Personalized Workout Generator")
9
 
10
+ # Load model
11
+ tokenizer, model = load_model()
12
 
13
  # -------------------------
14
+ # User Inputs
15
  # -------------------------
16
 
17
+ name = st.text_input("Name")
18
+ gender = st.selectbox("Gender", ["Male", "Female"])
19
 
20
+ height = st.number_input("Height (cm)", min_value=0.0)
21
+ weight = st.number_input("Weight (kg)", min_value=0.0)
 
 
 
 
 
 
22
 
23
  goal = st.selectbox(
24
+ "Fitness Goal",
25
  ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
26
  )
27
 
28
  equipment = st.multiselect(
29
+ "Available Equipment",
30
+ ["Dumbbells", "Resistance Band", "Yoga Mat", "No Equipment"]
 
31
  )
32
 
33
  fitness_level = st.radio(
34
+ "Fitness Level",
35
  ["Beginner", "Intermediate", "Advanced"]
36
  )
37
 
38
  # -------------------------
39
+ # Generate Plan
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  # -------------------------
41
 
42
  if st.button("Generate Workout Plan"):
43
 
44
+ if not name or height <= 0 or weight <= 0:
45
+ st.error("Please fill all fields properly")
46
+ else:
47
+
48
+ prompt, bmi, status = build_prompt(
49
+ name, gender, height, weight, goal, fitness_level, equipment
50
+ )
51
 
52
+ st.write("### 📊 BMI:", round(bmi, 2), "-", status)
53
 
54
+ with st.spinner("Generating your personalized plan..."):
55
+ plan = generate_plan(prompt, tokenizer, model)
 
56
 
57
+ st.success("Your Personalized Workout Plan")
58
+ st.write(plan)