Update app.py
Browse files9 unmodified lines10111213141516171819202122232425262728293031323334356 unmodified lines4243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959620 unmodified lines11711811912012112212312412512612712812913013113213313413513613713813914020 unmodified lines1611621631641651661679 unmodified linesreturn pd.read_excel(file_path, engine='openpyxl')# Function to generate the weekly menudef generate_menu(data, season, sub_category_pref, outings):season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]meals_needed = 14 - outings # Main Courses (14) minus outingsmenu = []for sub_category, freq in sub_category_pref.items():sub_category_dishes = season_data[season_data['Sub-Category'] == sub_category]menu.extend(sub_category_dishes.sample(min(freq, 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)lunch_menu = menu_df.iloc[:len(menu_df)//2]dinner_menu = menu_df.iloc[len(menu_df)//2:]6 unmodified lines# Function to calculate BMI and recommend diet for adultsdef bmi_insights(weight, height_cm):height_m = height_cm / 100bmi = 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."elif 18.5 <= bmi < 24.9:return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet."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."else: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."# Function to provide general diet recommendation for infantsdef infant_diet_recommendation():return ("For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. ""Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. ""Consult with your pediatrician for more personalized advice.")# Function to provide dietary recommendations based on medical conditionsdef medical_condition_recommendation(condition):recommendations = {"Diabetes": "A low-carb diet is essential. Focus on fiber-rich vegetables, lean proteins, and healthy fats. Avoid sugary foods.","Celiac Disease": "Avoid gluten-containing foods like wheat, barley, and rye. Focus on gluten-free grains, fruits, vegetables, and lean proteins.","Hypertension": "Limit salt intake. Incorporate potassium-rich foods such as bananas, spinach, and potatoes. A heart-healthy diet with lean proteins is ideal.","Heart Disease": "Consume a heart-healthy diet rich in omega-3 fatty acids, vegetables, and whole grains. Limit saturated fats and processed foods.","Obesity": "Focus on a calorie-restricted diet, prioritizing vegetables, lean meats, and whole grains. Avoid sugary snacks and drinks.","Cholesterol Disorders": "Eat foods rich in fiber, such as oats, fruits, and vegetables. Limit saturated fats and trans fats.","IBS": "Incorporate fiber-rich foods like oats and vegetables. Avoid foods that cause bloating, such as beans, cabbage, and onions.","GERD": "Avoid acidic and spicy foods, caffeine, and alcohol. Focus on bland, easy-to-digest meals like rice, oatmeal, and non-citrus fruits.","Peptic Ulcers": "Avoid spicy, fatty, and acidic foods. Focus on bland foods like rice, oatmeal, and non-citrus fruits.","Gout": "Limit foods high in purines, such as red meat, shellfish, and alcohol. Focus on low-fat dairy, fruits, and vegetables.","Lactose Intolerance": "Avoid dairy products or choose lactose-free alternatives. Incorporate plant-based sources of calcium.","Kidney Disease": "Reduce sodium, potassium, and phosphorus intake. Focus on lean proteins and avoid processed foods.","Hypothyroidism": "Increase iodine-rich foods like seaweed, eggs, and dairy. Focus on vegetables and lean proteins.","Anemia": "Focus on iron-rich foods such as red meat, spinach, and beans. Pair with vitamin C-rich foods for better absorption.","Food Allergies": "Avoid allergenic foods like peanuts, tree nuts, dairy, eggs, shellfish, and others. Focus on a balanced, allergy-free diet.","Acid Reflux": "Avoid acidic and spicy foods. Incorporate alkaline foods like bananas, melons, and oatmeal.","Crohn's Disease": "Focus on low-fiber foods and avoid spicy, fatty, and acidic foods. Prioritize lean meats and easy-to-digest grains.","Osteoporosis": "Ensure adequate calcium and vitamin D intake through dairy or fortified alternatives. Incorporate weight-bearing exercises.","Autoimmune Diseases": "A diet rich in anti-inflammatory foods like leafy greens, berries, nuts, and fatty fish is ideal.","Migraines": "Avoid foods that trigger migraines, such as chocolate, caffeine, and aged cheeses. Focus on magnesium-rich foods.","PCOS": "Focus on a low-glycemic index diet with plenty of fruits, vegetables, and lean proteins. Limit processed sugars.","CFS": "A balanced diet with adequate calories and nutrients is essential. Focus on anti-inflammatory foods and avoid refined sugars.","Mental Health": "Focus on omega-3 fatty acids, whole grains, fruits, and vegetables. Avoid processed foods and sugar."}return recommendations.get(condition, "No specific recommendations available.")# Main workflowdef main():st.title("Roz Roz Ka Masla..... Aaj Kya Pakayen!!! ")20 unmodified linesheight_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)# Dropdown for selecting medical condition(s)medical_condition = st.sidebar.selectbox("Select any medical condition", ["None", "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity","Cholesterol Disorders", "IBS", "GERD", "Peptic Ulcers", "Gout", "Lactose Intolerance","Kidney Disease", "Hypothyroidism", "Anemia", "Food Allergies", "Acid Reflux","Crohn's Disease", "Osteoporosis", "Autoimmune Diseases", "Migraines", "PCOS","CFS", "Mental Health"])if medical_condition != "None":condition_recommendation = medical_condition_recommendation(medical_condition)st.sidebar.write(condition_recommendation)# Google Drive file URLfile_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file linkdata = load_data(file_url)20 unmodified linesreturnif st.button("Generate Menu"):lunch_menu, dinner_menu, total_cost = generate_menu(data, season, sub_category_pref, outings)st.header("Weekly Menu")st.subheader("Lunch Menu")9 unmodified lines10111213141516171819202122232425262728293031323334353637383940414243444546474849506 unmodified lines5758596061626364656667686970717273747576777879808182838420 unmodified lines10510610710810911011111211320 unmodified lines1341351361371381391409 unmodified linesreturn pd.read_excel(file_path, engine='openpyxl')# Function to generate the weekly menudef generate_menu(data, season, sub_category_pref, outings, bmi_category):# Filter season dataseason_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]# Adjust the menu based on BMI categoryif bmi_category == "Underweight":# Suggest high-calorie dishes like meat, rice, and calorie-dense vegetablespreferred_dishes = ['Meat', 'Rice', 'Sabzi', 'Chicken']elif bmi_category == "Normal Weight":# Balanced meals with a variety of dishespreferred_dishes = ['Sabzi', 'Rice', 'Daal', 'Chicken', 'Fish']elif bmi_category == "Overweight":# Focus on lean proteins and vegetables, limiting carbspreferred_dishes = ['Sabzi', 'Chicken', 'Fish', 'Meat']else: # Obese category# Focus on lean proteins, vegetables, and smaller portions of carbspreferred_dishes = ['Sabzi', 'Daal', 'Chicken', 'Fish']# Select dishes based on the BMI category and preferencesmenu = []for sub_category in preferred_dishes:sub_category_dishes = season_data[season_data['Sub-Category'] == sub_category]menu.extend(sub_category_dishes.sample(min(3, len(sub_category_dishes))).to_dict('records'))# Select outing dishesmeals_needed = 14 - outingsouting_dishes = data[data['Home Made / Outing'] == 'Outing'].sample(outings).to_dict('records')menu.extend(outing_dishes)# Select side dishesside_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records')menu.extend(side_dishes)# Generate the menu and calculate total costmenu_df = pd.DataFrame(menu)lunch_menu = menu_df.iloc[:len(menu_df)//2]dinner_menu = menu_df.iloc[len(menu_df)//2:]6 unmodified lines# Function to calculate BMI and recommend diet for adultsdef bmi_insights(weight, height_cm):# Convert height from cm to metersheight_m = height_cm / 100bmi = 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.", "Underweight"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.", "Normal Weight"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.", "Overweight"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.", "Obese"# Function to provide general diet recommendation for infantsdef infant_diet_recommendation():return ("For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. ""Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. ""Ensure a variety of textures as they grow and introduce protein-rich foods, like pureed meat or lentils. ""Consult with your pediatrician for more personalized advice.")# Main workflowdef main():st.title("Roz Roz Ka Masla..... Aaj Kya Pakayen!!! ")20 unmodified linesheight_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_category = bmi_insights(weight, height_cm)st.sidebar.success(bmi_message)# Google Drive file URLfile_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file linkdata = load_data(file_url)20 unmodified linesreturnif st.button("Generate Menu"):lunch_menu, dinner_menu, total_cost = generate_menu(data, season, sub_category_pref, outings, bmi_category)st.header("Weekly Menu")st.subheader("Lunch Menu")
app.py+32-59