srustik123 commited on
Commit
1cf42ec
·
verified ·
1 Parent(s): 4645e60

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +139 -1
src/streamlit_app.py CHANGED
@@ -1,4 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # -------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  # HANDLE SUBMISSION
3
  # -------------------------
4
  if submit:
@@ -41,4 +178,5 @@
41
  result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
42
 
43
  st.subheader("🏋️ Your Personalized Workout Plan")
44
- st.write(result)
 
 
1
+ import streamlit as st
2
+
3
+ from transformers import pipeline
4
+
5
+
6
+
7
+ # -------------------------
8
+
9
+ # PAGE CONFIG
10
+
11
+ # -------------------------
12
+
13
+ st.set_page_config(page_title="FitPlan-AI", page_icon="💪")
14
+
15
+
16
+
17
+ # -------------------------
18
+
19
+ # BMI FUNCTIONS
20
+
21
+ # -------------------------
22
+
23
+ def calculate_bmi(weight, height_cm):
24
+
25
+ height_m = height_cm / 100
26
+
27
+ return round(weight / (height_m ** 2), 2)
28
+
29
+
30
+
31
+ def get_category(bmi):
32
+
33
+ if bmi < 18.5:
34
+
35
+ return "Underweight"
36
+
37
+ elif bmi < 24.9:
38
+
39
+ return "Normal"
40
+
41
+ elif bmi < 29.9:
42
+
43
+ return "Overweight"
44
+
45
+ else:
46
+
47
+ return "Obese"
48
+
49
+
50
+
51
+ # -------------------------
52
+
53
+ # LOAD AI MODEL
54
+
55
+ # -------------------------
56
+
57
+ @st.cache_resource
58
+
59
+ def load_model():
60
+
61
+ return pipeline(
62
+
63
+ "text2text-generation", # Correct for FLAN-T5
64
+
65
+ model="google/flan-t5-base"
66
+
67
+ )
68
+
69
+
70
+
71
+ generator = load_model()
72
+
73
+
74
+
75
+ # -------------------------
76
+
77
+ # UI STARTS
78
+
79
  # -------------------------
80
+
81
+ st.title("💪 FitPlan-AI: Personalized Fitness Profile")
82
+
83
+
84
+
85
+ # Form to collect all inputs
86
+
87
+ with st.form("fitness_form"):
88
+
89
+
90
+
91
+ st.subheader("Personal Information")
92
+
93
+ name = st.text_input("Full Name*", placeholder="Enter your name")
94
+
95
+
96
+
97
+ col1, col2 = st.columns(2)
98
+
99
+ with col1:
100
+
101
+ height = st.number_input("Height (cm)*", min_value=1.0, step=0.1)
102
+
103
+ with col2:
104
+
105
+ weight = st.number_input("Weight (kg)*", min_value=1.0, step=0.1)
106
+
107
+
108
+
109
+ st.subheader("Fitness Details")
110
+
111
+ goal = st.selectbox(
112
+
113
+ "Fitness Goal",
114
+
115
+ ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
116
+
117
+ )
118
+
119
+ level = st.radio("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
120
+
121
+ equipment = st.multiselect(
122
+
123
+ "Available Equipment",
124
+
125
+ ["Dumbbells", "Resistance Band", "Yoga Mat", "No Equipment", "Kettlebell", "Pull-up Bar"]
126
+
127
+ )
128
+
129
+
130
+
131
+ # -------------------------
132
+
133
+ # SUBMIT BUTTON AT BOTTOM
134
+
135
+ # -------------------------
136
+
137
+ submit = st.form_submit_button("Submit Profile")
138
+ # -------------------------
139
  # HANDLE SUBMISSION
140
  # -------------------------
141
  if submit:
 
178
  result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
179
 
180
  st.subheader("🏋️ Your Personalized Workout Plan")
181
+ st.write(result)
182
+