Update src/streamlit_app.py
Browse files- src/streamlit_app.py +47 -47
src/streamlit_app.py
CHANGED
|
@@ -1,7 +1,13 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
st.set_page_config(page_title="Fitness Profile", page_icon="๐๏ธ", layout="centered")
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
st.title("๐๏ธ Personalized Fitness Profile")
|
| 6 |
|
| 7 |
st.markdown("---")
|
|
@@ -40,50 +46,44 @@ fitness_level = st.radio(
|
|
| 40 |
st.markdown("---")
|
| 41 |
|
| 42 |
# =========================
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
if
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
elif weight_kg <= 0:
|
| 55 |
-
st.error("โ Weight must be greater than zero.")
|
| 56 |
else:
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
st.
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
st.
|
| 85 |
-
st.write(
|
| 86 |
-
st.write(f"**BMI Category:** {category}")
|
| 87 |
-
st.write(f"**Fitness Goal:** {fitness_goal}")
|
| 88 |
-
st.write(f"**Fitness Level:** {fitness_level}")
|
| 89 |
-
st.write(f"**Available Equipment:** {', '.join(equipment) if equipment else 'None Selected'}")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
st.set_page_config(page_title="Fitness Profile", page_icon="๐๏ธ", layout="centered")
|
| 4 |
+
def load_model():
|
| 5 |
+
return pipeline(
|
| 6 |
+
"text-generation",
|
| 7 |
+
model="google/flan-t5-base"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
generator = load_model()
|
| 11 |
st.title("๐๏ธ Personalized Fitness Profile")
|
| 12 |
|
| 13 |
st.markdown("---")
|
|
|
|
| 46 |
st.markdown("---")
|
| 47 |
|
| 48 |
# =========================
|
| 49 |
+
if st.button("Submit Profile"):
|
| 50 |
+
|
| 51 |
+
if not name:
|
| 52 |
+
st.error("Please enter your name.")
|
| 53 |
+
|
| 54 |
+
elif not equipment:
|
| 55 |
+
st.error("Please select at least one equipment option.")
|
| 56 |
+
|
| 57 |
+
elif bmi is None:
|
| 58 |
+
st.error("Please enter valid height and weight.")
|
| 59 |
+
|
|
|
|
|
|
|
| 60 |
else:
|
| 61 |
+
st.success("โ
Profile Submitted Successfully!")
|
| 62 |
+
|
| 63 |
+
bmi_status = bmi_category(bmi)
|
| 64 |
+
equipment_list = ", ".join(equipment)
|
| 65 |
+
|
| 66 |
+
prompt = f"""
|
| 67 |
+
Generate a 5-day structured workout plan.
|
| 68 |
+
|
| 69 |
+
User Details:
|
| 70 |
+
Name: {name}
|
| 71 |
+
Gender: {gender}
|
| 72 |
+
BMI: {bmi:.2f} ({bmi_status})
|
| 73 |
+
Goal: {goal}
|
| 74 |
+
Fitness Level: {fitness_level}
|
| 75 |
+
Available Equipment: {equipment_list}
|
| 76 |
+
|
| 77 |
+
Requirements:
|
| 78 |
+
- Include warmup
|
| 79 |
+
- Include exercises with sets and reps
|
| 80 |
+
- Include rest time
|
| 81 |
+
- Adjust intensity based on BMI and fitness level
|
| 82 |
+
- Keep it structured day-wise
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
with st.spinner("Generating your AI workout plan..."):
|
| 86 |
+
result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
|
| 87 |
+
|
| 88 |
+
st.subheader("๐๏ธ Your Personalized Workout Plan")
|
| 89 |
+
st.write(result)
|
|
|
|
|
|
|
|
|
|
|
|