subhankarfynd commited on
Commit
ae76b85
·
1 Parent(s): 38abcfe

Add initial files

Browse files
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import streamlit as st
3
+ from html_information import html
4
+
5
+
6
+ def read_pickle_files(pickle_file):
7
+ with open(pickle_file, 'rb') as f:
8
+ return pickle.load(f)
9
+
10
+
11
+ def streamlit_carousel(header_name: str, rec_item_url: list,
12
+ rec_item_name: list) -> None:
13
+ st.header(header_name)
14
+ if header_name == "Up-Sell Recommendations" or header_name == "Cross-Sell Recommendations":
15
+ st.write("Based on Products added to the Cart")
16
+ mid_section = ""
17
+ for index, value in enumerate(rec_item_url):
18
+ mid_section += """<div class="item"><div id="image-container"><img src='""" + str(value) + """' /></div><p>""" + str(rec_item_name[index]) + """</p></div>"""
19
+
20
+ mid_html = html + mid_section + """</div></div></body>"""
21
+ st.markdown(mid_html, unsafe_allow_html=True)
22
+
23
+ def get_mapped_values(uid_list, dict_map):
24
+ res = []
25
+ for val in uid_list:
26
+ res.append(dict_map[val])
27
+ return res
28
+
29
+ uid_name_map = read_pickle_files("uid_name_map.pkl")
30
+ uid_url_map = read_pickle_files("uid_url_map.pkl")
31
+ uid_brand_map = read_pickle_files("uid_brand_map.pkl")
32
+ uid_category_map = read_pickle_files("uid_category_map.pkl")
33
+ trending_uid_list = read_pickle_files("trending_uid_list.pkl")
34
+ category_uid_dict = read_pickle_files("category_uid_dict.pkl")
35
+ brand_name_dict = read_pickle_files("brand_uid_dict.pkl")
36
+
37
+ st.header("Trending Products Recommendations")
38
+ st.subheader("Trending Products")
39
+ trending_name_list = get_mapped_values(trending_uid_list, uid_name_map)
40
+ trending_url_list = get_mapped_values(trending_uid_list, uid_url_map)
41
+ streamlit_carousel("Trending Products", trending_url_list, trending_name_list)
42
+
43
+ st.subheader("Trending Category Products")
44
+ category_list = list(category_uid_dict.keys())
45
+ category = st.selectbox("Select Category", category_list)
46
+ category_heading = "Trending " + category + " Products"
47
+ selected_category_uid_list = category_uid_dict[category]
48
+ selected_category_name_list = get_mapped_values(selected_category_uid_list, uid_name_map)
49
+ selected_category_url_list = get_mapped_values(selected_category_uid_list, uid_url_map)
50
+ streamlit_carousel(category_heading, selected_category_url_list, selected_category_name_list)
51
+
52
+ st.subheader("Trending Brands Products")
53
+ brand_list = list(brand_name_dict.keys())
54
+ brand = st.selectbox("Select Brand", brand_list)
55
+ brand_heading = "Trending " + brand + " Products"
56
+ selected_brand_uid_list = brand_name_dict[brand]
57
+ selected_brand_name_list = get_mapped_values(selected_brand_uid_list, uid_name_map)
58
+ selected_brand_url_list = get_mapped_values(selected_brand_uid_list, uid_url_map)
59
+ streamlit_carousel(brand_heading, selected_brand_url_list, selected_brand_name_list)
brand_uid_dict.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:844f00def6ebc9aaf304e3a2f4729f599c963daa28c392b56f3daebf6e9a10f8
3
+ size 10098
category_uid_dict.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4bd55ebb8e666c648075b2c0438f529514b24d872aefdb6a45e47095dc55b76d
3
+ size 11851
html_information.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html = """
2
+ <style>
3
+ body{
4
+ font-family: sans-serif;
5
+ }
6
+ h1{
7
+ font-weight: 100;
8
+ }
9
+ .container{
10
+ width: 100%;
11
+ display:block;
12
+ overflow:hidden;
13
+ }
14
+ .carousel{
15
+ display:block;
16
+ width: 100%;
17
+ height: 320px;
18
+ background: white;
19
+ overflow-x: scroll;
20
+ padding: 10px;
21
+ margin: 0;
22
+ white-space: nowrap;
23
+ border-top: 2px solid rgba(0, 0, 0, 0.1);
24
+ border-bottom: 2px solid rgba(0, 0, 0, 0.1);
25
+ }
26
+ .item {
27
+ display: inline-block;
28
+ overflow: hidden;
29
+ width: 250px;
30
+ margin: 0 10px;
31
+ height: calc(100%);
32
+ background: rgba(0, 0, 0, 0.05) no-repeat center center;
33
+ background-size: cover;
34
+ position:relative;
35
+ border-radius: 20px;
36
+ box-shadow: 0 0 10px #dfdfdf;
37
+ }
38
+ .item p {
39
+ padding: 20px;
40
+ word-break: break-all;
41
+ white-space: break-spaces;
42
+ overflow: hidden;
43
+ display: -webkit-box;
44
+ -webkit-line-clamp: 4;
45
+ -webkit-box-orient: vertical;
46
+ margin: 0;
47
+ align: center;
48
+ }
49
+ #image-container{
50
+ width: 100%;
51
+ height: 60%;
52
+ text-align:center;
53
+ font-size: 9em;
54
+ color: white;
55
+ overflow: hidden;
56
+ }
57
+ #image-container img{
58
+ width: 100%;
59
+ height: 100%;
60
+ object-fit: contain;
61
+ }
62
+
63
+ </style>
64
+ </head>
65
+ <body>
66
+ <div class="container">
67
+ <div class="carousel">
68
+
69
+ """
trending_uid_list.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5c2dfe2393ad642249372e42b6fd0fdacbf65c589694b3468704cdc23ed5c3b
3
+ size 9598
uid_brand_map.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd53e18d037efce5b12c3943fc8b0fda5150faa0ea6f3b2716a94f0731defa13
3
+ size 174178
uid_category_map.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edc8ae3b1c1f0c3c48d70027a9899c74915938b1c8fa1f816122a71299945641
3
+ size 201288
uid_name_map.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2baf082fe3aadc989ca78b9f1c46403d652d26b410d77cc9897e2e6a1c0d80e5
3
+ size 490344
uid_url_map.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad60e3e3b88ae91d266b5ede301b2f748999bbd141e240021be40c49d4af4db4
3
+ size 1403171