|
import streamlit as st |
|
|
|
|
|
def calculate_bmr(gender, age, weight, height): |
|
if gender == 'Male': |
|
|
|
bmr = 10 * weight + 6.25 * height - 5 * age + 5 |
|
else: |
|
|
|
bmr = 10 * weight + 6.25 * height - 5 * age - 161 |
|
return bmr |
|
|
|
|
|
def calculate_calories(bmr, activity_level): |
|
activity_factor = { |
|
'Sedentary (little or no exercise)': 1.2, |
|
'Lightly Active (light exercise or sports 1-3 days a week)': 1.375, |
|
'Moderately Active (moderate exercise or sports 3-5 days a week)': 1.55, |
|
'Very Active (hard exercise or sports 6-7 days a week)': 1.725, |
|
'Super Active (very hard exercise or physical job)': 1.9 |
|
} |
|
calories = bmr * activity_factor[activity_level] |
|
return calories |
|
|
|
|
|
def generate_diet_plan(calories): |
|
if calories < 1800: |
|
return "Suggested Diet Plan: \n- Breakfast: Oatmeal with fruits \n- Snack: Yogurt with nuts \n- Lunch: Grilled chicken with vegetables \n- Snack: Fruits \n- Dinner: Salmon with steamed broccoli" |
|
elif calories < 2500: |
|
return "Suggested Diet Plan: \n- Breakfast: Scrambled eggs with toast and avocado \n- Snack: Protein shake \n- Lunch: Turkey and quinoa salad \n- Snack: Hummus with carrot sticks \n- Dinner: Grilled steak with sweet potatoes" |
|
else: |
|
return "Suggested Diet Plan: \n- Breakfast: Protein pancakes with berries \n- Snack: Mixed nuts and protein bar \n- Lunch: Grilled chicken with rice and veggies \n- Snack: Cottage cheese with fruit \n- Dinner: Beef stir-fry with vegetables and noodles" |
|
|
|
|
|
st.title("Diet Plan Generator") |
|
|
|
st.markdown(""" |
|
This application generates a personalized diet plan based on your gender, age, weight, height, and activity level. |
|
Please enter your details to get started! |
|
""") |
|
|
|
|
|
st.sidebar.header("Input Your Details") |
|
gender = st.sidebar.selectbox("Gender", ["Male", "Female"]) |
|
age = st.sidebar.number_input("Age", min_value=18, max_value=100, value=25) |
|
weight = st.sidebar.number_input("Weight (in kg)", min_value=30, max_value=200, value=70) |
|
height = st.sidebar.number_input("Height (in cm)", min_value=100, max_value=250, value=170) |
|
|
|
activity_level = st.sidebar.selectbox( |
|
"Activity Level", |
|
['Sedentary (little or no exercise)', 'Lightly Active (light exercise or sports 1-3 days a week)', |
|
'Moderately Active (moderate exercise or sports 3-5 days a week)', |
|
'Very Active (hard exercise or sports 6-7 days a week)', 'Super Active (very hard exercise or physical job)'] |
|
) |
|
|
|
|
|
bmr = calculate_bmr(gender, age, weight, height) |
|
daily_calories = calculate_calories(bmr, activity_level) |
|
|
|
|
|
diet_plan = generate_diet_plan(daily_calories) |
|
|
|
|
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
st.subheader("Your Profile") |
|
st.write(f"**Gender**: {gender}") |
|
st.write(f"**Age**: {age} years") |
|
st.write(f"**Weight**: {weight} kg") |
|
st.write(f"**Height**: {height} cm") |
|
st.write(f"**Activity Level**: {activity_level}") |
|
|
|
with col2: |
|
st.subheader("Your Estimated Daily Caloric Needs") |
|
st.write(f"**BMR (Basal Metabolic Rate)**: {bmr:.2f} kcal/day") |
|
st.write(f"**Total Daily Calories**: {daily_calories:.2f} kcal/day") |
|
|
|
|
|
st.subheader("Suggested Diet Plan:") |
|
st.write(diet_plan) |
|
|