Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,88 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
# coding: utf-8
|
| 3 |
-
|
| 4 |
-
# In[6]:
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
import gradio as gr
|
| 8 |
-
import random
|
| 9 |
-
from datetime import datetime
|
| 10 |
-
|
| 11 |
-
veg_foods = {
|
| 12 |
-
"breakfast": ["Idli", "Dosa", "Oats", "Upma", "Poha", "Vegetable Sandwich"],
|
| 13 |
-
"lunch": ["Chapati with Sabzi", "Veg Pulao", "Curd Rice", "Dal Rice"],
|
| 14 |
-
"dinner": ["Khichdi", "Paneer Curry", "Spinach Rice", "Mixed Vegetable Curry"],
|
| 15 |
-
"snacks": ["Fruits", "Peanut Chikki", "Roasted Chickpeas", "Sprouts"]
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
non_veg_foods = {
|
| 19 |
-
"breakfast": ["Boiled Eggs", "Omelette", "Chicken Sandwich", "Protein Shake"],
|
| 20 |
-
"lunch": ["Chicken Curry with Rice", "Fish Fry with Dal", "Egg Biryani"],
|
| 21 |
-
"dinner": ["Grilled Chicken", "Egg Curry", "Chicken Soup"],
|
| 22 |
-
"snacks": ["Boiled Eggs", "Greek Yogurt", "Dry Fruits"]
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
recommended_foods = {
|
| 26 |
-
"Veg": ["Whole Grains", "Low-Fat Dairy", "Oats", "Fruits", "Leafy Greens"],
|
| 27 |
-
"Non-Veg": ["Eggs", "Chicken Breast", "Fish", "Greek Yogurt", "Lean Meat"]
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
restricted_foods = {
|
| 31 |
-
"None": ["Fried Food", "Soda", "Processed Snacks", "White Bread", "Sugar"],
|
| 32 |
-
"Gym": ["Soft Drinks", "Junk Food", "Candies", "Refined Carbs", "Ice Cream"],
|
| 33 |
-
"Yoga": ["Heavy Fried Items", "Processed Sugar", "Soda", "Refined Oil", "Caffeine"],
|
| 34 |
-
"Strength Training": ["Sugary Beverages", "Fried Snacks", "White Rice", "Sweets", "Butter"]
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
def generate_diet(age, height, weight, disease, workout, allergies, category):
|
| 38 |
-
food_group = veg_foods if category == "Veg" else non_veg_foods
|
| 39 |
-
seed = hash((age, height, weight, disease, workout, allergies, category, datetime.now().isocalendar().week))
|
| 40 |
-
random.seed(seed)
|
| 41 |
-
|
| 42 |
-
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
| 43 |
-
weekly_plan = ""
|
| 44 |
-
for day in days:
|
| 45 |
-
breakfast = ", ".join(random.sample(food_group["breakfast"], 2))
|
| 46 |
-
lunch = ", ".join(random.sample(food_group["lunch"], 2))
|
| 47 |
-
dinner = ", ".join(random.sample(food_group["dinner"], 2))
|
| 48 |
-
snack = ", ".join(random.sample(food_group["snacks"], 1))
|
| 49 |
-
weekly_plan += f"<b>{day}</b><br>Breakfast: {breakfast}<br>Lunch: {lunch}<br>Dinner: {dinner}<br>Snacks: {snack}<br><br>"
|
| 50 |
-
|
| 51 |
-
recommended = ", ".join(recommended_foods[category])
|
| 52 |
-
restricted = ", ".join(restricted_foods[workout])
|
| 53 |
-
|
| 54 |
-
output_html = f"""
|
| 55 |
-
<h3>Weekly Diet Plan</h3>
|
| 56 |
-
{weekly_plan}
|
| 57 |
-
<h3>Recommended Foods</h3>
|
| 58 |
-
{recommended}
|
| 59 |
-
<h3>Restricted Foods</h3>
|
| 60 |
-
{restricted}
|
| 61 |
-
"""
|
| 62 |
-
return output_html
|
| 63 |
-
|
| 64 |
-
iface = gr.Interface(
|
| 65 |
-
fn=generate_diet,
|
| 66 |
-
inputs=[
|
| 67 |
-
gr.Number(label="Age"),
|
| 68 |
-
gr.Number(label="Height (cm)"),
|
| 69 |
-
gr.Number(label="Weight (kg)"),
|
| 70 |
-
gr.Textbox(label="Disease (if any)"),
|
| 71 |
-
gr.Radio(["None", "Gym", "Yoga", "Strength Training"], label="Workout Type"),
|
| 72 |
-
gr.Textbox(label="Food Allergies (comma separated)"),
|
| 73 |
-
gr.Radio(["Veg", "Non-Veg"], label="Food Category")
|
| 74 |
-
],
|
| 75 |
-
outputs=gr.HTML(label="Personalized Weekly Diet Plan"),
|
| 76 |
-
title="Diet Recommendation System 🍎",
|
| 77 |
-
description="Get a full weekly diet plan based on your profile",
|
| 78 |
-
allow_flagging="never"
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
iface.launch()
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
# In[ ]:
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|