srbhavya01 commited on
Commit
b1508b9
ยท
verified ยท
1 Parent(s): 5534731

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +81 -48
src/streamlit_app.py CHANGED
@@ -1,52 +1,85 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
- def load_model():
4
- return pipeline(
5
- "text-generation",
6
- model="google/flan-t5-base"
7
- )
8
-
9
- generator = load_model()
10
-
11
- if st.button("Submit Profile"):
12
-
13
- if not name:
14
- st.error("Please enter your name.")
15
-
16
- elif not equipment:
17
- st.error("Please select at least one equipment option.")
18
-
19
- elif bmi is None:
20
- st.error("Please enter valid height and weight.")
21
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  else:
23
- st.success("โœ… Profile Submitted Successfully!")
24
-
25
- bmi_status = bmi_category(bmi)
26
- equipment_list = ", ".join(equipment)
27
-
28
- prompt = f"""
29
- Generate a 5-day structured workout plan.
30
-
31
- User Details:
32
- Name: {name}
33
- Gender: {gender}
34
- BMI: {bmi:.2f} ({bmi_status})
35
- Goal: {goal}
36
- Fitness Level: {fitness_level}
37
- Available Equipment: {equipment_list}
38
-
39
- Requirements:
40
- - Include warmup
41
- - Include exercises with sets and reps
42
- - Include rest time
43
- - Adjust intensity based on BMI and fitness level
44
- - Keep it structured day-wise
45
- """
46
-
47
- with st.spinner("Generating your AI workout plan..."):
48
- result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
49
-
50
- st.subheader("๐Ÿ‹๏ธ Your Personalized Workout Plan")
51
- st.write(result)
52
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ import streamlit as st
4
+
5
+ st.set_page_config(page_title="FitPlan AI - BMI Calculator", page_icon="๐Ÿ’ช")
6
+
7
+ st.title("๐Ÿ’ช FitPlan AI - Fitness Profile & BMI Calculator")
8
+
9
+ st.write("Fill in your details to calculate your BMI and fitness category.")
10
+
11
+ # -------------------------
12
+ # 1. Personal Information
13
+ # -------------------------
14
+
15
+ name = st.text_input("Enter Your Name *")
16
+
17
+ height_cm = st.number_input("Enter Height (in centimeters) *", min_value=0.0, format="%.2f")
18
+ weight_kg = st.number_input("Enter Weight (in kilograms) *", min_value=0.0, format="%.2f")
19
+
20
+ # -------------------------
21
+ # 2. Fitness Details
22
+ # -------------------------
23
+
24
+ st.subheader("Fitness Details")
25
+
26
+ goal = st.selectbox(
27
+ "Select Your Fitness Goal",
28
+ ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
29
+ )
30
+
31
+ equipment = st.multiselect(
32
+ "Available Equipment (Select multiple if available)",
33
+ ["Dumbbells", "Resistance Band", "Yoga Mat", "No Equipment"]
34
+ )
35
+
36
+ fitness_level = st.radio(
37
+ "Select Your Fitness Level",
38
+ ["Beginner", "Intermediate", "Advanced"]
39
+ )
40
+
41
+ # -------------------------
42
+ # BMI Calculation Function
43
+ # -------------------------
44
+
45
+ def calculate_bmi(weight, height_cm):
46
+ height_m = height_cm / 100 # Convert cm to meters
47
+ bmi = weight / (height_m ** 2)
48
+ return round(bmi, 2)
49
+
50
+ def bmi_category(bmi):
51
+ if bmi < 18.5:
52
+ return "Underweight"
53
+ elif 18.5 <= bmi < 24.9:
54
+ return "Normal"
55
+ elif 25 <= bmi < 29.9:
56
+ return "Overweight"
57
  else:
58
+ return "Obese"
59
+
60
+ # -------------------------
61
+ # Submit Button
62
+ # -------------------------
63
+
64
+ if st.button("Calculate BMI"):
65
+
66
+ # Validation
67
+ if not name or height_cm <= 0 or weight_kg <= 0:
68
+ st.error("โš  Please fill all required fields with valid values!")
69
+ else:
70
+ bmi = calculate_bmi(weight_kg, height_cm)
71
+ category = bmi_category(bmi)
72
+
73
+ st.success("โœ… Calculation Successful!")
74
+
75
+ st.write(f"### ๐Ÿ‘ค Name: {name}")
76
+ st.write(f"### ๐Ÿ“Š Your BMI: {bmi}")
77
+ st.write(f"### ๐Ÿท BMI Category: {category}")
78
+
79
+ st.write("---")
80
+ st.write("### ๐Ÿ‹ Fitness Summary")
81
+ st.write(f"**Goal:** {goal}")
82
+ st.write(f"**Fitness Level:** {fitness_level}")
83
+ st.write(f"**Equipment Available:** {', '.join(equipment) if equipment else 'None selected'}")
84
+
 
 
85