Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,56 +42,54 @@ def generate_menu(data, season, sub_category_pref, outings):
|
|
| 42 |
|
| 43 |
# Function to calculate BMI and recommend diet for adults
|
| 44 |
def bmi_insights(weight, height_cm):
|
| 45 |
-
# Convert height from cm to meters
|
| 46 |
height_m = height_cm / 100
|
| 47 |
bmi = weight / (height_m ** 2)
|
| 48 |
|
| 49 |
if bmi < 18.5:
|
| 50 |
-
return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial.
|
| 51 |
elif 18.5 <= bmi < 24.9:
|
| 52 |
-
return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet
|
| 53 |
elif 25 <= bmi < 29.9:
|
| 54 |
-
return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight.
|
| 55 |
else:
|
| 56 |
-
return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods
|
| 57 |
|
| 58 |
# Function to provide general diet recommendation for infants
|
| 59 |
def infant_diet_recommendation():
|
| 60 |
return (
|
| 61 |
"For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
|
| 62 |
"Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
|
| 63 |
-
"Ensure a variety of textures as they grow and introduce protein-rich foods, like pureed meat or lentils. "
|
| 64 |
"Consult with your pediatrician for more personalized advice."
|
| 65 |
)
|
| 66 |
|
| 67 |
-
# Function to provide
|
| 68 |
def medical_condition_recommendation(condition):
|
| 69 |
recommendations = {
|
| 70 |
-
"Diabetes": "
|
| 71 |
-
"Celiac Disease": "
|
| 72 |
-
"Hypertension": "
|
| 73 |
-
"Heart Disease": "
|
| 74 |
-
"Obesity": "
|
| 75 |
-
"Cholesterol Disorders": "
|
| 76 |
-
"
|
| 77 |
-
"
|
| 78 |
-
"Peptic Ulcers": "
|
| 79 |
-
"
|
| 80 |
-
"
|
| 81 |
-
"
|
| 82 |
-
"
|
| 83 |
-
"
|
| 84 |
-
"
|
| 85 |
-
"
|
| 86 |
-
"
|
| 87 |
-
"
|
| 88 |
-
"
|
| 89 |
-
"
|
| 90 |
-
"
|
| 91 |
-
"
|
|
|
|
| 92 |
}
|
| 93 |
-
|
| 94 |
-
return recommendations.get(condition, "Please consult a healthcare professional for personalized advice.")
|
| 95 |
|
| 96 |
# Main workflow
|
| 97 |
def main():
|
|
@@ -123,26 +121,26 @@ def main():
|
|
| 123 |
st.sidebar.success(bmi_message)
|
| 124 |
|
| 125 |
# Dropdown for selecting medical condition(s)
|
| 126 |
-
st.sidebar.header("Do you have any of the following medical conditions?")
|
| 127 |
medical_condition = st.sidebar.selectbox(
|
| 128 |
-
"Select
|
| 129 |
-
"Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
|
| 130 |
-
"Cholesterol Disorders", "
|
| 131 |
-
"
|
| 132 |
-
"
|
| 133 |
-
"
|
| 134 |
]
|
| 135 |
)
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
|
|
|
| 146 |
season = st.selectbox("Select the current season", ["Summer", "Winter"])
|
| 147 |
|
| 148 |
outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0)
|
|
|
|
| 42 |
|
| 43 |
# Function to calculate BMI and recommend diet for adults
|
| 44 |
def bmi_insights(weight, height_cm):
|
|
|
|
| 45 |
height_m = height_cm / 100
|
| 46 |
bmi = weight / (height_m ** 2)
|
| 47 |
|
| 48 |
if bmi < 18.5:
|
| 49 |
+
return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial."
|
| 50 |
elif 18.5 <= bmi < 24.9:
|
| 51 |
+
return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet."
|
| 52 |
elif 25 <= bmi < 29.9:
|
| 53 |
+
return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight."
|
| 54 |
else:
|
| 55 |
+
return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods and lean proteins is recommended."
|
| 56 |
|
| 57 |
# Function to provide general diet recommendation for infants
|
| 58 |
def infant_diet_recommendation():
|
| 59 |
return (
|
| 60 |
"For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
|
| 61 |
"Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
|
|
|
|
| 62 |
"Consult with your pediatrician for more personalized advice."
|
| 63 |
)
|
| 64 |
|
| 65 |
+
# Function to provide dietary recommendations based on medical conditions
|
| 66 |
def medical_condition_recommendation(condition):
|
| 67 |
recommendations = {
|
| 68 |
+
"Diabetes": "A low-carb diet is essential. Focus on fiber-rich vegetables, lean proteins, and healthy fats. Avoid sugary foods.",
|
| 69 |
+
"Celiac Disease": "Avoid gluten-containing foods like wheat, barley, and rye. Focus on gluten-free grains, fruits, vegetables, and lean proteins.",
|
| 70 |
+
"Hypertension": "Limit salt intake. Incorporate potassium-rich foods such as bananas, spinach, and potatoes. A heart-healthy diet with lean proteins is ideal.",
|
| 71 |
+
"Heart Disease": "Consume a heart-healthy diet rich in omega-3 fatty acids, vegetables, and whole grains. Limit saturated fats and processed foods.",
|
| 72 |
+
"Obesity": "Focus on a calorie-restricted diet, prioritizing vegetables, lean meats, and whole grains. Avoid sugary snacks and drinks.",
|
| 73 |
+
"Cholesterol Disorders": "Eat foods rich in fiber, such as oats, fruits, and vegetables. Limit saturated fats and trans fats.",
|
| 74 |
+
"IBS": "Incorporate fiber-rich foods like oats and vegetables. Avoid foods that cause bloating, such as beans, cabbage, and onions.",
|
| 75 |
+
"GERD": "Avoid acidic and spicy foods, caffeine, and alcohol. Focus on bland, easy-to-digest meals like rice, oatmeal, and non-citrus fruits.",
|
| 76 |
+
"Peptic Ulcers": "Avoid spicy, fatty, and acidic foods. Focus on bland foods like rice, oatmeal, and non-citrus fruits.",
|
| 77 |
+
"Gout": "Limit foods high in purines, such as red meat, shellfish, and alcohol. Focus on low-fat dairy, fruits, and vegetables.",
|
| 78 |
+
"Lactose Intolerance": "Avoid dairy products or choose lactose-free alternatives. Incorporate plant-based sources of calcium.",
|
| 79 |
+
"Kidney Disease": "Reduce sodium, potassium, and phosphorus intake. Focus on lean proteins and avoid processed foods.",
|
| 80 |
+
"Hypothyroidism": "Increase iodine-rich foods like seaweed, eggs, and dairy. Focus on vegetables and lean proteins.",
|
| 81 |
+
"Anemia": "Focus on iron-rich foods such as red meat, spinach, and beans. Pair with vitamin C-rich foods for better absorption.",
|
| 82 |
+
"Food Allergies": "Avoid allergenic foods like peanuts, tree nuts, dairy, eggs, shellfish, and others. Focus on a balanced, allergy-free diet.",
|
| 83 |
+
"Acid Reflux": "Avoid acidic and spicy foods. Incorporate alkaline foods like bananas, melons, and oatmeal.",
|
| 84 |
+
"Crohn's Disease": "Focus on low-fiber foods and avoid spicy, fatty, and acidic foods. Prioritize lean meats and easy-to-digest grains.",
|
| 85 |
+
"Osteoporosis": "Ensure adequate calcium and vitamin D intake through dairy or fortified alternatives. Incorporate weight-bearing exercises.",
|
| 86 |
+
"Autoimmune Diseases": "A diet rich in anti-inflammatory foods like leafy greens, berries, nuts, and fatty fish is ideal.",
|
| 87 |
+
"Migraines": "Avoid foods that trigger migraines, such as chocolate, caffeine, and aged cheeses. Focus on magnesium-rich foods.",
|
| 88 |
+
"PCOS": "Focus on a low-glycemic index diet with plenty of fruits, vegetables, and lean proteins. Limit processed sugars.",
|
| 89 |
+
"CFS": "A balanced diet with adequate calories and nutrients is essential. Focus on anti-inflammatory foods and avoid refined sugars.",
|
| 90 |
+
"Mental Health": "Focus on omega-3 fatty acids, whole grains, fruits, and vegetables. Avoid processed foods and sugar."
|
| 91 |
}
|
| 92 |
+
return recommendations.get(condition, "No specific recommendations available.")
|
|
|
|
| 93 |
|
| 94 |
# Main workflow
|
| 95 |
def main():
|
|
|
|
| 121 |
st.sidebar.success(bmi_message)
|
| 122 |
|
| 123 |
# Dropdown for selecting medical condition(s)
|
|
|
|
| 124 |
medical_condition = st.sidebar.selectbox(
|
| 125 |
+
"Select any medical condition", [
|
| 126 |
+
"None", "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
|
| 127 |
+
"Cholesterol Disorders", "IBS", "GERD", "Peptic Ulcers", "Gout", "Lactose Intolerance",
|
| 128 |
+
"Kidney Disease", "Hypothyroidism", "Anemia", "Food Allergies", "Acid Reflux",
|
| 129 |
+
"Crohn's Disease", "Osteoporosis", "Autoimmune Diseases", "Migraines", "PCOS",
|
| 130 |
+
"CFS", "Mental Health"
|
| 131 |
]
|
| 132 |
)
|
| 133 |
|
| 134 |
+
if medical_condition != "None":
|
| 135 |
+
condition_recommendation = medical_condition_recommendation(medical_condition)
|
| 136 |
+
st.sidebar.write(condition_recommendation)
|
| 137 |
|
| 138 |
+
# Google Drive file URL
|
| 139 |
+
file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file link
|
| 140 |
+
data = load_data(file_url)
|
| 141 |
|
| 142 |
+
# Main menu generation section (for Adults)
|
| 143 |
+
if category == "Adult":
|
| 144 |
season = st.selectbox("Select the current season", ["Summer", "Winter"])
|
| 145 |
|
| 146 |
outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0)
|