Harry2406 commited on
Commit
42dcdc4
ยท
verified ยท
1 Parent(s): 0dc8057

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +47 -47
src/streamlit_app.py CHANGED
@@ -1,7 +1,13 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
  st.set_page_config(page_title="Fitness Profile", page_icon="๐Ÿ‹๏ธ", layout="centered")
4
-
 
 
 
 
 
 
5
  st.title("๐Ÿ‹๏ธ Personalized Fitness Profile")
6
 
7
  st.markdown("---")
@@ -40,50 +46,44 @@ fitness_level = st.radio(
40
  st.markdown("---")
41
 
42
  # =========================
43
- # 3๏ธโƒฃ Submit Button
44
- # =========================
45
- if st.button("Generate Profile"):
46
-
47
- # =========================
48
- # Validation
49
- # =========================
50
- if name.strip() == "":
51
- st.error("โŒ Name is required.")
52
- elif height_cm <= 0:
53
- st.error("โŒ Height must be greater than zero.")
54
- elif weight_kg <= 0:
55
- st.error("โŒ Weight must be greater than zero.")
56
  else:
57
- # =========================
58
- # BMI Calculation
59
- # =========================
60
- height_m = height_cm / 100 # Convert cm to meters
61
- bmi = weight_kg / (height_m ** 2)
62
- bmi = round(bmi, 2)
63
-
64
- # =========================
65
- # BMI Category
66
- # =========================
67
- if bmi < 18.5:
68
- category = "Underweight"
69
- elif 18.5 <= bmi < 24.9:
70
- category = "Normal"
71
- elif 25 <= bmi < 29.9:
72
- category = "Overweight"
73
- else:
74
- category = "Obese"
75
-
76
- # =========================
77
- # Display Results
78
- # =========================
79
- st.success("โœ… Profile Generated Successfully!")
80
-
81
- st.subheader(f"๐Ÿ‘ค {name}'s Fitness Summary")
82
-
83
- st.write(f"**Height (m):** {round(height_m, 2)} m")
84
- st.write(f"**Weight (kg):** {weight_kg} kg")
85
- st.write(f"**BMI:** {bmi}")
86
- st.write(f"**BMI Category:** {category}")
87
- st.write(f"**Fitness Goal:** {fitness_goal}")
88
- st.write(f"**Fitness Level:** {fitness_level}")
89
- st.write(f"**Available Equipment:** {', '.join(equipment) if equipment else 'None Selected'}")
 
1
  import streamlit as st
2
  from transformers import pipeline
3
  st.set_page_config(page_title="Fitness Profile", page_icon="๐Ÿ‹๏ธ", layout="centered")
4
+ def load_model():
5
+ return pipeline(
6
+ "text-generation",
7
+ model="google/flan-t5-base"
8
+ )
9
+
10
+ generator = load_model()
11
  st.title("๐Ÿ‹๏ธ Personalized Fitness Profile")
12
 
13
  st.markdown("---")
 
46
  st.markdown("---")
47
 
48
  # =========================
49
+ if st.button("Submit Profile"):
50
+
51
+ if not name:
52
+ st.error("Please enter your name.")
53
+
54
+ elif not equipment:
55
+ st.error("Please select at least one equipment option.")
56
+
57
+ elif bmi is None:
58
+ st.error("Please enter valid height and weight.")
59
+
 
 
60
  else:
61
+ st.success("โœ… Profile Submitted Successfully!")
62
+
63
+ bmi_status = bmi_category(bmi)
64
+ equipment_list = ", ".join(equipment)
65
+
66
+ prompt = f"""
67
+ Generate a 5-day structured workout plan.
68
+
69
+ User Details:
70
+ Name: {name}
71
+ Gender: {gender}
72
+ BMI: {bmi:.2f} ({bmi_status})
73
+ Goal: {goal}
74
+ Fitness Level: {fitness_level}
75
+ Available Equipment: {equipment_list}
76
+
77
+ Requirements:
78
+ - Include warmup
79
+ - Include exercises with sets and reps
80
+ - Include rest time
81
+ - Adjust intensity based on BMI and fitness level
82
+ - Keep it structured day-wise
83
+ """
84
+
85
+ with st.spinner("Generating your AI workout plan..."):
86
+ result = generator(prompt, max_new_tokens=400)[0]["generated_text"]
87
+
88
+ st.subheader("๐Ÿ‹๏ธ Your Personalized Workout Plan")
89
+ st.write(result)