js02vel commited on
Commit
51f28ea
·
verified ·
1 Parent(s): 34dd986

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +101 -35
src/streamlit_app.py CHANGED
@@ -1,36 +1,102 @@
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 "
27
- f"{age}-year-old {gender}. "
28
- f"Goal: {goal}. "
29
- f"Fitness level: {level}. "
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+
3
+ # Page configuration
4
+ st.set_page_config(
5
+ page_title="Fitness Plan AI Generator",
6
+ page_icon="💪",
7
+ layout="centered"
8
+ )
9
+
10
+ # Custom CSS for better UI
11
+ st.markdown("""
12
+ <style>
13
+ .stButton>button {
14
+ width: 100%;
15
+ height: 50px;
16
+ font-size: 18px;
17
+ background: linear-gradient(to right, #1f4e79, #2fa4a9);
18
+ color: white;
19
+ border-radius: 10px;
20
+ }
21
+ </style>
22
+ """, unsafe_allow_html=True)
23
+
24
+ # Title
25
+ st.markdown("## 🧍 Your Fitness Profile")
26
+
27
+ # Fitness Goal
28
+ goal = st.selectbox(
29
+ "Fitness Goal",
30
+ ["Build Muscle", "Lose Weight", "Improve Endurance", "General Fitness"]
31
+ )
32
+
33
+ # Equipment Selection
34
+ st.markdown("### Available Equipment")
35
+ col1, col2, col3 = st.columns(3)
36
+
37
+ with col1:
38
+ dumbbells = st.checkbox("Dumbbells")
39
+ with col2:
40
+ bands = st.checkbox("Resistance Bands")
41
+ with col3:
42
+ no_equipment = st.checkbox("No Equipment")
43
+
44
+ # Fitness Level
45
+ st.markdown("### Fitness Level")
46
+ level = st.radio(
47
+ "",
48
+ ["Beginner", "Intermediate", "Advanced"],
49
+ horizontal=True
50
+ )
51
+
52
+ # Generate Plan Button
53
+ if st.button("Generate Personalised Plan"):
54
+ st.markdown("---")
55
+ st.markdown("## 🏋️ Your Personalised Fitness Plan")
56
+
57
+ equipment = []
58
+ if dumbbells:
59
+ equipment.append("Dumbbells")
60
+ if bands:
61
+ equipment.append("Resistance Bands")
62
+ if no_equipment or not equipment:
63
+ equipment.append("Bodyweight")
64
+
65
+ st.write(f"**Goal:** {goal}")
66
+ st.write(f"**Level:** {level}")
67
+ st.write(f"**Equipment:** {', '.join(equipment)}")
68
+
69
+ st.markdown("### 📅 Weekly Workout Plan")
70
+
71
+ if goal == "Build Muscle":
72
+ st.write("""
73
+ - **Day 1:** Chest & Triceps
74
+ - **Day 2:** Back & Biceps
75
+ - **Day 3:** Legs
76
+ - **Day 4:** Shoulders & Core
77
+ - **Day 5:** Full Body
78
+ - **Day 6:** Active Recovery
79
+ - **Day 7:** Rest
80
+ """)
81
+ elif goal == "Lose Weight":
82
+ st.write("""
83
+ - **Day 1:** Full Body HIIT
84
+ - **Day 2:** Cardio + Core
85
+ - **Day 3:** Strength Training
86
+ - **Day 4:** HIIT
87
+ - **Day 5:** Cardio
88
+ - **Day 6:** Yoga / Stretching
89
+ - **Day 7:** Rest
90
+ """)
91
+ else:
92
+ st.write("""
93
+ - **Day 1:** Full Body
94
+ - **Day 2:** Cardio
95
+ - **Day 3:** Strength
96
+ - **Day 4:** Mobility
97
+ - **Day 5:** Mixed Training
98
+ - **Day 6:** Light Cardio
99
+ - **Day 7:** Rest
100
+ """)
101
+
102
+ st.success("✅ Plan generated successfully!")