Update app.py
Browse files
app.py
CHANGED
|
@@ -1,2 +1,51 @@
|
|
| 1 |
import os
|
| 2 |
-
import request
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import request
|
| 3 |
+
import
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
st.set_page{
|
| 6 |
+
def load_model():
|
| 7 |
+
return pipeline(
|
| 8 |
+
"text-generation",
|
| 9 |
+
model="google/flan-t5-base"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
generator = load_model()
|
| 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)
|