Harry2406 commited on
Commit
edda980
·
verified ·
1 Parent(s): e1cd62f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +57 -32
src/streamlit_app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
- from transformers import pipeline
 
3
 
4
  # =========================
5
  # Page Configuration
@@ -98,49 +99,73 @@ st.markdown("---")
98
  # =========================
99
  # Submit Button
100
  # =========================
101
- if st.button("Submit Profile"):
102
 
 
 
103
  if not name:
 
104
  st.error("Please enter your name.")
 
 
105
 
106
- elif height_cm <= 0 or weight_kg <= 0:
107
  st.error("Please enter valid height and weight.")
108
-
109
  elif not equipment:
110
- st.error("Please select at least one equipment option.")
111
 
 
 
112
  else:
113
- st.success("✅ Profile Submitted Successfully!")
114
 
 
 
115
  bmi_status = bmi_category(bmi)
116
- equipment_list = ", ".join(equipment)
117
 
 
 
118
  prompt = f"""
119
- Generate a 5-day structured workout plan.
120
-
121
- User Details:
122
- Name: {name}
123
- Gender: {gender}
124
- BMI: {bmi:.2f} ({bmi_status})
125
- Goal: {fitness_goal}
126
- Fitness Level: {fitness_level}
127
- Available Equipment: {equipment_list}
128
-
129
- Requirements:
130
- - Include warmup
131
- - Include exercises with sets and reps
132
- - Include rest time
133
- - Adjust intensity based on BMI and fitness level
134
- - Keep it structured day-wise
135
- """
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  with st.spinner("Generating your AI workout plan..."):
138
- result = generator(
139
- prompt,
140
- max_new_tokens=400,
141
- do_sample=True,
142
- temperature=0.7
143
- )[0]["generated_text"]
144
-
145
- st.subheader("🏋️ Your Personalized Workout Plan")
 
 
 
 
 
 
 
 
 
 
 
146
  st.write(result)
 
 
1
  import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+ import torch
4
 
5
  # =========================
6
  # Page Configuration
 
99
  # =========================
100
  # Submit Button
101
  # =========================
102
+ # SUBMIT BUTTON
103
 
104
+ if st.button(" Submit Profile"):
105
+
106
  if not name:
107
+
108
  st.error("Please enter your name.")
109
+
110
+ elif height <= 0 or weight <= 0:
111
 
 
112
  st.error("Please enter valid height and weight.")
113
+
114
  elif not equipment:
 
115
 
116
+ st.error("Please select at least one equipment option.")
117
+
118
  else:
 
119
 
120
+ st.success(" Profile Submitted Successfully!")
121
+
122
  bmi_status = bmi_category(bmi)
 
123
 
124
+ equipment_list = ", ".join(equipment)
125
+
126
  prompt = f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
+ You are a certified professional fitness trainer.
129
+
130
+ Create a detailed 5-day workout plan.
131
+
132
+ User Information:
133
+
134
+ - Gender: {gender}
135
+
136
+ - BMI: {bmi:.2f} ({bmi_status})
137
+
138
+ - Goal: {goal}
139
+
140
+ - Fitness Level: {fitness_level}
141
+
142
+ - Equipment Available: {equipment_list}
143
+
144
+ Start directly with:
145
+
146
+ Day 1:
147
+
148
+ """
149
+
150
  with st.spinner("Generating your AI workout plan..."):
151
+
152
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
153
+
154
+ outputs = model.generate(
155
+
156
+ **inputs,
157
+
158
+ max_new_tokens=900,
159
+
160
+ temperature=0.7,
161
+
162
+ do_sample=True
163
+
164
+ )
165
+
166
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
167
+
168
+ st.subheader(" Your Personalized Workout Plan")
169
+
170
  st.write(result)
171
+