tdnathmlenthusiast commited on
Commit
c90eafc
1 Parent(s): ac47380

uploaded core model

Browse files
Files changed (2) hide show
  1. interface.py +60 -0
  2. requirements.txt +2 -0
interface.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ def generate_recommendations(party_on_weekends, flavor_preference, texture_dislike, price_range):
5
+ # Define the list of ingredients
6
+ ingredients = ["oranges", "apples", "pears", "grapes", "watermelon", "lemon", "lime"]
7
+
8
+ # Apply the rules based on user answers
9
+ allowed_fruits = ingredients.copy()
10
+
11
+ if party_on_weekends == "yes":
12
+ allowed_fruits = list(set(allowed_fruits) & set(["apples", "pears", "grapes", "watermelon"]))
13
+
14
+ if flavor_preference == "cider":
15
+ allowed_fruits = list(set(allowed_fruits) & set(["apples", "oranges", "lemon", "lime"]))
16
+
17
+ elif flavor_preference == "sweet":
18
+ allowed_fruits = list(set(allowed_fruits) & set(["watermelon", "oranges"]))
19
+
20
+ elif flavor_preference == "waterlike":
21
+ allowed_fruits = list(set(allowed_fruits) & set(["watermelon"]))
22
+
23
+ if "grapes" in allowed_fruits:
24
+ allowed_fruits.remove("watermelon")
25
+
26
+ if texture_dislike == "smooth":
27
+ if "pears" in allowed_fruits:
28
+ allowed_fruits.remove("pears")
29
+
30
+ elif texture_dislike == "slimy":
31
+ slimy_fruits = ["watermelon", "lime", "grapes"]
32
+ allowed_fruits = list(set(allowed_fruits) - set(slimy_fruits))
33
+
34
+ elif texture_dislike == "waterlike":
35
+ if "watermelon" in allowed_fruits:
36
+ allowed_fruits.remove("watermelon")
37
+
38
+ if price_range < 3:
39
+ if "lime" in allowed_fruits:
40
+ allowed_fruits.remove("lime")
41
+ if "watermelon" in allowed_fruits:
42
+ allowed_fruits.remove("watermelon")
43
+
44
+ elif 4 < price_range < 7:
45
+ if "pears" in allowed_fruits:
46
+ allowed_fruits.remove("pears")
47
+ if "apples" in allowed_fruits:
48
+ allowed_fruits.remove("apples")
49
+
50
+ return allowed_fruits
51
+
52
+ def recommend_fruits(party_answer, flavor_answer, texture_answer, price_answer):
53
+ recommendations = generate_recommendations(party_answer, flavor_answer, texture_answer, price_answer)
54
+ return "Recommended fruits: " + str(recommendations)
55
+
56
+ iface = gr.Interface(fn=recommend_fruits,
57
+ inputs=["text", "text", "text", "text"],
58
+ outputs="text",
59
+ live=True)
60
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers==4.27.0
2
+ gradio==3.41.0