Update src/streamlit_app.py
Browse files- src/streamlit_app.py +13 -15
src/streamlit_app.py
CHANGED
|
@@ -1,28 +1,26 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
"text2text-generation",
|
| 9 |
-
model="google/flan-t5-small" # smaller & safer for HF Spaces
|
| 10 |
-
)
|
| 11 |
-
|
| 12 |
-
generator = 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 |
-
|
| 20 |
-
age = st.number_input("Age", min_value=15, max_value=80, value=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 = (
|
| 28 |
f"Create a {days}-day fitness workout plan for a "
|
|
@@ -32,7 +30,7 @@ if st.button("Generate Fitness Plan"):
|
|
| 32 |
f"Include warm-up, main workout, and cool-down."
|
| 33 |
)
|
| 34 |
|
| 35 |
-
with st.spinner("Generating
|
| 36 |
-
|
| 37 |
st.success("✅ Your Fitness Plan")
|
| 38 |
-
st.write(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
|
| 4 |
+
API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-small"
|
| 5 |
+
headers = {
|
| 6 |
+
"Authorization": f"Bearer {st.secrets['HF_API_TOKEN']}"
|
| 7 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
st.set_page_config(page_title="Fitness Plan AI", layout="centered")
|
| 10 |
|
| 11 |
st.title("🏋️ Fitness Plan AI Generator")
|
| 12 |
st.write("Generate a personalized fitness plan using AI")
|
| 13 |
|
| 14 |
+
age = st.number_input("Age", 15, 80, 22)
|
|
|
|
| 15 |
gender = st.selectbox("Gender", ["Male", "Female"])
|
| 16 |
goal = st.selectbox("Fitness Goal", ["Weight Loss", "Muscle Gain", "General Fitness"])
|
| 17 |
level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
|
| 18 |
days = st.slider("Workout Days per Week", 1, 7, 4)
|
| 19 |
|
| 20 |
+
def query(payload):
|
| 21 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 22 |
+
return response.json()
|
| 23 |
+
|
| 24 |
if st.button("Generate Fitness Plan"):
|
| 25 |
prompt = (
|
| 26 |
f"Create a {days}-day fitness workout plan for a "
|
|
|
|
| 30 |
f"Include warm-up, main workout, and cool-down."
|
| 31 |
)
|
| 32 |
|
| 33 |
+
with st.spinner("Generating plan..."):
|
| 34 |
+
output = query({"inputs": prompt})
|
| 35 |
st.success("✅ Your Fitness Plan")
|
| 36 |
+
st.write(outp
|