Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +121 -0
- task1_output_n_c1_sup4 (2).txt +0 -0
app.py
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
from collections import defaultdict
|
3 |
+
import gradio as gr
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
def create_recommendation_system(pairs):
|
7 |
+
sets_by_length = defaultdict(list)
|
8 |
+
|
9 |
+
for pair in pairs:
|
10 |
+
sets_by_length[len(pair)].append(set(pair))
|
11 |
+
|
12 |
+
sorted_keys = sorted(sets_by_length.keys(), reverse=True)
|
13 |
+
|
14 |
+
def recommend(restaurant):
|
15 |
+
recommended = set()
|
16 |
+
for length in sorted_keys:
|
17 |
+
for rest_set in sets_by_length[length]:
|
18 |
+
if restaurant in rest_set:
|
19 |
+
recommended.update(rest_set - {restaurant})
|
20 |
+
return list(recommended)
|
21 |
+
|
22 |
+
return recommend
|
23 |
+
|
24 |
+
def recommend(input_string):
|
25 |
+
f = open("task1_output_n_c1_sup4 (2).txt", "r")
|
26 |
+
data = f.read()
|
27 |
+
data = data.split("Frequent Itemsets:")
|
28 |
+
|
29 |
+
clean_string = re.sub(r'\n', '', data[1])
|
30 |
+
pattern = r"\([^\)]+\)"
|
31 |
+
|
32 |
+
extracted_tuples = re.findall(pattern, clean_string.replace("'", ""))
|
33 |
+
|
34 |
+
tuple_list = [tuple(s.strip('()').split(', ')) for s in extracted_tuples]
|
35 |
+
|
36 |
+
recommendation_system = create_recommendation_system(tuple_list)
|
37 |
+
|
38 |
+
output_list = recommendation_system(input_string)
|
39 |
+
|
40 |
+
images_labels = [("https://logowik.com/content/uploads/images/aw-restaurants5299.jpg", "A&W Restaurant"),
|
41 |
+
("https://inspirebrands.com/wp-content/uploads/2017/10/Arbys.jpg","Arbys"),
|
42 |
+
("https://www.shutterstock.com/image-vector/vinnytsia-ukraine-october-8-2023-600nw-2372329457.jpg","Burger King"),
|
43 |
+
("https://static.wixstatic.com/media/cc8696_2f0a91e1d9d245efa98b100adfcdd887~mv2.png/v1/crop/x_0,y_0,w_242,h_71/fill/w_339,h_94,al_c,lg_1,q_85,enc_auto/logo.png","California Kitchen"),
|
44 |
+
("https://logos-world.net/wp-content/uploads/2022/11/Carls-Jr.-Logo-500x281.png","Carls Jr."),
|
45 |
+
("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Chick-fil-A_Logo.svg/873px-Chick-fil-A_Logo.svg.png","Chick-Fil-A"),
|
46 |
+
("https://upload.wikimedia.org/wikipedia/en/thumb/3/38/CECLogo2019.svg/330px-CECLogo2019.svg.png","Chuck E. Cheese"),
|
47 |
+
("https://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Culver%27s_logo.svg/558px-Culver%27s_logo.svg.png","Culvers"),
|
48 |
+
("https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Dairy_Queen_logo.svg/300px-Dairy_Queen_logo.svg.png", "Dairy Queen"),
|
49 |
+
("https://logowik.com/content/uploads/images/493_dominospizza.jpg", "Dominos Pizza"),
|
50 |
+
("https://logos-world.net/wp-content/uploads/2023/03/Five-Guys-Logo-500x281.png", "Five Guys"),
|
51 |
+
("https://entrackr.com/storage/2023/06/Good-Flippin.jpg", "Good Flippin Burger"),
|
52 |
+
("https://logowik.com/content/uploads/images/hardees4024.jpg", "Hardees"),
|
53 |
+
("https://logos-marques.com/wp-content/uploads/2023/04/In-N-Out-Burger-Logo-768x432.png", "In-N-Out"),
|
54 |
+
("https://logos-world.net/wp-content/uploads/2022/08/Jack-in-the-Box-Logo-500x281.png", "Jack in the Box"),
|
55 |
+
("https://1000logos.net/wp-content/uploads/2021/05/Jollibee-logo-768x432.png", "Jollibee"),
|
56 |
+
("https://logowik.com/content/uploads/images/674_kfc.jpg", "KFC"),
|
57 |
+
("https://visitguernseycounty.com/wp-content/uploads/2022/05/Little-Caesars-Logo-1024x576.jpg", "Little Caesars"),
|
58 |
+
("https://logowik.com/content/uploads/images/mcdonalds-icon.jpg", "McDonalds"),
|
59 |
+
("https://images.squarespace-cdn.com/content/v1/53a47e51e4b0e78ae9ed2e97/4b8df8ab-662a-4381-92a6-97839099d5a7/Papa-Johns-logo.jpg", "Papa Johns"),
|
60 |
+
("https://cdn.nwe.io/files/x/d5/cc/c9810c9ad13188a3e0b2bc6577d7.jpg", "Pizza Inn"),
|
61 |
+
("https://logowik.com/content/uploads/images/294_pizza_hut_new_logo.jpg", "Pizza hut"),
|
62 |
+
("https://upload.wikimedia.org/wikipedia/commons/a/a6/PizzaExpress_Logo.jpg", "PizzaExpress"),
|
63 |
+
("https://images.squarespace-cdn.com/content/v1/53a47e51e4b0e78ae9ed2e97/be0aea01-84cc-4b89-a5e8-314ed394dc3c/Popeyes+logo.jpg", "Popeyes"),
|
64 |
+
("https://upload.wikimedia.org/wikipedia/commons/d/d9/Original_Round_Table_Pizza_Logo.jpg", "Round Table Pizza"),
|
65 |
+
("https://logowik.com/content/uploads/images/328_sbarro.jpg", "Sbarro"),
|
66 |
+
("https://1000logos.net/wp-content/uploads/2023/04/Shake-Shack-Logo-768x432.png", "Shake Shack"),
|
67 |
+
("https://upload.wikimedia.org/wikipedia/en/thumb/6/6d/Shakey%27s_US_logo.svg/330px-Shakey%27s_US_logo.svg.png", "Shakeys Pizza"),
|
68 |
+
("https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/SONIC_New_Logo_2020.svg/1199px-SONIC_New_Logo_2020.svg.png", "Sonic"),
|
69 |
+
("https://images.getbento.com/accounts/236fb3743b9522eafb90c6d2d20b8115/media/accounts/media/V1G5LTCrSDqyixbNUDpr_logo-tasty-burger.png", "Tasty burger"),
|
70 |
+
("https://cdn.worldvectorlogo.com/logos/uno-pizzeria.svg", "Uno Pizzeria"),
|
71 |
+
("https://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Wahlburgers_Logo.svg/768px-Wahlburgers_Logo.svg.png", "Wahlburgers"),
|
72 |
+
("https://logowik.com/content/uploads/images/866_wendys.jpg", "Wendys"),
|
73 |
+
("https://logowik.com/content/uploads/images/whataburger8433.jpg", "Whataburger"),
|
74 |
+
("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTsUZPMFzUmACfaeSrMSZsgGn5gnbXNyYRPxIrS1PfCrFWI9QJhrlkmdG9IhFbi", "White Castle")]
|
75 |
+
|
76 |
+
output = []
|
77 |
+
for i in images_labels:
|
78 |
+
if(i[1] in output_list):
|
79 |
+
output.append(i)
|
80 |
+
|
81 |
+
return output
|
82 |
+
|
83 |
+
sorted_unique_restaurants = [
|
84 |
+
'A&W Restaurant',
|
85 |
+
'Arbys',
|
86 |
+
'Burger King',
|
87 |
+
'California Kitchen',
|
88 |
+
'Carls Jr.',
|
89 |
+
'Chick-Fil-A',
|
90 |
+
'Chuck E. Cheese',
|
91 |
+
'Culvers',
|
92 |
+
'Dairy Queen',
|
93 |
+
'Dominos Pizza',
|
94 |
+
'Five Guys',
|
95 |
+
'Good Flippin Burger',
|
96 |
+
'Hardees',
|
97 |
+
'In-N-Out',
|
98 |
+
'Jack in the Box',
|
99 |
+
'Jollibee',
|
100 |
+
'KFC',
|
101 |
+
'Little Caesars',
|
102 |
+
'McDonalds',
|
103 |
+
'Papa Johns',
|
104 |
+
'Pizza Inn',
|
105 |
+
'Pizza hut',
|
106 |
+
'PizzaExpress',
|
107 |
+
'Popeyes',
|
108 |
+
'Round Table Pizza',
|
109 |
+
'Sbarro',
|
110 |
+
'Shake Shack',
|
111 |
+
'Shakeys Pizza',
|
112 |
+
'Sonic',
|
113 |
+
'Tasty burger',
|
114 |
+
'Uno Pizzeria',
|
115 |
+
'Wahlburgers',
|
116 |
+
'Wendys',
|
117 |
+
'Whataburger',
|
118 |
+
'White Castle']
|
119 |
+
|
120 |
+
io = gr.Interface(fn=recommend, inputs=gr.Dropdown(choices=sorted_unique_restaurants, value="Burger King"), outputs=gr.Gallery(label="Generated images", show_label=False, elem_id="gallery", columns=[4], object_fit="contain", height="auto"), title='Restaurant Recommender System', description='Find your ideal restaurant')
|
121 |
+
io.queue().launch(share = True, debug = True)
|
task1_output_n_c1_sup4 (2).txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|