implemented prompt for the nutrition expert.
Browse files
index.py
CHANGED
|
@@ -2,7 +2,6 @@ import streamlit as st
|
|
| 2 |
import cv2
|
| 3 |
import os
|
| 4 |
from app import *
|
| 5 |
-
import json
|
| 6 |
|
| 7 |
# Create a folder to save captured images
|
| 8 |
if not os.path.exists("captured_images"):
|
|
@@ -18,11 +17,7 @@ def main():
|
|
| 18 |
items = ['Item 1', 'Item 2', 'Item 3']
|
| 19 |
|
| 20 |
#list to of Ingredients camptured
|
| 21 |
-
<<<<<<< HEAD
|
| 22 |
-
ingredientsList =[] #list()
|
| 23 |
-
=======
|
| 24 |
ingredientsList =["apple", "orange", "mango", "potato", "cabbage", "carrot", "lentils"] #list()
|
| 25 |
-
>>>>>>> 37e4918 (implemented prompt for the nutrition expert.)
|
| 26 |
|
| 27 |
# Define content for each item
|
| 28 |
content = {
|
|
@@ -36,7 +31,6 @@ def main():
|
|
| 36 |
with st.sidebar.expander(item):
|
| 37 |
st.write(content[item])
|
| 38 |
|
| 39 |
-
button_clicked = st.sidebar.button('Done')
|
| 40 |
|
| 41 |
# Create a VideoCapture object to access the webcam
|
| 42 |
cap = cv2.VideoCapture(0)
|
|
@@ -59,6 +53,7 @@ def main():
|
|
| 59 |
classification = classifyImage(image_path)
|
| 60 |
ingredientsList.append(classification)
|
| 61 |
|
|
|
|
| 62 |
if button_clicked:
|
| 63 |
displayRecipes(ingredientsList)
|
| 64 |
print(ingredientsList)
|
|
@@ -79,26 +74,22 @@ def main():
|
|
| 79 |
|
| 80 |
|
| 81 |
def displayRecipes(ingredientsList):
|
| 82 |
-
items = [
|
| 83 |
-
{"title": "Recipe 1", "content": "Content for Item 1."},
|
| 84 |
-
{"title": "Recipe 2", "content": "Content for Item 2."},
|
| 85 |
-
{"title": "Recipe 3", "content": "Content for Item 3."}
|
| 86 |
-
]
|
| 87 |
-
# Display the items with expanding boxes
|
| 88 |
-
for item in items:
|
| 89 |
-
with st.expander(item["title"]):
|
| 90 |
-
st.write(item["content"])
|
| 91 |
#now we are gonna send the ingredient list to ask gpt
|
| 92 |
prompt = f"I have following Ingredients :{','.join(ingredientsList)}. What can I make with these \
|
| 93 |
-
Ingredients? give me possible
|
| 94 |
highest nutrition value to lowest. Give me results in \
|
| 95 |
-
|
| 96 |
['title': 'Recipe title', 'content': 'recipe and nutritional facts per 100g']"
|
| 97 |
LLMResult = askGPT(prompt)
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
def capture_image(cap):
|
|
|
|
| 2 |
import cv2
|
| 3 |
import os
|
| 4 |
from app import *
|
|
|
|
| 5 |
|
| 6 |
# Create a folder to save captured images
|
| 7 |
if not os.path.exists("captured_images"):
|
|
|
|
| 17 |
items = ['Item 1', 'Item 2', 'Item 3']
|
| 18 |
|
| 19 |
#list to of Ingredients camptured
|
|
|
|
|
|
|
|
|
|
| 20 |
ingredientsList =["apple", "orange", "mango", "potato", "cabbage", "carrot", "lentils"] #list()
|
|
|
|
| 21 |
|
| 22 |
# Define content for each item
|
| 23 |
content = {
|
|
|
|
| 31 |
with st.sidebar.expander(item):
|
| 32 |
st.write(content[item])
|
| 33 |
|
|
|
|
| 34 |
|
| 35 |
# Create a VideoCapture object to access the webcam
|
| 36 |
cap = cv2.VideoCapture(0)
|
|
|
|
| 53 |
classification = classifyImage(image_path)
|
| 54 |
ingredientsList.append(classification)
|
| 55 |
|
| 56 |
+
button_clicked = st.sidebar.button('Done')
|
| 57 |
if button_clicked:
|
| 58 |
displayRecipes(ingredientsList)
|
| 59 |
print(ingredientsList)
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
def displayRecipes(ingredientsList):
|
| 77 |
+
items = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
#now we are gonna send the ingredient list to ask gpt
|
| 79 |
prompt = f"I have following Ingredients :{','.join(ingredientsList)}. What can I make with these \
|
| 80 |
+
Ingredients? give me possible list of recipes with Nutrition Facts per 100g from \
|
| 81 |
highest nutrition value to lowest. Give me results in \
|
| 82 |
+
followig format:\
|
| 83 |
['title': 'Recipe title', 'content': 'recipe and nutritional facts per 100g']"
|
| 84 |
LLMResult = askGPT(prompt)
|
| 85 |
+
lystOfRecipes = LLMResult.split('\n\n')
|
| 86 |
+
for recipe in range(1, len(lystOfRecipes)-1):
|
| 87 |
+
items.append({"title": f"Recipe {recipe}", "content": lystOfRecipes[recipe]})
|
| 88 |
+
# Display the items with expanding boxes
|
| 89 |
+
for item in items:
|
| 90 |
+
with st.expander(item["title"]):
|
| 91 |
+
st.write(item["content"])
|
| 92 |
+
|
| 93 |
|
| 94 |
|
| 95 |
def capture_image(cap):
|