Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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("
|
| 32 |
-
st.markdown("### Get a customized
|
| 33 |
|
| 34 |
-
# BMI Calculation
|
| 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-
|
| 52 |
-
caption="Healthy Eating",
|
| 53 |
use_column_width=True,
|
| 54 |
)
|
| 55 |
|
| 56 |
-
# Function to Generate
|
| 57 |
-
def
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
if goal == "Lose Weight":
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
elif goal == "Maintain Weight":
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
| 63 |
elif goal == "Gain Weight":
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 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
|
| 76 |
|
| 77 |
-
# Generate
|
| 78 |
-
if st.button("Generate
|
| 79 |
-
|
| 80 |
-
st.subheader("Your Personalized
|
| 81 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|