| import streamlit as st |
| import pandas as pd |
| import gdown |
| from PIL import Image |
|
|
| |
| def load_data(file_url): |
| file_path = "menu_data.xlsx" |
| gdown.download(file_url, file_path, quiet=False) |
| return pd.read_excel(file_path, engine='openpyxl') |
|
|
| |
| def generate_menu(data, season, dietary_restriction, outings): |
| |
| season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')] |
|
|
| |
| if dietary_restriction == "Gluten-Free": |
| season_data = season_data[season_data['Gluten-Free'] == True] |
| elif dietary_restriction == "Low-Sodium": |
| season_data = season_data[season_data['Sodium'] < 100] |
|
|
| meals_needed = 14 - outings |
|
|
| menu = [] |
| sub_categories = ['Sabzi', 'Rice', 'Daal', 'Meat', 'Chicken', 'Fish'] |
|
|
| for sub_category in sub_categories: |
| sub_category_dishes = season_data[season_data['Sub-Category'] == sub_category] |
| menu.extend(sub_category_dishes.sample(min(1, len(sub_category_dishes))).to_dict('records')) |
|
|
| menu = menu[:meals_needed] |
|
|
| outing_dishes = data[data['Home Made / Outing'] == 'Outing'].sample(outings).to_dict('records') |
| menu.extend(outing_dishes) |
|
|
| side_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records') |
| menu.extend(side_dishes) |
|
|
| menu_df = pd.DataFrame(menu) |
|
|
| |
| def assign_weekdays(menu): |
| weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] |
|
|
| menu_with_weekdays = [] |
| for i, dish in enumerate(menu): |
| if isinstance(dish, dict): |
| dish_with_day = dish.copy() |
| else: |
| dish_with_day = {"Name": dish} |
|
|
| dish_with_day["Weekday"] = weekdays[i % 7] |
| menu_with_weekdays.append(dish_with_day) |
|
|
| return pd.DataFrame(menu_with_weekdays) |
|
|
| lunch_menu = menu_df.iloc[:len(menu_df)//2] |
| dinner_menu = menu_df.iloc[len(menu_df)//2:] |
|
|
| total_cost = menu_df["Cost per 4 persons"].sum() |
|
|
| lunch_menu = assign_weekdays(lunch_menu) |
| dinner_menu = assign_weekdays(dinner_menu) |
|
|
| lunch_menu = lunch_menu[["Name", "Weekday"]] |
| dinner_menu = dinner_menu[["Name", "Weekday"]] |
|
|
| return lunch_menu, dinner_menu, total_cost |
|
|
| |
| def bmi_insights(weight, height_cm): |
| height_m = height_cm / 100 |
| bmi = weight / (height_m ** 2) |
|
|
| if bmi < 18.5: |
| return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial. Consider incorporating more calories and nutritious snacks." |
| elif 18.5 <= bmi < 24.9: |
| return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet, including fruits, vegetables, whole grains, and lean proteins." |
| elif 25 <= bmi < 29.9: |
| return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight. Consider reducing sugar intake." |
| else: |
| return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods, vegetables, and lean proteins is recommended. Consult a health professional for personalized guidance." |
|
|
| |
| def main(): |
| st.title("Roz Roz Ka Masla..... Aaj Kya Pakayen!!! ") |
| st.title("Now generate weekly Menu with BMI Insights") |
| |
| |
| image = Image.open("food_image.jpg") |
| st.sidebar.image(image, use_container_width=True) |
|
|
| |
| st.sidebar.header("Enter your details for BMI insights:") |
| weight = st.sidebar.number_input("Enter your weight (kg)", min_value=30, max_value=200, value=70) |
| height_cm = st.sidebar.number_input("Enter your height (cm)", min_value=90, max_value=250, value=175) |
|
|
| if st.sidebar.button("Get BMI Insights"): |
| bmi_message = bmi_insights(weight, height_cm) |
| st.sidebar.success(bmi_message) |
|
|
| |
| file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' |
| data = load_data(file_url) |
|
|
| |
| season = st.selectbox("Select the current season", ["Summer", "Winter"]) |
| dietary_restriction = st.selectbox("Select your dietary restriction", ["None", "Gluten-Free", "Low-Sodium"]) |
|
|
| outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0) |
|
|
| |
| if st.button("Generate Menu"): |
| lunch_menu, dinner_menu, total_cost = generate_menu(data, season, dietary_restriction, outings) |
|
|
| st.header("Weekly Menu") |
| st.subheader("Lunch Menu") |
| st.write(lunch_menu) |
|
|
| st.subheader("Dinner Menu") |
| st.write(dinner_menu) |
|
|
| st.subheader(f"Total Expenditure for the Week: PKR {total_cost}") |
|
|
| |
| with pd.ExcelWriter("weekly_menu_split.xlsx") as writer: |
| lunch_menu.to_excel(writer, sheet_name="Lunch", index=False) |
| dinner_menu.to_excel(writer, sheet_name="Dinner", index=False) |
|
|
| st.success("Weekly menu saved as 'weekly_menu_split.xlsx'") |
|
|
| if __name__ == "__main__": |
| main() |
|
|