SanaAdeel commited on
Commit
e61982b
·
verified ·
1 Parent(s): 5143f2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -18
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  import pandas as pd
3
  import gdown
4
  from PIL import Image
5
- import random
6
 
7
  # Function to load data from Google Drive
8
  def load_data(file_url):
@@ -11,9 +10,47 @@ def load_data(file_url):
11
  return pd.read_excel(file_path, engine='openpyxl')
12
 
13
  # Function to generate the weekly menu based on BMI, dietary restriction, and pantry sync
14
- def generate_menu(data, season, sub_category_pref, outings, dietary_restrictions, pantry_ingredients):
15
  season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  meals_needed = 14 - outings # Main Courses (14) minus outings
18
 
19
  menu = []
@@ -110,21 +147,6 @@ def main():
110
  # Dietary restrictions
111
  dietary_restrictions = st.selectbox("Select any dietary restrictions", ["None", "Diabetic", "Gluten-Free", "Low-Sodium"])
112
 
113
- st.header("How many dishes from each sub-category would you like?")
114
- sub_category_pref = {
115
- 'Sabzi': st.number_input("Number of Sabzi dishes", min_value=0, value=0),
116
- 'Rice': st.number_input("Number of Rice dishes", min_value=0, value=0),
117
- 'Daal': st.number_input("Number of Daal dishes", min_value=0, value=0),
118
- 'Meat': st.number_input("Number of Meat dishes", min_value=0, value=0),
119
- 'Chicken': st.number_input("Number of Chicken dishes", min_value=0, value=0),
120
- 'Fish': st.number_input("Number of Fish dishes", min_value=0, value=0)
121
- }
122
-
123
- total_main_courses = sum(sub_category_pref.values()) + outings
124
- if total_main_courses > 14:
125
- st.warning("The total number of main courses exceeds 14! Please adjust your preferences.")
126
- return
127
-
128
  # Pantry Sync
129
  pantry_ingredients_input = st.text_area("Enter available ingredients in your pantry (comma separated)")
130
  if pantry_ingredients_input:
@@ -133,7 +155,8 @@ def main():
133
  pantry_ingredients = set()
134
 
135
  if st.button("Generate Menu"):
136
- lunch_menu, dinner_menu, total_cost, shopping_list = generate_menu(data, season, sub_category_pref, outings, dietary_restrictions, pantry_ingredients)
 
137
 
138
  st.header("Weekly Menu")
139
  st.subheader("Lunch Menu")
 
2
  import pandas as pd
3
  import gdown
4
  from PIL import Image
 
5
 
6
  # Function to load data from Google Drive
7
  def load_data(file_url):
 
10
  return pd.read_excel(file_path, engine='openpyxl')
11
 
12
  # Function to generate the weekly menu based on BMI, dietary restriction, and pantry sync
13
+ def generate_menu(data, season, outings, dietary_restrictions, bmi, pantry_ingredients):
14
  season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]
15
 
16
+ # Define the number of dishes based on BMI
17
+ if bmi < 18.5: # Underweight
18
+ sub_category_pref = {
19
+ 'Sabzi': 3, # More vegetables to increase calorie intake
20
+ 'Rice': 2, # More rice to increase carbohydrates
21
+ 'Daal': 2, # Protein-rich dals
22
+ 'Meat': 3, # More meat for proteins
23
+ 'Chicken': 2,
24
+ 'Fish': 1
25
+ }
26
+ elif 18.5 <= bmi < 24.9: # Normal weight
27
+ sub_category_pref = {
28
+ 'Sabzi': 2,
29
+ 'Rice': 2,
30
+ 'Daal': 2,
31
+ 'Meat': 2,
32
+ 'Chicken': 2,
33
+ 'Fish': 1
34
+ }
35
+ elif 25 <= bmi < 29.9: # Overweight
36
+ sub_category_pref = {
37
+ 'Sabzi': 4, # More vegetables
38
+ 'Rice': 1, # Limit rice
39
+ 'Daal': 2, # Protein-rich dals
40
+ 'Meat': 1, # Limit meat intake
41
+ 'Chicken': 3,
42
+ 'Fish': 1
43
+ }
44
+ else: # Obese
45
+ sub_category_pref = {
46
+ 'Sabzi': 5, # More vegetables
47
+ 'Rice': 1, # Very limited rice
48
+ 'Daal': 2, # Protein-rich dals
49
+ 'Meat': 1, # Very limited meat
50
+ 'Chicken': 2,
51
+ 'Fish': 1
52
+ }
53
+
54
  meals_needed = 14 - outings # Main Courses (14) minus outings
55
 
56
  menu = []
 
147
  # Dietary restrictions
148
  dietary_restrictions = st.selectbox("Select any dietary restrictions", ["None", "Diabetic", "Gluten-Free", "Low-Sodium"])
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  # Pantry Sync
151
  pantry_ingredients_input = st.text_area("Enter available ingredients in your pantry (comma separated)")
152
  if pantry_ingredients_input:
 
155
  pantry_ingredients = set()
156
 
157
  if st.button("Generate Menu"):
158
+ bmi = weight / (height_cm / 100) ** 2 # BMI calculation
159
+ lunch_menu, dinner_menu, total_cost, shopping_list = generate_menu(data, season, outings, dietary_restrictions, bmi, pantry_ingredients)
160
 
161
  st.header("Weekly Menu")
162
  st.subheader("Lunch Menu")