Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +13 -14
src/streamlit_app.py
CHANGED
|
@@ -8,12 +8,11 @@ st.set_page_config(page_title="FitPlan AI", layout="centered")
|
|
| 8 |
# ---------------------------------------------------
|
| 9 |
@st.cache_resource
|
| 10 |
def load_model():
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
)
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
# ---------------------------------------------------
|
| 19 |
# TITLE
|
|
@@ -182,14 +181,14 @@ Day 1:
|
|
| 182 |
"""
|
| 183 |
|
| 184 |
with st.spinner("Generating your AI workout plan..."):
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
| 191 |
|
| 192 |
-
|
| 193 |
|
| 194 |
-
st.subheader("🏋️ Your Personalized Workout Plan")
|
| 195 |
-
st.write(result)
|
|
|
|
| 8 |
# ---------------------------------------------------
|
| 9 |
@st.cache_resource
|
| 10 |
def load_model():
|
| 11 |
+
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-base")
|
| 12 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-base")
|
| 13 |
+
return tokenizer, model
|
|
|
|
| 14 |
|
| 15 |
+
tokenizer, model = load_model()
|
| 16 |
|
| 17 |
# ---------------------------------------------------
|
| 18 |
# TITLE
|
|
|
|
| 181 |
"""
|
| 182 |
|
| 183 |
with st.spinner("Generating your AI workout plan..."):
|
| 184 |
+
inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
|
| 185 |
+
|
| 186 |
+
outputs = model.generate(
|
| 187 |
+
**inputs,
|
| 188 |
+
max_new_tokens=400,
|
| 189 |
+
temperature=0.7,
|
| 190 |
+
do_sample=True
|
| 191 |
+
)
|
| 192 |
|
| 193 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
|
| 194 |
|
|
|
|
|
|