MalikShehram commited on
Commit
907e859
Β·
verified Β·
1 Parent(s): 9b4b3f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -27
app.py CHANGED
@@ -3,14 +3,14 @@ import streamlit as st
3
  # Set page configuration
4
  st.set_page_config(
5
  page_title="Personalized Diet Plan",
6
- page_icon="πŸ₯—",
7
  layout="wide",
8
  initial_sidebar_state="expanded",
9
  )
10
 
11
  # Sidebar
12
  st.sidebar.title("User Inputs")
13
- st.sidebar.markdown("Provide your details below to get a personalized diet plan.")
14
 
15
  # User Inputs in Sidebar
16
  age = st.sidebar.number_input("Age (years)", min_value=1, max_value=120, value=25, step=1)
@@ -28,10 +28,10 @@ activity_level = st.sidebar.selectbox(
28
  goal = st.sidebar.radio("Your Goal", ["Lose Weight", "Maintain Weight", "Gain Weight"])
29
 
30
  # Main Content
31
- st.title("πŸ₯— Personalized Diet Plan Generator")
32
- st.markdown("### Get a customized diet plan tailored to your needs!")
33
 
34
- # BMI Calculation and Display
35
  bmi = weight / ((height / 100) ** 2)
36
 
37
  col1, col2 = st.columns(2)
@@ -48,37 +48,51 @@ with col1:
48
 
49
  with col2:
50
  st.image(
51
- "https://images.unsplash.com/photo-1514996937319-344454492b37",
52
- caption="Healthy Eating",
53
  use_column_width=True,
54
  )
55
 
56
- # Function to Generate Diet Plan
57
- def generate_diet_plan(age, bmi, weight, activity_level, goal):
58
- plan = ""
 
 
 
 
59
  if goal == "Lose Weight":
60
- plan = "Focus on a calorie deficit diet. Include lean proteins, whole grains, and plenty of vegetables."
 
 
 
61
  elif goal == "Maintain Weight":
62
- plan = "Stick to a balanced diet with a mix of proteins, carbs, and fats. Stay consistent with your calorie intake."
 
 
 
63
  elif goal == "Gain Weight":
64
- plan = "Increase calorie intake with nutrient-dense foods like nuts, seeds, whole grains, and lean proteins."
 
 
65
 
66
- if activity_level == "Sedentary (little to no exercise)":
67
- plan += " Incorporate at least 30 minutes of physical activity daily."
68
- elif activity_level == "Lightly active (light exercise)":
69
- plan += " Continue light exercises and aim for 5,000 to 7,000 steps per day."
70
- elif activity_level == "Moderately active (moderate exercise)":
71
- plan += " Maintain your moderate exercises and ensure proper hydration."
72
- elif activity_level == "Very active (hard exercise)":
73
- plan += " Ensure high protein intake and post-workout nutrition."
74
 
75
- return plan
76
 
77
- # Generate Diet Plan Button
78
- if st.button("Generate Diet Plan"):
79
- diet_plan = generate_diet_plan(age, bmi, weight, activity_level, goal)
80
- st.subheader("Your Personalized Diet Plan:")
81
- st.write(diet_plan)
 
 
 
 
 
82
 
83
  # Footer
84
  st.markdown(
 
3
  # Set page configuration
4
  st.set_page_config(
5
  page_title="Personalized Diet Plan",
6
+ page_icon="🍎",
7
  layout="wide",
8
  initial_sidebar_state="expanded",
9
  )
10
 
11
  # Sidebar
12
  st.sidebar.title("User Inputs")
13
+ st.sidebar.markdown("Provide your details below to get a personalized meal plan.")
14
 
15
  # User Inputs in Sidebar
16
  age = st.sidebar.number_input("Age (years)", min_value=1, max_value=120, value=25, step=1)
 
28
  goal = st.sidebar.radio("Your Goal", ["Lose Weight", "Maintain Weight", "Gain Weight"])
29
 
30
  # Main Content
31
+ st.title("🍎 Personalized Diet Plan Generator")
32
+ st.markdown("### Get a customized meal plan for breakfast, lunch, and dinner!")
33
 
34
+ # BMI Calculation
35
  bmi = weight / ((height / 100) ** 2)
36
 
37
  col1, col2 = st.columns(2)
 
48
 
49
  with col2:
50
  st.image(
51
+ "https://images.unsplash.com/photo-1585325701955-b26bf045dc12",
52
+ caption="Healthy Eating Choices",
53
  use_column_width=True,
54
  )
55
 
56
+ # Function to Generate Meal Plan
57
+ def generate_meal_plan(age, bmi, activity_level, goal):
58
+ # Base meal components
59
+ breakfast = ["Oats", "Chia seeds", "Almonds", "Greek yogurt", "Banana"]
60
+ lunch = ["Quinoa", "Mixed greens", "Pumpkin seeds", "Grilled chicken", "Avocado"]
61
+ dinner = ["Brown rice", "Steamed broccoli", "Tofu", "Sunflower seeds", "Spinach"]
62
+
63
  if goal == "Lose Weight":
64
+ breakfast = ["Chia pudding", "Berries", "Almond milk"]
65
+ lunch = ["Grilled salmon", "Quinoa", "Steamed vegetables", "Pumpkin seeds"]
66
+ dinner = ["Lentil soup", "Leafy greens", "Sunflower seeds"]
67
+
68
  elif goal == "Maintain Weight":
69
+ breakfast = ["Oats", "Mixed nuts", "Honey", "Greek yogurt"]
70
+ lunch = ["Grilled chicken", "Brown rice", "Steamed broccoli", "Pumpkin seeds"]
71
+ dinner = ["Quinoa bowl", "Avocado", "Tofu", "Spinach", "Sunflower seeds"]
72
+
73
  elif goal == "Gain Weight":
74
+ breakfast = ["Peanut butter toast", "Chia seeds", "Whole milk", "Banana"]
75
+ lunch = ["Steak", "Sweet potatoes", "Avocado", "Mixed greens"]
76
+ dinner = ["Brown rice", "Grilled fish", "Lentils", "Pumpkin seeds", "Olive oil"]
77
 
78
+ # Adjustments based on activity level
79
+ if activity_level in ["Very active (hard exercise)", "Moderately active (moderate exercise)"]:
80
+ breakfast.append("Protein shake")
81
+ lunch.append("Boiled eggs")
82
+ dinner.append("Cottage cheese")
 
 
 
83
 
84
+ return breakfast, lunch, dinner
85
 
86
+ # Generate Meal Plan Button
87
+ if st.button("Generate Meal Plan"):
88
+ breakfast, lunch, dinner = generate_meal_plan(age, bmi, activity_level, goal)
89
+ st.subheader("Your Personalized Meal Plan:")
90
+ st.markdown("#### Breakfast:")
91
+ st.write(", ".join(breakfast))
92
+ st.markdown("#### Lunch:")
93
+ st.write(", ".join(lunch))
94
+ st.markdown("#### Dinner:")
95
+ st.write(", ".join(dinner))
96
 
97
  # Footer
98
  st.markdown(