Update src/streamlit_app.py
Browse files- src/streamlit_app.py +34 -12
src/streamlit_app.py
CHANGED
|
@@ -1,16 +1,38 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
st.write("You selected:", goal)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load model
|
| 5 |
+
@st.cache_resource
|
| 6 |
+
def load_model():
|
| 7 |
+
return pipeline(
|
| 8 |
+
"text2text-generation",
|
| 9 |
+
model="google/flan-t5-base"
|
| 10 |
+
)
|
| 11 |
|
| 12 |
+
model = load_model()
|
| 13 |
+
|
| 14 |
+
st.set_page_config(page_title="Fitness Plan AI", layout="centered")
|
| 15 |
+
|
| 16 |
+
st.title("🏋️ Fitness Plan AI Generator")
|
| 17 |
+
st.write("Generate a personalized fitness plan using AI")
|
| 18 |
+
|
| 19 |
+
# User inputs
|
| 20 |
+
age = st.number_input("Age", 15, 80, 22)
|
| 21 |
+
gender = st.selectbox("Gender", ["Male", "Female"])
|
| 22 |
+
goal = st.selectbox("Fitness Goal", ["Weight Loss", "Muscle Gain", "General Fitness"])
|
| 23 |
+
level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
|
| 24 |
+
days = st.slider("Workout Days per Week", 1, 7, 4)
|
| 25 |
+
|
| 26 |
+
if st.button("Generate Fitness Plan"):
|
| 27 |
+
prompt = f"""
|
| 28 |
+
Create a {days}-day fitness plan for a {age}-year-old {gender}.
|
| 29 |
+
Goal: {goal}
|
| 30 |
+
Level: {level}
|
| 31 |
+
Include warm-up, main workout, and cool-down.
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
with st.spinner("Generating plan..."):
|
| 35 |
+
output = model(prompt, max_length=300)
|
| 36 |
+
st.success("Your Fitness Plan:")
|
| 37 |
+
st.write(output[0]['generated_text'])
|
| 38 |
|
|
|