stchakman commited on
Commit
bc55074
·
1 Parent(s): ea5f1ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -15
app.py CHANGED
@@ -69,24 +69,36 @@ def get_image_download_link(image, filename, text):
69
  return href
70
 
71
  st.title("Fridge to Dish App")
72
- st.write("Upload an image of food ingredients in your fridge and get recipe suggestions!")
73
 
74
- # Upload the image and extract ingredients (use the appropriate function)
75
- uploaded_image = st.file_uploader("Upload an image of your fridge", type=['jpg', 'jpeg'])
76
- if uploaded_image:
77
  image = Image.open(uploaded_image)
78
- st.image(image, caption='Uploaded Image.', use_column_width=True)
 
79
  ingredients = extract_ingredients(image)
 
 
80
 
81
- # Generate dish suggestions
82
  suggested_dishes = generate_dishes(ingredients)
83
 
84
- for i, dish in enumerate(suggested_dishes):
85
- st.write(f"Suggested Dish {i + 1}: {dish}")
86
-
87
- if st.button(f"Generate Image for Dish {i + 1}"):
88
- dish_image = generate_image(dish)
89
- st.image(dish_image, caption=f'Generated Image for {dish}.', use_column_width=True)
90
-
91
- download_link = get_image_download_link(dish_image, f"{dish}.jpg", f"Download {dish} Image")
92
- st.markdown(download_link, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
69
  return href
70
 
71
  st.title("Fridge to Dish App")
 
72
 
73
+ uploaded_image = st.file_uploader("Upload an image of your fridge", type=["jpg", "jpeg", "png"])
74
+
75
+ if uploaded_image is not None:
76
  image = Image.open(uploaded_image)
77
+ st.image(image, caption="Uploaded Fridge Image, Please wait", use_column_width=True)
78
+
79
  ingredients = extract_ingredients(image)
80
+ st.write("Detected Ingredients:")
81
+ st.write(ingredients)
82
 
 
83
  suggested_dishes = generate_dishes(ingredients)
84
 
85
+ if suggested_dishes:
86
+ st.write("Suggested Dishes:")
87
+ for dish in suggested_dishes:
88
+ st.write(dish)
89
+
90
+ if st.button("Generate Image for Dish 1"):
91
+ dish1_image = generate_image(suggested_dishes[0].split(":")[0])
92
+ st.image(dish1_image, caption=f"Generated Image for {suggested_dishes[0].split(':')[0]}", use_column_width=True)
93
+
94
+ if st.button("Generate Image for Dish 2"):
95
+ dish2_image = generate_image(suggested_dishes[1].split(":")[0])
96
+ st.image(dish2_image, caption=f"Generated Image for {suggested_dishes[1].split(':')[0]}", use_column_width=True)
97
+
98
+ if st.button("Generate Image for Dish 3"):
99
+ dish3_image = generate_image(suggested_dishes[2].split(":")[0])
100
+ st.image(dish3_image, caption=f"Generated Image for {suggested_dishes[2].split(':')[0]}", use_column_width=True)
101
+ else:
102
+ st.write("No dishes found")
103
+ else:
104
+ st.write("Please upload an image")