Poojashetty357 commited on
Commit
ffe1554
·
verified ·
1 Parent(s): 0e51acd

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +44 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Define the mapping of unhealthy ingredients to healthier alternatives
4
+ ingredient_swaps = {
5
+ "white rice": "brown rice or quinoa",
6
+ "white pasta": "whole grain or lentil pasta",
7
+ "sour cream": "low-fat Greek yogurt",
8
+ "whole milk": "almond milk or oat milk",
9
+ "mayonnaise": "mashed avocado",
10
+ "white flour": "almond flour or oat flour",
11
+ "bottled dressing": "olive oil and lemon juice",
12
+ "butter": "olive oil or avocado oil",
13
+ "sugar": "honey or stevia",
14
+ "salt": "herbs or spices",
15
+ "cream": "coconut cream or low-fat yogurt",
16
+ "cheddar cheese": "low-fat cheese or nutritional yeast",
17
+ "fried chicken": "grilled chicken or baked tofu",
18
+ "potato chips": "baked sweet potato chips or kale chips",
19
+ "ice cream": "frozen banana or Greek yogurt-based dessert"
20
+ }
21
+
22
+ # Function to suggest healthier swaps
23
+ def suggest_swaps(recipe_text):
24
+ suggestions = []
25
+ recipe_lower = recipe_text.lower()
26
+ for ingredient, substitute in ingredient_swaps.items():
27
+ if ingredient in recipe_lower:
28
+ suggestions.append(f"Swap '{ingredient}' with '{substitute}'.")
29
+ if suggestions:
30
+ return "\n".join(suggestions)
31
+ else:
32
+ return "No unhealthy ingredients detected. Your recipe looks great!"
33
+
34
+ # Create Gradio interface
35
+ demo = gr.Interface(
36
+ fn=suggest_swaps,
37
+ inputs=gr.Textbox(lines=10, placeholder="Paste your recipe here..."),
38
+ outputs="text",
39
+ title="Healthy Recipe Swaps Generator",
40
+ description="Paste your recipe to get healthier ingredient alternatives."
41
+ )
42
+
43
+ # Launch the app
44
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio