Spaces:
Running
Running
Upload 14 files
Browse files- Calorie_calculator.py +37 -0
- JO_parsed.csv +0 -0
- Korean food_calorie.csv +0 -0
- Korean food_calorie__.csv +0 -0
- Procfile +1 -0
- README.md +1 -12
- calorie_deficit.py +41 -0
- multiapp.py +16 -0
- rec_system.py +94 -0
- requirements.txt +45 -0
- setup.sh +7 -0
- tfidf_encodings.pkl +3 -0
- tfidf_model.pkl +3 -0
- weightloss_tracker.py +99 -0
Calorie_calculator.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
def app():
|
3 |
+
#st.set_page_config(page_title='Calorie Calculator for Korean Food')
|
4 |
+
st.title("Calorie Calculator for Korean Food")
|
5 |
+
st.write("Enter the name of a food item with the serving amount")
|
6 |
+
st.markdown("""
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
color: #000;
|
10 |
+
background-color: #CF9FFF;
|
11 |
+
}
|
12 |
+
</style>
|
13 |
+
""", unsafe_allow_html=True)
|
14 |
+
import pandas as pd
|
15 |
+
df1 = pd.read_csv('Korean food_calorie__.csv',index_col=0)
|
16 |
+
dish = st.selectbox("Select the name of dish ",('Kimbap/๊น๋ฐฅ','Tteokbokki/๋ก๋ณถ์ด','Kalguksu/์นผ๊ตญ์','Gopchang-jeongol/๊ณฑ์ฐฝ์ ๊ณจ','Chadolbagi/์ฐจ๋๋ฐ๊ธฐ','Samgyeopsal/์ผ๊ฒน์ด','Panjeon/ํ์ ','Korean Tofu Kimchi Soup/๋๋ถ ๊น์น์ฐ๊ฐ','Samgetang/์ผ๊ณํ','Pork Ribs/๋ผ์ง ๊ฐ๋น','Dumplings/๋ง๋','Carrots In Korean/๋น๊ทผ ํ๊ตญ์ด','Galbi Jjim/๊ฐ๋น์ฐ','Bibimbap/๋น๋น๋ฐฅ','Yeongyang dolsatbap/์์ ๋์ฅ๋ฐฅ','Carrot Salad/๋น๊ทผ ์๋ฌ๋','Korean Food Lunch/ํ์ ์ ์ฌ','Ddukbaegi Bulgogi/๋๋ฐฐ๊ธฐ ๋ถ๊ณ ๊ธฐ','Jjamppong/์งฌ๋ฝ','Octopus bibimbap/๋ฌธ์ด๋น๋น๋ฐฅ','Sujebi/์์ ๋น','Dumpling Soup/๋ง๋ ์ํ','Yukgaejang/์ก๊ฐ์ฅ','Beef bulgogi/์๋ถ๊ณ ๊ธฐ','Vegetable Dumbling/์ผ์ฑ ๋ค๋ธ๋ง','Bulgogi/๋ถ๊ณ ๊ธฐ','Korean cold noodles/ํ๊ตญ ๋๋ฉด','Korean Eel soup/์ฅ์ดํ','Sundubu/์๋๋ถ','Korean Homemade food/ํ๊ตญ ์ง์์ ๋ง๋ ์์','Bibimnangmein/๋น๋น๋ญ๋ง์ธ','Bi Bim Bap/๋น๋น๋ฐฅ','Noodle/๊ตญ์','Galbi-tang /๊ฐ๋นํ','Bibimbap With Beef/์๊ณ ๊ธฐ ๋น๋น๋ฐฅ','Ginseng Chicken Soup/์ธ์ผ ์นํจ ์ํ','Dwen Jang Jigae/๋์ฌ ์ฅ์ง๊ฐ','Korean Beef Noodles/ํ์ฐ๊ตญ์','Tofu Kimchi/๋๋ถ','Makchang/๋ง์ฐฝ','Steamed Monkfish/์๊ท์ฐ','Sundaegukbab/์๋๊ตญ๋ฐฅ','Doganitang/๋๊ฐ๋ํ','Bulgogi /๋ถ๊ณ ๊ธฐ','Eomukguk/์ด๋ฌต๊ตญ','Soon Dae/์๋','Sirloin Steak/๋ฑ์ฌ ์คํ
์ดํฌ','Oi Kimchi/์ค์ด ๊น์น','Tempah/ํ
ํ','Seaweed Salad/๋ฏธ์ญ ์๋ฌ๋','Hobbang/ํธ๋ฑ
','Broiled Eels/๊ตฌ์ด ์ฅ์ด','Korean bbq/ํ๊ตญ์ ๋ฐ๋ฒ ํ','Nori/Seaweed/๊น','Upjinsal roast/์์ง์ด ๊ตฌ์ด','Samgyupsal Pork Belly/์ผ๊ฒน์ด ์ผ๊ฒน์ด','JwiPo/์ฃผ์ดํฌ','Kim Bugak/๋ฏธ์ญ ์ค๋ต','Sogogi Youkgajang/์๊ณ ๊ธฐ์ก๊ฐ์ฅ','Korean bbq marinade/ํ๊ตญ์ ๋ฐ๋ฒ ํ ๋ง๋ฆฌ๋ค์ด๋','Self heating food/์์ฒด ๊ฐ์ด ์ํ','Korean Chicken Stir-Fry/ํ๊ตญ ์นํจ ๋ณถ์','Beef Intestine /์ ๊ณ ๊ธฐ ์ฐฝ์','Pork Bone Soup โ Gamjatang/๊ฐ์ํ','Ojingeo Deopbap/์ค์ง์ด๋ฎ๋ฐฅ','Ddukbokkie/๋ก๋ณถ์ด','Dwenjanggigae/์ฌ์ฅ๊ธฐ๊ฐ','Ja Jang Myeon/์์ฅ๋ฉด','Doenjang Soup With Spinach/์๊ธ์น ๋์ฅ๊ตญ','Korean Biscuit/ํ๊ตญ ๊ณผ์','Seasoned Tofu /์๋
๋๋ถ','Korean Short Rib Soup/ํ์ ๊ฐ๋นํ','Roasted Pork Belly /๊ตฌ์ด ์ผ๊ฒน์ด','Tteokguk/์ถํ ์ํ','Korean beef/ํ์ฐ','Dak kkochi/๋ก๋ณถ์ด','Rice Cake Soup/๋ก๊ตญ','Stuffed Cucumber Kimchi/์ค์ด ๋ฐ์ ๊น์น','Yeot/์ฏง์ฏง','Gim/๊น','Triangular kimbap/์ผ๊ฐ๊น๋ฐฅ','Baked Chub Mackerel/๊ตฌ์ด ๊ณ ๋ฑ์ด','Bebimbap/๋น๋น๋ฐฅ','Bread Ttoah/๋นต๋์','Korean seaweed/ํ๊ตญ ํด์ด','Saeukkang/์๊ฐ','Bread Ttoah/๋นต๋์','Korean seaweed/ํ๊ตญ ํด์ด','Udon boeuf/์ฐ๋๋ถํ','Korean Kimchi/ํ๊ตญ ๊น์น','Korean Bbq/ํ๊ตญ์ ๋ฐ๋ฒ ํ','Dashida/๋ค์๋ค','Galbitang/๊ฐ๋นํ','Kimchi/๊น์น','Bibimbap vegetables/๋น๋น๋ฐฅ ์ผ์ฑ','Korean Chicken/ํ๊ตญ ์นํจ','Sikhye/์ํ','Saeng Maekju/์๋งฅ์ฃผ','Patbingsu/ํฅ๋น์','Tangpyeongchae/ํํ์ฑ'))
|
17 |
+
serving_ = st.number_input("Enter number of Servings")
|
18 |
+
try:
|
19 |
+
index_ = df1.index[df1['Name of the food']==dish].item()
|
20 |
+
except ValueError:
|
21 |
+
index_ = 1
|
22 |
+
else:
|
23 |
+
recipe_ = df1['Recipe'][index_]
|
24 |
+
cal_ = df1['Calories'][index_]
|
25 |
+
carb_ = df1['Carb(g)'][index_]
|
26 |
+
fat_ = df1['Fat (g)'][index_]
|
27 |
+
proteins_ = df1['Proteins(g)'][index_]
|
28 |
+
image_ = df1['Image'][index_]
|
29 |
+
kd = df1['Korean Description'][index_]
|
30 |
+
st.write("**Calorie count** ",round(cal_*serving_,2))
|
31 |
+
st.write("**Carbohydrate value** ",round(carb_*serving_,2))
|
32 |
+
st.write("**Fat value** ",round(fat_*serving_,2))
|
33 |
+
st.write("**Protein intake** ",round(proteins_*serving_,2))
|
34 |
+
st.write("**Recipe**",recipe_)
|
35 |
+
st.write("**Description in Korean**",kd)
|
36 |
+
st.image(image_,width=500)
|
37 |
+
|
JO_parsed.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Korean food_calorie.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Korean food_calorie__.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Procfile
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
web: sh setup.sh && streamlit run multiapp.py
|
README.md
CHANGED
@@ -1,12 +1 @@
|
|
1 |
-
|
2 |
-
title: Calorie Calculator
|
3 |
-
emoji: ๐ป
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: yellow
|
6 |
-
sdk: streamlit
|
7 |
-
sdk_version: 1.21.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# Calorie-Calculator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
calorie_deficit.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import datetime
|
4 |
+
from datetime import date
|
5 |
+
|
6 |
+
def app():
|
7 |
+
st.title("Calorie Deficit Tracker")
|
8 |
+
st.markdown("""
|
9 |
+
<style>
|
10 |
+
body {
|
11 |
+
color: #000;
|
12 |
+
background-color: #CF9FFF;
|
13 |
+
}
|
14 |
+
</style>
|
15 |
+
""", unsafe_allow_html=True)
|
16 |
+
sweight = st.number_input("Enter the current weight in kilograms")
|
17 |
+
height = st.number_input("Enter the height in centimetres")
|
18 |
+
gender = st.selectbox("Enter the Gender",("Male","Female"))
|
19 |
+
age = st.number_input("Enter the age in years")
|
20 |
+
calfood = st.number_input("Enter the food calorie intake")
|
21 |
+
act = st.selectbox("Enter the type of lifestyle ",("Sedentary : Sitting most of the day with no structured exercise","Moderately active : Sedentary and low active job with 1 hr exercise daily or Active job (moderate movement 8+ hrs per day) but no structured exercise","Vigorously active : Active job (moderate movement 8+ hours per day) and 1 hr exercise per day or Sedentary or low active job but 2 hours of exercise daily","Extremely active : Training more than 2 hrs per day or Moderately active job (walking all day) plus at least 1 hr of exercise daily"))
|
22 |
+
if act=="Sedentary : Sitting most of the day with no structured exercise":
|
23 |
+
act = 1.55
|
24 |
+
elif act == "Moderately active : Sedentary and low active job with 1 hr exercise daily or Active job (moderate movement 8+ hrs per day) but no structured exercise":
|
25 |
+
act = 1.85
|
26 |
+
elif act == "Vigorously active : Active job (moderate movement 8+ hours per day) and 1 hr exercise per day or Sedentary or low active job but 2 hours of exercise daily":
|
27 |
+
act = 2.2
|
28 |
+
else:
|
29 |
+
act = 2.4
|
30 |
+
rmr_male = 88.362 + (13.397 * sweight) + (4.799 * height) - (5.677 * age)
|
31 |
+
rmr_female = 447.593 + (9.247 * sweight) + (3.098 * height) - (4.330 * age)
|
32 |
+
if gender == "Male":
|
33 |
+
bmr = 10 * sweight + 6.25 * height - 5 * age + 5
|
34 |
+
st.write("**Resting Metabolic Rate: **",round(rmr_male,2))
|
35 |
+
else:
|
36 |
+
bmr = 10 * sweight + 6.25 * height - 5 * age - 161
|
37 |
+
st.write("**Resting Metabolic Rate: **",round(rmr_female,2))
|
38 |
+
mcal = bmr * act
|
39 |
+
mcalw = mcal * 7
|
40 |
+
st.write("**Calorie Deficit for the day: **",round(mcal,2))
|
41 |
+
app()
|
multiapp.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
st.set_page_config(page_title='Calorie Calculator')
|
3 |
+
import Calorie_calculator
|
4 |
+
import weightloss_tracker
|
5 |
+
import calorie_deficit
|
6 |
+
import rec_system
|
7 |
+
PAGES = {
|
8 |
+
"Calorie Calculator": Calorie_calculator,
|
9 |
+
"Calorie Deficit Calculator": calorie_deficit,
|
10 |
+
"Weight Loss Tracker": weightloss_tracker,
|
11 |
+
"Recommendation System": rec_system
|
12 |
+
}
|
13 |
+
st.sidebar.title('Calorie cum weight loss tracker')
|
14 |
+
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
|
15 |
+
page = PAGES[selection]
|
16 |
+
page.app()
|
rec_system.py
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import nltk
|
2 |
+
import string
|
3 |
+
import ast
|
4 |
+
import re
|
5 |
+
import unidecode
|
6 |
+
import pandas as pd
|
7 |
+
import streamlit as st
|
8 |
+
import nltk
|
9 |
+
nltk.download('wordnet')
|
10 |
+
from nltk.stem import WordNetLemmatizer
|
11 |
+
from nltk.corpus import wordnet
|
12 |
+
from collections import Counter
|
13 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
14 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
15 |
+
import pickle
|
16 |
+
def ingredient_parser(ingreds):
|
17 |
+
measures = ['teaspoon', 't', 'tsp', 'tablespoon', 'T', 'tbl.', 'tb', 'tbsp.', 'fluid ounce', 'fl oz', 'gill', 'cup', 'c', 'pint', 'p', 'pt', 'fl pt', 'quart', 'q', 'qt', 'fl qt', 'gallon', 'g', 'gal', 'ml', 'milliliter', 'millilitre', 'cc', 'mL', 'l', 'liter', 'litre', 'L', 'dl', 'deciliter', 'decilitre', 'dL', 'bulb', 'level', 'heaped', 'rounded', 'whole', 'pinch', 'medium', 'slice', 'pound', 'lb', '#', 'ounce', 'oz', 'mg', 'milligram', 'milligramme', 'g', 'gram', 'gramme', 'kg', 'kilogram', 'kilogramme', 'x', 'of', 'mm', 'millimetre', 'millimeter', 'cm', 'centimeter', 'centimetre', 'm', 'meter', 'metre', 'inch', 'in', 'milli', 'centi', 'deci', 'hecto', 'kilo']
|
18 |
+
words_to_remove = ['fresh', 'oil', 'a', 'red', 'bunch', 'and', 'clove', 'or', 'leaf', 'chilly','chillies', 'large', 'extra', 'sprig', 'ground', 'handful', 'free', 'small', 'pepper', 'virgin', 'range', 'from', 'dried', 'sustainable', 'black', 'peeled', 'higher', 'welfare', 'seed', 'for', 'finely', 'freshly', 'sea', 'quality', 'white', 'ripe', 'few', 'piece', 'source', 'to', 'organic', 'flat', 'smoked', 'ginger', 'sliced', 'green', 'picked', 'the', 'stick', 'plain', 'plus', 'mixed', 'mint', 'bay', 'basil', 'your', 'cumin', 'optional', 'fennel', 'serve', 'mustard', 'unsalted', 'baby', 'paprika', 'fat', 'ask', 'natural', 'skin', 'roughly', 'into', 'such', 'cut', 'good', 'brown', 'grated', 'trimmed', 'oregano', 'powder', 'yellow', 'dusting', 'knob', 'frozen', 'on', 'deseeded', 'low', 'runny', 'balsamic', 'cooked', 'streaky', 'nutmeg', 'sage', 'rasher', 'zest', 'pin', 'groundnut', 'breadcrumb', 'turmeric', 'halved', 'grating', 'stalk', 'light', 'tinned', 'dry', 'soft', 'rocket', 'bone', 'colour', 'washed', 'skinless', 'leftover', 'splash', 'removed', 'dijon', 'thick', 'big', 'hot', 'drained', 'sized', 'chestnut', 'watercress', 'fishmonger', 'english', 'dill', 'caper', 'raw', 'worcestershire', 'flake', 'cider', 'cayenne', 'tbsp', 'leg', 'pine', 'wild', 'if', 'fine', 'herb', 'almond', 'shoulder', 'cube', 'dressing', 'with', 'chunk', 'spice', 'thumb', 'garam', 'new', 'little', 'punnet', 'peppercorn', 'shelled', 'saffron', 'other''chopped', 'salt', 'olive', 'taste', 'can', 'sauce', 'water', 'diced', 'package', 'italian', 'shredded', 'divided', 'parsley', 'vinegar', 'all', 'purpose', 'crushed', 'juice', 'more', 'coriander', 'bell', 'needed', 'thinly', 'boneless', 'half', 'thyme', 'cubed', 'cinnamon', 'cilantro', 'jar', 'seasoning', 'rosemary', 'extract', 'sweet', 'baking', 'beaten', 'heavy', 'seeded', 'tin', 'vanilla', 'uncooked', 'crumb', 'style', 'thin', 'nut', 'coarsely', 'spring', 'chili', 'cornstarch', 'strip', 'cardamom', 'rinsed', 'honey', 'cherry', 'root', 'quartered', 'head', 'softened', 'container', 'crumbled', 'frying', 'lean', 'cooking', 'roasted', 'warm', 'whipping', 'thawed', 'corn', 'pitted', 'sun', 'kosher', 'bite', 'toasted', 'lasagna', 'split', 'melted', 'degree', 'lengthwise', 'romano', 'packed', 'pod', 'anchovy', 'rom', 'prepared', 'juiced', 'fluid', 'floret', 'room', 'active', 'seasoned', 'mix', 'deveined', 'lightly', 'anise', 'thai', 'size', 'unsweetened', 'torn', 'wedge', 'sour', 'basmati', 'marinara', 'dark', 'temperature', 'garnish', 'bouillon', 'loaf', 'shell', 'reggiano', 'canola', 'parmigiano', 'round', 'canned', 'ghee', 'crust', 'long', 'broken', 'ketchup', 'bulk', 'cleaned', 'condensed', 'sherry', 'provolone', 'cold', 'soda', 'cottage', 'spray', 'tamarind', 'pecorino', 'shortening', 'part', 'bottle', 'sodium', 'cocoa', 'grain', 'french', 'roast', 'stem', 'link', 'firm', 'asafoetida', 'mild', 'dash', 'boiling']
|
19 |
+
if isinstance(ingreds, list):
|
20 |
+
ingredients = ingreds
|
21 |
+
else:
|
22 |
+
ingredients = ast.literal_eval(ingreds)
|
23 |
+
translator = str.maketrans('', '', string.punctuation)
|
24 |
+
lemmatizer = WordNetLemmatizer()
|
25 |
+
ingred_list = []
|
26 |
+
for i in ingredients:
|
27 |
+
i.translate(translator)
|
28 |
+
# We split up with hyphens as well as spaces
|
29 |
+
items = re.split(' |-', i)
|
30 |
+
# Get rid of words containing non alphabet letters
|
31 |
+
items = [word for word in items if word.isalpha()]
|
32 |
+
# Turn everything to lowercase
|
33 |
+
items = [word.lower() for word in items]
|
34 |
+
# remove accents
|
35 |
+
items = [unidecode.unidecode(word) for word in items] #''.join((c for c in unicodedata.normalize('NFD', items) if unicodedata.category(c) != 'Mn'))
|
36 |
+
# Lemmatize words so we can compare words to measuring words
|
37 |
+
items = [lemmatizer.lemmatize(word) for word in items]
|
38 |
+
# Gets rid of measuring words/phrases, e.g. heaped teaspoon
|
39 |
+
items = [word for word in items if word not in measures]
|
40 |
+
# Get rid of common easy words
|
41 |
+
items = [word for word in items if word not in words_to_remove]
|
42 |
+
if items:
|
43 |
+
ingred_list.append(' '.join(items))
|
44 |
+
ingred_list = " ".join(ingred_list)
|
45 |
+
return ingred_list
|
46 |
+
# load in tdidf model and encodings
|
47 |
+
def scorefunc(ingredients):
|
48 |
+
with open('tfidf_encodings.pkl', 'rb') as f:
|
49 |
+
tfidf_encodings = pickle.load(f)
|
50 |
+
with open('tfidf_model.pkl', "rb") as f:
|
51 |
+
tfidf = pickle.load(f)
|
52 |
+
# parse the ingredients using my ingredient_parser
|
53 |
+
try:
|
54 |
+
ingredients_parsed = ingredient_parser(ingredients)
|
55 |
+
except:
|
56 |
+
ingredients_parsed = ingredient_parser([ingredients])
|
57 |
+
# use our pretrained tfidf model to encode our input ingredients
|
58 |
+
ingredients_tfidf = tfidf.transform([ingredients_parsed])
|
59 |
+
# calculate cosine similarity between actual recipe ingreds and test ingreds
|
60 |
+
cos_sim = map(lambda x: cosine_similarity(ingredients_tfidf, x), tfidf_encodings)
|
61 |
+
scores = list(cos_sim)
|
62 |
+
return scores
|
63 |
+
def get_recommendations(N, scores):
|
64 |
+
# load in recipe dataset
|
65 |
+
df_recipes = pd.read_csv('JO_parsed.csv')
|
66 |
+
# order the scores with and filter to get the highest N scores(desc order)
|
67 |
+
top = sorted(range(len(scores)), key=lambda i: scores[i], reverse=True)[:N]
|
68 |
+
# create dataframe to load in recommendations
|
69 |
+
recommendation = pd.DataFrame(columns = ['Recipe', 'Ingredients', 'Score', 'Url'])
|
70 |
+
count = 0
|
71 |
+
for i in top:
|
72 |
+
recommendation.at[count, 'Recipe'] = df_recipes['recipe_name'][i]
|
73 |
+
recommendation.at[count, 'Ingredients'] = df_recipes['ingredients'][i]
|
74 |
+
recommendation.at[count, 'Url'] = df_recipes['recipe_urls'][i]
|
75 |
+
recommendation.at[count, 'Score'] = "{:.3f}".format(float(scores[i]))
|
76 |
+
count += 1
|
77 |
+
return recommendation
|
78 |
+
def app():
|
79 |
+
st.markdown("*Recipe Recommendation System*")
|
80 |
+
recipe_box = st.selectbox(
|
81 |
+
"Display the top 5 recommendations or pick a particular recipe",
|
82 |
+
["Show the top picks", "Select a single recipe"],
|
83 |
+
)
|
84 |
+
if recipe_box =="Show the top picks":
|
85 |
+
N=5
|
86 |
+
else:
|
87 |
+
N=1
|
88 |
+
ing = st.text_input("Enter the ingredients you would like to cook with")
|
89 |
+
if ing:
|
90 |
+
scores = scorefunc(ing)
|
91 |
+
rec = get_recommendations(N,scores)
|
92 |
+
st.write("These are some recommendation(s) for you")
|
93 |
+
st.write(rec.head(N))
|
94 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==4.1.0
|
2 |
+
blinker==1.4
|
3 |
+
dlib==19.22.1
|
4 |
+
face-recognition==1.3.0
|
5 |
+
gitdb==4.0.5
|
6 |
+
GitPython==3.1.11
|
7 |
+
html5lib==1.0.1
|
8 |
+
imbalanced-learn==0.7.0
|
9 |
+
ipaddr==2.2.0
|
10 |
+
ipykernel==5.3.4
|
11 |
+
ipython==7.15.0
|
12 |
+
ipython-genutils==0.2.0
|
13 |
+
ipywidgets==7.5.1
|
14 |
+
jupyter-client==6.1.7
|
15 |
+
jupyter-core==4.7.0
|
16 |
+
jupyterlab-pygments==0.1.2
|
17 |
+
MarkupSafe==1.1.1
|
18 |
+
matplotlib==3.2.2
|
19 |
+
nbclient==0.5.1
|
20 |
+
nltk==3.5
|
21 |
+
notebook==6.1.5
|
22 |
+
numpy==1.19.4
|
23 |
+
pandas==1.1.4
|
24 |
+
pathtools==0.1.2
|
25 |
+
pickleshare==0.7.5
|
26 |
+
Pillow==8.0.1
|
27 |
+
pip==21.3.0
|
28 |
+
pycparser==2.20
|
29 |
+
pydeck==0.5.0
|
30 |
+
Pygments==2.7.2
|
31 |
+
pyparsing==2.4.7
|
32 |
+
pyrsistent==0.17.3
|
33 |
+
python-dateutil==2.8.1
|
34 |
+
pytoml==0.1.21
|
35 |
+
pytz==2020.4
|
36 |
+
pyzmq==20.0.0
|
37 |
+
six==1.15.0
|
38 |
+
scikit-learn==0.23.2
|
39 |
+
streamlit==0.71.0
|
40 |
+
unidecode==1.3.2
|
41 |
+
urllib3==1.26.2
|
42 |
+
validators==0.18.1
|
43 |
+
watchdog==0.10.4
|
44 |
+
webencodings==0.5.1
|
45 |
+
widgetsnbextension==3.5.1
|
setup.sh
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
mkdir -p ~/.streamlit
|
2 |
+
|
3 |
+
echo "[server]
|
4 |
+
headless = true
|
5 |
+
port = $PORT
|
6 |
+
enableCORS = false
|
7 |
+
" > ~/.streamlit/config.toml
|
tfidf_encodings.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c75868951060ee04bbd6b35d5884d7248dead1785923401ce2abd6e0e5fa53c7
|
3 |
+
size 132948
|
tfidf_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fe36aa25df7cdb05145c6b400a0afe26054ee14b2019e8f6552de343c0860107
|
3 |
+
size 42698
|
weightloss_tracker.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import datetime
|
4 |
+
from datetime import date
|
5 |
+
def shortcut():
|
6 |
+
scval = st.beta_expander("Information about Calories Burnt",False)
|
7 |
+
scval.markdown("**Walking**")
|
8 |
+
scval.markdown("1 Hour--> 350 Cal")
|
9 |
+
scval.markdown("1,000 Steps-->60 Cal")
|
10 |
+
scval.markdown("10,000 Steps-->600 Cal")
|
11 |
+
scval.markdown("**Running at an average speed**")
|
12 |
+
scval.markdown("1 Mile--> 100 Cal")
|
13 |
+
scval.markdown("1 KM-->60 Cal")
|
14 |
+
scval.markdown("5 Miles-->500 Cal")
|
15 |
+
scval.markdown("5 KM-->300 Cal")
|
16 |
+
scval.markdown("**Swimming at a slow pace**")
|
17 |
+
scval.markdown("1 Hour--> 500 Cal")
|
18 |
+
scval.markdown("1 Lap of 50m Pool-->25 Cal")
|
19 |
+
scval.markdown("**Swimming at a fast pace**")
|
20 |
+
scval.markdown("1 Hour--> 750 Cal")
|
21 |
+
scval.markdown("1 Lap of 50m Pool-->50 Cal")
|
22 |
+
scval.markdown("**Gym Workout for 1 Hour**")
|
23 |
+
scval.markdown("Light workout--> 200 Cal")
|
24 |
+
scval.markdown("Medium workout--> 350 Cal")
|
25 |
+
scval.markdown("Heavy workout--> 500 Cal")
|
26 |
+
scval.markdown("**Bike Ride for 1 Hour**")
|
27 |
+
scval.markdown("At 20 Km/hr or 13 Miles/hr--> 600 Cal")
|
28 |
+
scval.markdown("At 25 Km/hr or 16 Miles/hr--> 740 Cal")
|
29 |
+
scval1 = st.beta_expander("Information about Calorie Intake",False)
|
30 |
+
scval1.markdown("**Average general Calorie intake--> 2000-2500 Cal**")
|
31 |
+
scval1.markdown("**No. of Calorie Deficit required to lose 1 kg--> 7800 Cal**")
|
32 |
+
scval1.markdown("**Deficit of 1,100 cals per day --> 1 kg loss per week**")
|
33 |
+
scval1.markdown("**Daily loss for 2 kg per week is 0.3 kg per day**")
|
34 |
+
scval1.markdown("**1 kg of fat--> 7,500 calories**")
|
35 |
+
scval1.markdown("Calories for 2 small meals--> 1000 Cal")
|
36 |
+
scval1.markdown("Calories for 3 small meals--> 1800 Cal")
|
37 |
+
scval1.markdown("Apple, orange or banana--> 100 Cal")
|
38 |
+
scval1.markdown("Muesli with 1 cup of milk--> 500 Cal")
|
39 |
+
scval1.markdown("Fish 400 g with salad--> 600 Cal")
|
40 |
+
scval1.markdown("Steak 300 g with salad--> 800 Cal")
|
41 |
+
def func(val,sweight,height,gender,age,lr,cw,calfood,calburn):
|
42 |
+
st.write("**Days from the Start: **",val)
|
43 |
+
target_t = sweight - (val*lr)/7
|
44 |
+
st.write("**Start Weight: **",sweight)
|
45 |
+
st.write("**Target Today: **",round(target_t,2))
|
46 |
+
prg = target_t - cw
|
47 |
+
if prg>0:
|
48 |
+
st.write("**Progress: Ahead of target by **",round(prg,2)," **kg**")
|
49 |
+
else:
|
50 |
+
st.write("**Progress: Behind target by **",round(prg,2)," **kg**")
|
51 |
+
rmr_male = 88.362 + (13.397 * cw) + (4.799 * height) - (5.677 * age)
|
52 |
+
rmr_female = 447.593 + (9.247 * cw) + (3.098 * height) - (4.330 * age)
|
53 |
+
if gender =="Male":
|
54 |
+
cd = rmr_male + calburn - calfood
|
55 |
+
st.write("**Resting Metabolic Rate: **",round(rmr_male,2))
|
56 |
+
else:
|
57 |
+
cd = rmr_female + calburn - calfood
|
58 |
+
st.write("**Resting Metabolic Rate: **",round(rmr_female,2))
|
59 |
+
st.write("**Calorie Deficit: **",round(cd,2))
|
60 |
+
loss_exp = cd/7500
|
61 |
+
st.write("**Loss Expected: **",round(loss_exp,2))
|
62 |
+
st.markdown("____")
|
63 |
+
shortcut()
|
64 |
+
def app():
|
65 |
+
st.title("Weight Loss Tracker")
|
66 |
+
st.markdown("""
|
67 |
+
<style>
|
68 |
+
body {
|
69 |
+
color: #000;
|
70 |
+
background-color: #CF9FFF;
|
71 |
+
}
|
72 |
+
</style>
|
73 |
+
""", unsafe_allow_html=True)
|
74 |
+
date = st.date_input("Enter the start date",datetime.date(2022, 1, 1))
|
75 |
+
sweight = st.number_input("Enter the start weight in kilograms")
|
76 |
+
height = st.number_input("Enter the height in centimetres")
|
77 |
+
gender = st.selectbox("Enter the Gender",("Male","Female"))
|
78 |
+
age = st.number_input("Enter the age in years")
|
79 |
+
lr = st.number_input("Enter the loss rate(in kgs) per week")
|
80 |
+
cw = st.number_input("Enter the weight now")
|
81 |
+
calfood = st.number_input("Enter the food calorie intake")
|
82 |
+
calburn = st.number_input("Enter the calories burnt")
|
83 |
+
cdate = datetime.date.today()
|
84 |
+
if cdate == date:
|
85 |
+
val = 1
|
86 |
+
func(val,sweight,height,gender,age,lr,cw,calfood,calburn)
|
87 |
+
elif cdate>date:
|
88 |
+
delta = cdate - date
|
89 |
+
val = delta.days
|
90 |
+
func(val,sweight,height,gender,age,lr,cw,calfood,calburn)
|
91 |
+
else:
|
92 |
+
st.write("** Please select a Start date before current date**")
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
|