Update src/streamlit_app.py
Browse files- src/streamlit_app.py +49 -32
src/streamlit_app.py
CHANGED
|
@@ -1,8 +1,14 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
# 1. Basic Configuration
|
| 4 |
st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered")
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# 2. Enhanced CSS
|
| 7 |
st.markdown("""
|
| 8 |
<style>
|
|
@@ -110,34 +116,45 @@ with st.form("fitness_form", clear_on_submit=False):
|
|
| 110 |
# Submission Button
|
| 111 |
submit = st.form_submit_button("GENERATE MY PLAN")
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
else:
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
with
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
# 1. Basic Configuration
|
| 4 |
st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered")
|
| 5 |
+
def load_model():
|
| 6 |
+
return pipeline(
|
| 7 |
+
"text-generation",
|
| 8 |
+
model="google/flan-t5-base"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
generator = load_model()
|
| 12 |
# 2. Enhanced CSS
|
| 13 |
st.markdown("""
|
| 14 |
<style>
|
|
|
|
| 116 |
# Submission Button
|
| 117 |
submit = st.form_submit_button("GENERATE MY PLAN")
|
| 118 |
|
| 119 |
+
if st.button("🚀 Submit Profile"):
|
| 120 |
+
|
| 121 |
+
if not name:
|
| 122 |
+
st.error("Please enter your name.")
|
| 123 |
+
|
| 124 |
+
elif height <= 0 or weight <= 0:
|
| 125 |
+
st.error("Please enter valid height and weight.")
|
| 126 |
+
|
| 127 |
+
elif not equipment:
|
| 128 |
+
st.error("Please select at least one equipment option.")
|
| 129 |
+
|
| 130 |
else:
|
| 131 |
+
st.success("✅ Profile Submitted Successfully!")
|
| 132 |
+
|
| 133 |
+
bmi_status = bmi_category(bmi)
|
| 134 |
+
equipment_list = ", ".join(equipment)
|
| 135 |
+
|
| 136 |
+
prompt = f"""
|
| 137 |
+
Generate a 5-day structured workout plan.
|
| 138 |
+
|
| 139 |
+
User Details:
|
| 140 |
+
Name: {name}
|
| 141 |
+
Gender: {gender}
|
| 142 |
+
BMI: {bmi:.2f} ({bmi_status})
|
| 143 |
+
Goal: {goal}
|
| 144 |
+
Fitness Level: {fitness_level}
|
| 145 |
+
Available Equipment: {equipment_list}
|
| 146 |
+
|
| 147 |
+
Requirements:
|
| 148 |
+
- Include warmup
|
| 149 |
+
- Include exercises with sets and reps
|
| 150 |
+
- Include rest time
|
| 151 |
+
- Adjust intensity based on BMI and fitness level
|
| 152 |
+
- Keep it structured day-wise
|
| 153 |
+
"""
|
| 154 |
+
|
| 155 |
+
with st.spinner("Generating your AI workout plan..."):
|
| 156 |
+
response = generator(prompt, max_new_tokens=400)
|
| 157 |
+
result = response[0]["generated_text"]
|
| 158 |
+
|
| 159 |
+
st.subheader("🏋️ Your Personalized Workout Plan")
|
| 160 |
+
st.write(result)
|