lydiazyang commited on
Commit
127e868
·
1 Parent(s): 6f12f41

connected the front end flow and the back end flow to complete the application.

Browse files
Files changed (1) hide show
  1. index.py +15 -15
index.py CHANGED
@@ -21,7 +21,7 @@ def main():
21
  #items = ['Item 1', 'Item 2', 'Item 3']
22
 
23
  #list to of Ingredients camptured
24
- ingredientsList =["apple", "orange", "mango"] #list()
25
 
26
 
27
 
@@ -47,26 +47,16 @@ def main():
47
  session_state['ingredientsList'].append(classification)
48
 
49
  # Button to indicate done
50
- done_button = st.sidebar.button('Done')
51
 
52
  # Display the captured ingredients
53
  st.write("Captured Ingredients:", session_state['ingredientsList'])
54
 
55
  button_clicked = st.sidebar.button('Done')
56
- if button_clicked:
57
- # Define content for each item
58
- content = {}
59
- for ingredient in ingredientsList:
60
- content[ingredient] = askGPT(f"Give me your estimate the calories, grams of protein, grams of sugar, grams of fat, and grams of carbohydrates per 100g of {ingredient} as a list")
61
-
62
- # Display expanders for each item
63
- for ingredient in ingredientsList:
64
- with st.sidebar.expander(ingredient):
65
- st.write(content[ingredient])
66
- displayRecipes(ingredientsList)
67
 
68
  # Display recipes if "Done" is clicked
69
- while not done_button:
70
  # Read a frame from the webcam
71
  ret, frame = cap.read()
72
 
@@ -76,11 +66,21 @@ def main():
76
 
77
  # Display the frame in the Streamlit app
78
  video_placeholder.image(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB), channels="RGB", use_column_width=True)
79
- if done_button:
80
  cap.release()
81
  if session_state['ingredientsList']:
82
  session_state['ingredientsList'].pop()
83
  displayRecipes(session_state['ingredientsList'])
 
 
 
 
 
 
 
 
 
 
84
 
85
  def displayRecipes(ingredientsList):
86
  items = []
 
21
  #items = ['Item 1', 'Item 2', 'Item 3']
22
 
23
  #list to of Ingredients camptured
24
+ #ingredientsList =["apple", "orange", "mango"] #list()
25
 
26
 
27
 
 
47
  session_state['ingredientsList'].append(classification)
48
 
49
  # Button to indicate done
50
+ #done_button = st.sidebar.button('Done')
51
 
52
  # Display the captured ingredients
53
  st.write("Captured Ingredients:", session_state['ingredientsList'])
54
 
55
  button_clicked = st.sidebar.button('Done')
56
+
 
 
 
 
 
 
 
 
 
 
57
 
58
  # Display recipes if "Done" is clicked
59
+ while not button_clicked:
60
  # Read a frame from the webcam
61
  ret, frame = cap.read()
62
 
 
66
 
67
  # Display the frame in the Streamlit app
68
  video_placeholder.image(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB), channels="RGB", use_column_width=True)
69
+ if button_clicked:
70
  cap.release()
71
  if session_state['ingredientsList']:
72
  session_state['ingredientsList'].pop()
73
  displayRecipes(session_state['ingredientsList'])
74
+ # Define content for each item
75
+ content = {}
76
+ for ingredient in session_state['ingredientsList']:
77
+ content[ingredient] = askGPT(f"Give me your estimate the calories, grams of protein, grams of sugar, grams of fat, and grams of carbohydrates per 100g of {ingredient} as a list")
78
+
79
+ # Display expanders for each item
80
+ for ingredient in session_state['ingredientsList']:
81
+ with st.sidebar.expander(ingredient):
82
+ st.write(content[ingredient])
83
+ displayRecipes(session_state['ingredientsList'])
84
 
85
  def displayRecipes(ingredientsList):
86
  items = []