Spaces:
Sleeping
Sleeping
Sarat Chandra
commited on
Commit
•
ec14c0e
1
Parent(s):
1fdedd6
initial commit
Browse files- .DS_Store +0 -0
- .gitignore +2 -0
- Dockerfile +32 -0
- app.py +42 -0
- embedding.ipynb +989 -0
- helloworld.py +12 -0
- images.csv +0 -0
- requirements.txt +5 -0
- static/scripts.js +59 -0
- static/styles.css +122 -0
- styles.csv +0 -0
- templates/index.html +39 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
KEYS.py
|
2 |
+
*.feather
|
Dockerfile
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use a Python base image
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
+
|
6 |
+
USER user
|
7 |
+
|
8 |
+
ENV HOME=/home/user \
|
9 |
+
PATH=/home/user/.local/bin:$PATH
|
10 |
+
|
11 |
+
WORKDIR $HOME/app
|
12 |
+
|
13 |
+
# Copy the required files to the working directory
|
14 |
+
COPY app.py .
|
15 |
+
COPY ./templates/index.html /code/templates/index.html
|
16 |
+
COPY ./static/styles.css /code/static/styles.css
|
17 |
+
COPY ./static/scripts.js /code/static/scripts.js
|
18 |
+
COPY ./requirements.txt /code/requirements.txt
|
19 |
+
|
20 |
+
# Install the required packages
|
21 |
+
RUN pip install --no-cache-dir -r /code/requirements.txt
|
22 |
+
|
23 |
+
# Get secret SECRET_EXAMPLE and clone it as repo at buildtime
|
24 |
+
RUN --mount=type=secret,id=GEMINI_API_KEY,mode=0444,required=true
|
25 |
+
|
26 |
+
COPY --chown=user . $HOME/app
|
27 |
+
|
28 |
+
# Expose the port that the Flask app will run on
|
29 |
+
EXPOSE 7860
|
30 |
+
|
31 |
+
# Start the Flask app
|
32 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, render_template
|
2 |
+
from flask_socketio import SocketIO
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
import google.generativeai as genai
|
6 |
+
# import KEYS
|
7 |
+
import os
|
8 |
+
|
9 |
+
app = Flask(__name__)
|
10 |
+
socketio = SocketIO(app)
|
11 |
+
|
12 |
+
# genai.configure(api_key=KEYS.api_key.GOOGLE_API_KEY)
|
13 |
+
genai.configure(api_key=os.environ.get("GEMINI_API_KEY"))
|
14 |
+
|
15 |
+
n_steps = 10
|
16 |
+
df = pd.DataFrame()
|
17 |
+
for i in range(0,n_steps):
|
18 |
+
df = pd.concat([df,pd.read_feather(f"data_{i}.feather")])
|
19 |
+
df.reset_index(inplace=True,drop=True)
|
20 |
+
|
21 |
+
def get_results(top_n = 6,query = "men shirt"):
|
22 |
+
query_embedding = genai.embed_content(model="models/text-embedding-004",
|
23 |
+
content=query,
|
24 |
+
task_type="retrieval_query")['embedding']
|
25 |
+
scores = df['embedding'].apply(lambda x: np.dot(x,query_embedding))
|
26 |
+
scores = scores.sort_values(ascending=False)[0:top_n]
|
27 |
+
return df.loc[scores.index][['productDisplayName','link']].to_numpy()
|
28 |
+
|
29 |
+
|
30 |
+
@app.route('/')
|
31 |
+
def index():
|
32 |
+
return render_template('index.html')
|
33 |
+
|
34 |
+
@socketio.on("search")
|
35 |
+
def get_products(query):
|
36 |
+
data = []
|
37 |
+
for x in get_results(query=query):
|
38 |
+
data.append({'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
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"import csv"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 9,
|
16 |
+
"metadata": {},
|
17 |
+
"outputs": [],
|
18 |
+
"source": [
|
19 |
+
"# Specify the path to your CSV file\n",
|
20 |
+
"file_path = 'styles.csv'\n",
|
21 |
+
"\n",
|
22 |
+
"headers = []\n",
|
23 |
+
"data = []\n",
|
24 |
+
"\n",
|
25 |
+
"# Open the CSV file\n",
|
26 |
+
"with open(file_path, mode='r', newline='') as file:\n",
|
27 |
+
" # Create a CSV reader object\n",
|
28 |
+
" csv_reader = csv.reader(file)\n",
|
29 |
+
" \n",
|
30 |
+
" # Iterate over each row in the CSV file\n",
|
31 |
+
" for row in csv_reader:\n",
|
32 |
+
" # Print each row (you can replace this with any other operation you want to perform on the row)\n",
|
33 |
+
" headers = row\n",
|
34 |
+
" break\n",
|
35 |
+
" for row in csv_reader:\n",
|
36 |
+
" if len(row) != 10:\n",
|
37 |
+
" pass\n",
|
38 |
+
" else:\n",
|
39 |
+
" data.append(row)"
|
40 |
+
]
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"cell_type": "code",
|
44 |
+
"execution_count": 10,
|
45 |
+
"metadata": {},
|
46 |
+
"outputs": [
|
47 |
+
{
|
48 |
+
"data": {
|
49 |
+
"text/html": [
|
50 |
+
"<div>\n",
|
51 |
+
"<style scoped>\n",
|
52 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
53 |
+
" vertical-align: middle;\n",
|
54 |
+
" }\n",
|
55 |
+
"\n",
|
56 |
+
" .dataframe tbody tr th {\n",
|
57 |
+
" vertical-align: top;\n",
|
58 |
+
" }\n",
|
59 |
+
"\n",
|
60 |
+
" .dataframe thead th {\n",
|
61 |
+
" text-align: right;\n",
|
62 |
+
" }\n",
|
63 |
+
"</style>\n",
|
64 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
65 |
+
" <thead>\n",
|
66 |
+
" <tr style=\"text-align: right;\">\n",
|
67 |
+
" <th></th>\n",
|
68 |
+
" <th>id</th>\n",
|
69 |
+
" <th>gender</th>\n",
|
70 |
+
" <th>masterCategory</th>\n",
|
71 |
+
" <th>subCategory</th>\n",
|
72 |
+
" <th>articleType</th>\n",
|
73 |
+
" <th>baseColour</th>\n",
|
74 |
+
" <th>season</th>\n",
|
75 |
+
" <th>year</th>\n",
|
76 |
+
" <th>usage</th>\n",
|
77 |
+
" <th>productDisplayName</th>\n",
|
78 |
+
" </tr>\n",
|
79 |
+
" </thead>\n",
|
80 |
+
" <tbody>\n",
|
81 |
+
" <tr>\n",
|
82 |
+
" <th>0</th>\n",
|
83 |
+
" <td>15970</td>\n",
|
84 |
+
" <td>Men</td>\n",
|
85 |
+
" <td>Apparel</td>\n",
|
86 |
+
" <td>Topwear</td>\n",
|
87 |
+
" <td>Shirts</td>\n",
|
88 |
+
" <td>Navy Blue</td>\n",
|
89 |
+
" <td>Fall</td>\n",
|
90 |
+
" <td>2011</td>\n",
|
91 |
+
" <td>Casual</td>\n",
|
92 |
+
" <td>Turtle Check Men Navy Blue Shirt</td>\n",
|
93 |
+
" </tr>\n",
|
94 |
+
" <tr>\n",
|
95 |
+
" <th>1</th>\n",
|
96 |
+
" <td>39386</td>\n",
|
97 |
+
" <td>Men</td>\n",
|
98 |
+
" <td>Apparel</td>\n",
|
99 |
+
" <td>Bottomwear</td>\n",
|
100 |
+
" <td>Jeans</td>\n",
|
101 |
+
" <td>Blue</td>\n",
|
102 |
+
" <td>Summer</td>\n",
|
103 |
+
" <td>2012</td>\n",
|
104 |
+
" <td>Casual</td>\n",
|
105 |
+
" <td>Peter England Men Party Blue Jeans</td>\n",
|
106 |
+
" </tr>\n",
|
107 |
+
" <tr>\n",
|
108 |
+
" <th>2</th>\n",
|
109 |
+
" <td>59263</td>\n",
|
110 |
+
" <td>Women</td>\n",
|
111 |
+
" <td>Accessories</td>\n",
|
112 |
+
" <td>Watches</td>\n",
|
113 |
+
" <td>Watches</td>\n",
|
114 |
+
" <td>Silver</td>\n",
|
115 |
+
" <td>Winter</td>\n",
|
116 |
+
" <td>2016</td>\n",
|
117 |
+
" <td>Casual</td>\n",
|
118 |
+
" <td>Titan Women Silver Watch</td>\n",
|
119 |
+
" </tr>\n",
|
120 |
+
" <tr>\n",
|
121 |
+
" <th>3</th>\n",
|
122 |
+
" <td>21379</td>\n",
|
123 |
+
" <td>Men</td>\n",
|
124 |
+
" <td>Apparel</td>\n",
|
125 |
+
" <td>Bottomwear</td>\n",
|
126 |
+
" <td>Track Pants</td>\n",
|
127 |
+
" <td>Black</td>\n",
|
128 |
+
" <td>Fall</td>\n",
|
129 |
+
" <td>2011</td>\n",
|
130 |
+
" <td>Casual</td>\n",
|
131 |
+
" <td>Manchester United Men Solid Black Track Pants</td>\n",
|
132 |
+
" </tr>\n",
|
133 |
+
" <tr>\n",
|
134 |
+
" <th>4</th>\n",
|
135 |
+
" <td>53759</td>\n",
|
136 |
+
" <td>Men</td>\n",
|
137 |
+
" <td>Apparel</td>\n",
|
138 |
+
" <td>Topwear</td>\n",
|
139 |
+
" <td>Tshirts</td>\n",
|
140 |
+
" <td>Grey</td>\n",
|
141 |
+
" <td>Summer</td>\n",
|
142 |
+
" <td>2012</td>\n",
|
143 |
+
" <td>Casual</td>\n",
|
144 |
+
" <td>Puma Men Grey T-shirt</td>\n",
|
145 |
+
" </tr>\n",
|
146 |
+
" <tr>\n",
|
147 |
+
" <th>...</th>\n",
|
148 |
+
" <td>...</td>\n",
|
149 |
+
" <td>...</td>\n",
|
150 |
+
" <td>...</td>\n",
|
151 |
+
" <td>...</td>\n",
|
152 |
+
" <td>...</td>\n",
|
153 |
+
" <td>...</td>\n",
|
154 |
+
" <td>...</td>\n",
|
155 |
+
" <td>...</td>\n",
|
156 |
+
" <td>...</td>\n",
|
157 |
+
" <td>...</td>\n",
|
158 |
+
" </tr>\n",
|
159 |
+
" <tr>\n",
|
160 |
+
" <th>44419</th>\n",
|
161 |
+
" <td>17036</td>\n",
|
162 |
+
" <td>Men</td>\n",
|
163 |
+
" <td>Footwear</td>\n",
|
164 |
+
" <td>Shoes</td>\n",
|
165 |
+
" <td>Casual Shoes</td>\n",
|
166 |
+
" <td>White</td>\n",
|
167 |
+
" <td>Summer</td>\n",
|
168 |
+
" <td>2013</td>\n",
|
169 |
+
" <td>Casual</td>\n",
|
170 |
+
" <td>Gas Men Caddy Casual Shoe</td>\n",
|
171 |
+
" </tr>\n",
|
172 |
+
" <tr>\n",
|
173 |
+
" <th>44420</th>\n",
|
174 |
+
" <td>6461</td>\n",
|
175 |
+
" <td>Men</td>\n",
|
176 |
+
" <td>Footwear</td>\n",
|
177 |
+
" <td>Flip Flops</td>\n",
|
178 |
+
" <td>Flip Flops</td>\n",
|
179 |
+
" <td>Red</td>\n",
|
180 |
+
" <td>Summer</td>\n",
|
181 |
+
" <td>2011</td>\n",
|
182 |
+
" <td>Casual</td>\n",
|
183 |
+
" <td>Lotto Men's Soccer Track Flip Flop</td>\n",
|
184 |
+
" </tr>\n",
|
185 |
+
" <tr>\n",
|
186 |
+
" <th>44421</th>\n",
|
187 |
+
" <td>18842</td>\n",
|
188 |
+
" <td>Men</td>\n",
|
189 |
+
" <td>Apparel</td>\n",
|
190 |
+
" <td>Topwear</td>\n",
|
191 |
+
" <td>Tshirts</td>\n",
|
192 |
+
" <td>Blue</td>\n",
|
193 |
+
" <td>Fall</td>\n",
|
194 |
+
" <td>2011</td>\n",
|
195 |
+
" <td>Casual</td>\n",
|
196 |
+
" <td>Puma Men Graphic Stellar Blue Tshirt</td>\n",
|
197 |
+
" </tr>\n",
|
198 |
+
" <tr>\n",
|
199 |
+
" <th>44422</th>\n",
|
200 |
+
" <td>46694</td>\n",
|
201 |
+
" <td>Women</td>\n",
|
202 |
+
" <td>Personal Care</td>\n",
|
203 |
+
" <td>Fragrance</td>\n",
|
204 |
+
" <td>Perfume and Body Mist</td>\n",
|
205 |
+
" <td>Blue</td>\n",
|
206 |
+
" <td>Spring</td>\n",
|
207 |
+
" <td>2017</td>\n",
|
208 |
+
" <td>Casual</td>\n",
|
209 |
+
" <td>Rasasi Women Blue Lady Perfume</td>\n",
|
210 |
+
" </tr>\n",
|
211 |
+
" <tr>\n",
|
212 |
+
" <th>44423</th>\n",
|
213 |
+
" <td>51623</td>\n",
|
214 |
+
" <td>Women</td>\n",
|
215 |
+
" <td>Accessories</td>\n",
|
216 |
+
" <td>Watches</td>\n",
|
217 |
+
" <td>Watches</td>\n",
|
218 |
+
" <td>Pink</td>\n",
|
219 |
+
" <td>Winter</td>\n",
|
220 |
+
" <td>2016</td>\n",
|
221 |
+
" <td>Casual</td>\n",
|
222 |
+
" <td>Fossil Women Pink Dial Chronograph Watch ES3050</td>\n",
|
223 |
+
" </tr>\n",
|
224 |
+
" </tbody>\n",
|
225 |
+
"</table>\n",
|
226 |
+
"<p>44424 rows × 10 columns</p>\n",
|
227 |
+
"</div>"
|
228 |
+
],
|
229 |
+
"text/plain": [
|
230 |
+
" id gender masterCategory subCategory articleType \\\n",
|
231 |
+
"0 15970 Men Apparel Topwear Shirts \n",
|
232 |
+
"1 39386 Men Apparel Bottomwear Jeans \n",
|
233 |
+
"2 59263 Women Accessories Watches Watches \n",
|
234 |
+
"3 21379 Men Apparel Bottomwear Track Pants \n",
|
235 |
+
"4 53759 Men Apparel Topwear Tshirts \n",
|
236 |
+
"... ... ... ... ... ... \n",
|
237 |
+
"44419 17036 Men Footwear Shoes Casual Shoes \n",
|
238 |
+
"44420 6461 Men Footwear Flip Flops Flip Flops \n",
|
239 |
+
"44421 18842 Men Apparel Topwear Tshirts \n",
|
240 |
+
"44422 46694 Women Personal Care Fragrance Perfume and Body Mist \n",
|
241 |
+
"44423 51623 Women Accessories Watches Watches \n",
|
242 |
+
"\n",
|
243 |
+
" baseColour season year usage \\\n",
|
244 |
+
"0 Navy Blue Fall 2011 Casual \n",
|
245 |
+
"1 Blue Summer 2012 Casual \n",
|
246 |
+
"2 Silver Winter 2016 Casual \n",
|
247 |
+
"3 Black Fall 2011 Casual \n",
|
248 |
+
"4 Grey Summer 2012 Casual \n",
|
249 |
+
"... ... ... ... ... \n",
|
250 |
+
"44419 White Summer 2013 Casual \n",
|
251 |
+
"44420 Red Summer 2011 Casual \n",
|
252 |
+
"44421 Blue Fall 2011 Casual \n",
|
253 |
+
"44422 Blue Spring 2017 Casual \n",
|
254 |
+
"44423 Pink Winter 2016 Casual \n",
|
255 |
+
"\n",
|
256 |
+
" productDisplayName \n",
|
257 |
+
"0 Turtle Check Men Navy Blue Shirt \n",
|
258 |
+
"1 Peter England Men Party Blue Jeans \n",
|
259 |
+
"2 Titan Women Silver Watch \n",
|
260 |
+
"3 Manchester United Men Solid Black Track Pants \n",
|
261 |
+
"4 Puma Men Grey T-shirt \n",
|
262 |
+
"... ... \n",
|
263 |
+
"44419 Gas Men Caddy Casual Shoe \n",
|
264 |
+
"44420 Lotto Men's Soccer Track Flip Flop \n",
|
265 |
+
"44421 Puma Men Graphic Stellar Blue Tshirt \n",
|
266 |
+
"44422 Rasasi Women Blue Lady Perfume \n",
|
267 |
+
"44423 Fossil Women Pink Dial Chronograph Watch ES3050 \n",
|
268 |
+
"\n",
|
269 |
+
"[44424 rows x 10 columns]"
|
270 |
+
]
|
271 |
+
},
|
272 |
+
"execution_count": 10,
|
273 |
+
"metadata": {},
|
274 |
+
"output_type": "execute_result"
|
275 |
+
}
|
276 |
+
],
|
277 |
+
"source": [
|
278 |
+
"styles_df = pd.DataFrame(data,columns=headers)\n",
|
279 |
+
"styles_df"
|
280 |
+
]
|
281 |
+
},
|
282 |
+
{
|
283 |
+
"cell_type": "code",
|
284 |
+
"execution_count": 11,
|
285 |
+
"metadata": {},
|
286 |
+
"outputs": [
|
287 |
+
{
|
288 |
+
"data": {
|
289 |
+
"text/html": [
|
290 |
+
"<div>\n",
|
291 |
+
"<style scoped>\n",
|
292 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
293 |
+
" vertical-align: middle;\n",
|
294 |
+
" }\n",
|
295 |
+
"\n",
|
296 |
+
" .dataframe tbody tr th {\n",
|
297 |
+
" vertical-align: top;\n",
|
298 |
+
" }\n",
|
299 |
+
"\n",
|
300 |
+
" .dataframe thead th {\n",
|
301 |
+
" text-align: right;\n",
|
302 |
+
" }\n",
|
303 |
+
"</style>\n",
|
304 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
305 |
+
" <thead>\n",
|
306 |
+
" <tr style=\"text-align: right;\">\n",
|
307 |
+
" <th></th>\n",
|
308 |
+
" <th>filename</th>\n",
|
309 |
+
" <th>link</th>\n",
|
310 |
+
" </tr>\n",
|
311 |
+
" </thead>\n",
|
312 |
+
" <tbody>\n",
|
313 |
+
" <tr>\n",
|
314 |
+
" <th>0</th>\n",
|
315 |
+
" <td>15970.jpg</td>\n",
|
316 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
317 |
+
" </tr>\n",
|
318 |
+
" <tr>\n",
|
319 |
+
" <th>1</th>\n",
|
320 |
+
" <td>39386.jpg</td>\n",
|
321 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
322 |
+
" </tr>\n",
|
323 |
+
" <tr>\n",
|
324 |
+
" <th>2</th>\n",
|
325 |
+
" <td>59263.jpg</td>\n",
|
326 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
327 |
+
" </tr>\n",
|
328 |
+
" <tr>\n",
|
329 |
+
" <th>3</th>\n",
|
330 |
+
" <td>21379.jpg</td>\n",
|
331 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
332 |
+
" </tr>\n",
|
333 |
+
" <tr>\n",
|
334 |
+
" <th>4</th>\n",
|
335 |
+
" <td>53759.jpg</td>\n",
|
336 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
337 |
+
" </tr>\n",
|
338 |
+
" <tr>\n",
|
339 |
+
" <th>...</th>\n",
|
340 |
+
" <td>...</td>\n",
|
341 |
+
" <td>...</td>\n",
|
342 |
+
" </tr>\n",
|
343 |
+
" <tr>\n",
|
344 |
+
" <th>44441</th>\n",
|
345 |
+
" <td>17036.jpg</td>\n",
|
346 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
347 |
+
" </tr>\n",
|
348 |
+
" <tr>\n",
|
349 |
+
" <th>44442</th>\n",
|
350 |
+
" <td>6461.jpg</td>\n",
|
351 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
352 |
+
" </tr>\n",
|
353 |
+
" <tr>\n",
|
354 |
+
" <th>44443</th>\n",
|
355 |
+
" <td>18842.jpg</td>\n",
|
356 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
357 |
+
" </tr>\n",
|
358 |
+
" <tr>\n",
|
359 |
+
" <th>44444</th>\n",
|
360 |
+
" <td>46694.jpg</td>\n",
|
361 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
362 |
+
" </tr>\n",
|
363 |
+
" <tr>\n",
|
364 |
+
" <th>44445</th>\n",
|
365 |
+
" <td>51623.jpg</td>\n",
|
366 |
+
" <td>http://assets.myntassets.com/assets/images/516...</td>\n",
|
367 |
+
" </tr>\n",
|
368 |
+
" </tbody>\n",
|
369 |
+
"</table>\n",
|
370 |
+
"<p>44446 rows × 2 columns</p>\n",
|
371 |
+
"</div>"
|
372 |
+
],
|
373 |
+
"text/plain": [
|
374 |
+
" filename link\n",
|
375 |
+
"0 15970.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
376 |
+
"1 39386.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
377 |
+
"2 59263.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
378 |
+
"3 21379.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
379 |
+
"4 53759.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
380 |
+
"... ... ...\n",
|
381 |
+
"44441 17036.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
382 |
+
"44442 6461.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
383 |
+
"44443 18842.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
384 |
+
"44444 46694.jpg http://assets.myntassets.com/v1/images/style/p...\n",
|
385 |
+
"44445 51623.jpg http://assets.myntassets.com/assets/images/516...\n",
|
386 |
+
"\n",
|
387 |
+
"[44446 rows x 2 columns]"
|
388 |
+
]
|
389 |
+
},
|
390 |
+
"execution_count": 11,
|
391 |
+
"metadata": {},
|
392 |
+
"output_type": "execute_result"
|
393 |
+
}
|
394 |
+
],
|
395 |
+
"source": [
|
396 |
+
"images_df = pd.read_csv(\"images.csv\")\n",
|
397 |
+
"images_df"
|
398 |
+
]
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"cell_type": "code",
|
402 |
+
"execution_count": 12,
|
403 |
+
"metadata": {},
|
404 |
+
"outputs": [],
|
405 |
+
"source": [
|
406 |
+
"styles_df['filename'] = styles_df['id'] + \".jpg\""
|
407 |
+
]
|
408 |
+
},
|
409 |
+
{
|
410 |
+
"cell_type": "code",
|
411 |
+
"execution_count": 13,
|
412 |
+
"metadata": {},
|
413 |
+
"outputs": [],
|
414 |
+
"source": [
|
415 |
+
"main_df = pd.DataFrame()\n",
|
416 |
+
"main_df = pd.merge(styles_df,images_df,how=\"inner\",on='filename')"
|
417 |
+
]
|
418 |
+
},
|
419 |
+
{
|
420 |
+
"cell_type": "code",
|
421 |
+
"execution_count": 15,
|
422 |
+
"metadata": {},
|
423 |
+
"outputs": [],
|
424 |
+
"source": [
|
425 |
+
"main_df.drop(columns=['filename'],inplace=True)"
|
426 |
+
]
|
427 |
+
},
|
428 |
+
{
|
429 |
+
"cell_type": "code",
|
430 |
+
"execution_count": 16,
|
431 |
+
"metadata": {},
|
432 |
+
"outputs": [],
|
433 |
+
"source": [
|
434 |
+
"from langchain.docstore.document import Document"
|
435 |
+
]
|
436 |
+
},
|
437 |
+
{
|
438 |
+
"cell_type": "code",
|
439 |
+
"execution_count": 17,
|
440 |
+
"metadata": {},
|
441 |
+
"outputs": [
|
442 |
+
{
|
443 |
+
"data": {
|
444 |
+
"text/plain": [
|
445 |
+
"Index(['id', 'gender', 'masterCategory', 'subCategory', 'articleType',\n",
|
446 |
+
" 'baseColour', 'season', 'year', 'usage', 'productDisplayName', 'link'],\n",
|
447 |
+
" dtype='object')"
|
448 |
+
]
|
449 |
+
},
|
450 |
+
"execution_count": 17,
|
451 |
+
"metadata": {},
|
452 |
+
"output_type": "execute_result"
|
453 |
+
}
|
454 |
+
],
|
455 |
+
"source": [
|
456 |
+
"main_df.columns"
|
457 |
+
]
|
458 |
+
},
|
459 |
+
{
|
460 |
+
"cell_type": "code",
|
461 |
+
"execution_count": 30,
|
462 |
+
"metadata": {},
|
463 |
+
"outputs": [],
|
464 |
+
"source": [
|
465 |
+
"def make_text(x):\n",
|
466 |
+
" return (f\"\"\"\n",
|
467 |
+
" Gender is {x['gender']} and \n",
|
468 |
+
" masterCategory is {x['masterCategory']} and \n",
|
469 |
+
" subCategory is {x['subCategory']} and \n",
|
470 |
+
" articleType is {x['articleType']} and \n",
|
471 |
+
" baseColour is {x['baseColour']} and \n",
|
472 |
+
" season is {x['season']} and \n",
|
473 |
+
" year is {x['year']} and \n",
|
474 |
+
" usage is {x['usage']} and \n",
|
475 |
+
" productDisplayName is {x['productDisplayName']}\n",
|
476 |
+
" \"\"\" , x['id'])"
|
477 |
+
]
|
478 |
+
},
|
479 |
+
{
|
480 |
+
"cell_type": "code",
|
481 |
+
"execution_count": 34,
|
482 |
+
"metadata": {},
|
483 |
+
"outputs": [],
|
484 |
+
"source": [
|
485 |
+
"docs_content = main_df.apply(lambda x: make_text(x),axis=1)"
|
486 |
+
]
|
487 |
+
},
|
488 |
+
{
|
489 |
+
"cell_type": "code",
|
490 |
+
"execution_count": 35,
|
491 |
+
"metadata": {},
|
492 |
+
"outputs": [],
|
493 |
+
"source": [
|
494 |
+
"docs = []\n",
|
495 |
+
"for text,id in docs_content:\n",
|
496 |
+
" docs.append(Document(page_content=text,metadata={'id':id}))"
|
497 |
+
]
|
498 |
+
},
|
499 |
+
{
|
500 |
+
"cell_type": "code",
|
501 |
+
"execution_count": 38,
|
502 |
+
"metadata": {},
|
503 |
+
"outputs": [],
|
504 |
+
"source": [
|
505 |
+
"import KEYS\n",
|
506 |
+
"from langchain.vectorstores import Chroma\n",
|
507 |
+
"from langchain_google_genai import GoogleGenerativeAIEmbeddings"
|
508 |
+
]
|
509 |
+
},
|
510 |
+
{
|
511 |
+
"cell_type": "code",
|
512 |
+
"execution_count": 39,
|
513 |
+
"metadata": {},
|
514 |
+
"outputs": [],
|
515 |
+
"source": [
|
516 |
+
"gemini_embeddings = GoogleGenerativeAIEmbeddings(model=\"models/text-embedding-004\",google_api_key=KEYS.api_key.GOOGLE_API_KEY)"
|
517 |
+
]
|
518 |
+
},
|
519 |
+
{
|
520 |
+
"cell_type": "code",
|
521 |
+
"execution_count": 40,
|
522 |
+
"metadata": {},
|
523 |
+
"outputs": [],
|
524 |
+
"source": [
|
525 |
+
"# Save to disk\n",
|
526 |
+
"vectorstore = Chroma.from_documents(\n",
|
527 |
+
" documents=docs, # Data\n",
|
528 |
+
" embedding=gemini_embeddings, # Embedding model\n",
|
529 |
+
" persist_directory=\"./chroma_db\" # Directory to save data\n",
|
530 |
+
" )"
|
531 |
+
]
|
532 |
+
},
|
533 |
+
{
|
534 |
+
"cell_type": "code",
|
535 |
+
"execution_count": 41,
|
536 |
+
"metadata": {},
|
537 |
+
"outputs": [],
|
538 |
+
"source": [
|
539 |
+
"import chromadb"
|
540 |
+
]
|
541 |
+
},
|
542 |
+
{
|
543 |
+
"cell_type": "code",
|
544 |
+
"execution_count": 42,
|
545 |
+
"metadata": {},
|
546 |
+
"outputs": [],
|
547 |
+
"source": [
|
548 |
+
"client = chromadb.PersistentClient(path=\"./chroma_db\")"
|
549 |
+
]
|
550 |
+
},
|
551 |
+
{
|
552 |
+
"cell_type": "code",
|
553 |
+
"execution_count": 43,
|
554 |
+
"metadata": {},
|
555 |
+
"outputs": [],
|
556 |
+
"source": [
|
557 |
+
"collection = client.list_collections()[0]"
|
558 |
+
]
|
559 |
+
},
|
560 |
+
{
|
561 |
+
"cell_type": "code",
|
562 |
+
"execution_count": 49,
|
563 |
+
"metadata": {},
|
564 |
+
"outputs": [],
|
565 |
+
"source": [
|
566 |
+
"data = collection.get(include=['documents','metadatas','embeddings'])\n",
|
567 |
+
"\n",
|
568 |
+
"embedding_data = []\n",
|
569 |
+
"\n",
|
570 |
+
"for id,embedding,_ in zip(data['metadatas'],data['embeddings'],data['documents']):\n",
|
571 |
+
" embedding_data.append([id['id'],embedding])"
|
572 |
+
]
|
573 |
+
},
|
574 |
+
{
|
575 |
+
"cell_type": "code",
|
576 |
+
"execution_count": 51,
|
577 |
+
"metadata": {},
|
578 |
+
"outputs": [],
|
579 |
+
"source": [
|
580 |
+
"embeds_df = pd.DataFrame(embedding_data,columns=['id','embedding'])"
|
581 |
+
]
|
582 |
+
},
|
583 |
+
{
|
584 |
+
"cell_type": "code",
|
585 |
+
"execution_count": 65,
|
586 |
+
"metadata": {},
|
587 |
+
"outputs": [],
|
588 |
+
"source": [
|
589 |
+
"final_df = pd.DataFrame()\n",
|
590 |
+
"final_df = pd.merge(main_df,embeds_df,how=\"inner\",on='id')"
|
591 |
+
]
|
592 |
+
},
|
593 |
+
{
|
594 |
+
"cell_type": "code",
|
595 |
+
"execution_count": 66,
|
596 |
+
"metadata": {},
|
597 |
+
"outputs": [],
|
598 |
+
"source": [
|
599 |
+
"n_steps = 10\n",
|
600 |
+
"step_size = final_df.shape[0] // n_steps + 1\n",
|
601 |
+
"max_index = final_df.shape[0]\n",
|
602 |
+
"for i in range(0,n_steps):\n",
|
603 |
+
" final_df.iloc[i * step_size : min(max_index , (i + 1) * step_size)].reset_index().to_feather(f\"data_{i}.feather\")"
|
604 |
+
]
|
605 |
+
},
|
606 |
+
{
|
607 |
+
"cell_type": "code",
|
608 |
+
"execution_count": 68,
|
609 |
+
"metadata": {},
|
610 |
+
"outputs": [
|
611 |
+
{
|
612 |
+
"data": {
|
613 |
+
"text/html": [
|
614 |
+
"<div>\n",
|
615 |
+
"<style scoped>\n",
|
616 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
617 |
+
" vertical-align: middle;\n",
|
618 |
+
" }\n",
|
619 |
+
"\n",
|
620 |
+
" .dataframe tbody tr th {\n",
|
621 |
+
" vertical-align: top;\n",
|
622 |
+
" }\n",
|
623 |
+
"\n",
|
624 |
+
" .dataframe thead th {\n",
|
625 |
+
" text-align: right;\n",
|
626 |
+
" }\n",
|
627 |
+
"</style>\n",
|
628 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
629 |
+
" <thead>\n",
|
630 |
+
" <tr style=\"text-align: right;\">\n",
|
631 |
+
" <th></th>\n",
|
632 |
+
" <th>index</th>\n",
|
633 |
+
" <th>id</th>\n",
|
634 |
+
" <th>gender</th>\n",
|
635 |
+
" <th>masterCategory</th>\n",
|
636 |
+
" <th>subCategory</th>\n",
|
637 |
+
" <th>articleType</th>\n",
|
638 |
+
" <th>baseColour</th>\n",
|
639 |
+
" <th>season</th>\n",
|
640 |
+
" <th>year</th>\n",
|
641 |
+
" <th>usage</th>\n",
|
642 |
+
" <th>productDisplayName</th>\n",
|
643 |
+
" <th>link</th>\n",
|
644 |
+
" <th>embedding</th>\n",
|
645 |
+
" </tr>\n",
|
646 |
+
" </thead>\n",
|
647 |
+
" <tbody>\n",
|
648 |
+
" <tr>\n",
|
649 |
+
" <th>0</th>\n",
|
650 |
+
" <td>0</td>\n",
|
651 |
+
" <td>15970</td>\n",
|
652 |
+
" <td>Men</td>\n",
|
653 |
+
" <td>Apparel</td>\n",
|
654 |
+
" <td>Topwear</td>\n",
|
655 |
+
" <td>Shirts</td>\n",
|
656 |
+
" <td>Navy Blue</td>\n",
|
657 |
+
" <td>Fall</td>\n",
|
658 |
+
" <td>2011</td>\n",
|
659 |
+
" <td>Casual</td>\n",
|
660 |
+
" <td>Turtle Check Men Navy Blue Shirt</td>\n",
|
661 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
662 |
+
" <td>[-0.04959992691874504, 0.030256308615207672, 0...</td>\n",
|
663 |
+
" </tr>\n",
|
664 |
+
" <tr>\n",
|
665 |
+
" <th>1</th>\n",
|
666 |
+
" <td>1</td>\n",
|
667 |
+
" <td>39386</td>\n",
|
668 |
+
" <td>Men</td>\n",
|
669 |
+
" <td>Apparel</td>\n",
|
670 |
+
" <td>Bottomwear</td>\n",
|
671 |
+
" <td>Jeans</td>\n",
|
672 |
+
" <td>Blue</td>\n",
|
673 |
+
" <td>Summer</td>\n",
|
674 |
+
" <td>2012</td>\n",
|
675 |
+
" <td>Casual</td>\n",
|
676 |
+
" <td>Peter England Men Party Blue Jeans</td>\n",
|
677 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
678 |
+
" <td>[-0.04374004527926445, 0.0014770406996831298, ...</td>\n",
|
679 |
+
" </tr>\n",
|
680 |
+
" <tr>\n",
|
681 |
+
" <th>2</th>\n",
|
682 |
+
" <td>2</td>\n",
|
683 |
+
" <td>59263</td>\n",
|
684 |
+
" <td>Women</td>\n",
|
685 |
+
" <td>Accessories</td>\n",
|
686 |
+
" <td>Watches</td>\n",
|
687 |
+
" <td>Watches</td>\n",
|
688 |
+
" <td>Silver</td>\n",
|
689 |
+
" <td>Winter</td>\n",
|
690 |
+
" <td>2016</td>\n",
|
691 |
+
" <td>Casual</td>\n",
|
692 |
+
" <td>Titan Women Silver Watch</td>\n",
|
693 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
694 |
+
" <td>[-0.017907867208123207, -0.008326959796249866,...</td>\n",
|
695 |
+
" </tr>\n",
|
696 |
+
" <tr>\n",
|
697 |
+
" <th>3</th>\n",
|
698 |
+
" <td>3</td>\n",
|
699 |
+
" <td>21379</td>\n",
|
700 |
+
" <td>Men</td>\n",
|
701 |
+
" <td>Apparel</td>\n",
|
702 |
+
" <td>Bottomwear</td>\n",
|
703 |
+
" <td>Track Pants</td>\n",
|
704 |
+
" <td>Black</td>\n",
|
705 |
+
" <td>Fall</td>\n",
|
706 |
+
" <td>2011</td>\n",
|
707 |
+
" <td>Casual</td>\n",
|
708 |
+
" <td>Manchester United Men Solid Black Track Pants</td>\n",
|
709 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
710 |
+
" <td>[-0.06801198422908783, 0.011990022845566273, 0...</td>\n",
|
711 |
+
" </tr>\n",
|
712 |
+
" <tr>\n",
|
713 |
+
" <th>4</th>\n",
|
714 |
+
" <td>4</td>\n",
|
715 |
+
" <td>53759</td>\n",
|
716 |
+
" <td>Men</td>\n",
|
717 |
+
" <td>Apparel</td>\n",
|
718 |
+
" <td>Topwear</td>\n",
|
719 |
+
" <td>Tshirts</td>\n",
|
720 |
+
" <td>Grey</td>\n",
|
721 |
+
" <td>Summer</td>\n",
|
722 |
+
" <td>2012</td>\n",
|
723 |
+
" <td>Casual</td>\n",
|
724 |
+
" <td>Puma Men Grey T-shirt</td>\n",
|
725 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
726 |
+
" <td>[-0.08272361010313034, 0.017822109162807465, 0...</td>\n",
|
727 |
+
" </tr>\n",
|
728 |
+
" <tr>\n",
|
729 |
+
" <th>...</th>\n",
|
730 |
+
" <td>...</td>\n",
|
731 |
+
" <td>...</td>\n",
|
732 |
+
" <td>...</td>\n",
|
733 |
+
" <td>...</td>\n",
|
734 |
+
" <td>...</td>\n",
|
735 |
+
" <td>...</td>\n",
|
736 |
+
" <td>...</td>\n",
|
737 |
+
" <td>...</td>\n",
|
738 |
+
" <td>...</td>\n",
|
739 |
+
" <td>...</td>\n",
|
740 |
+
" <td>...</td>\n",
|
741 |
+
" <td>...</td>\n",
|
742 |
+
" <td>...</td>\n",
|
743 |
+
" </tr>\n",
|
744 |
+
" <tr>\n",
|
745 |
+
" <th>4432</th>\n",
|
746 |
+
" <td>44419</td>\n",
|
747 |
+
" <td>17036</td>\n",
|
748 |
+
" <td>Men</td>\n",
|
749 |
+
" <td>Footwear</td>\n",
|
750 |
+
" <td>Shoes</td>\n",
|
751 |
+
" <td>Casual Shoes</td>\n",
|
752 |
+
" <td>White</td>\n",
|
753 |
+
" <td>Summer</td>\n",
|
754 |
+
" <td>2013</td>\n",
|
755 |
+
" <td>Casual</td>\n",
|
756 |
+
" <td>Gas Men Caddy Casual Shoe</td>\n",
|
757 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
758 |
+
" <td>[-0.062232204, -0.011351791, -0.0027062385, 0....</td>\n",
|
759 |
+
" </tr>\n",
|
760 |
+
" <tr>\n",
|
761 |
+
" <th>4433</th>\n",
|
762 |
+
" <td>44420</td>\n",
|
763 |
+
" <td>6461</td>\n",
|
764 |
+
" <td>Men</td>\n",
|
765 |
+
" <td>Footwear</td>\n",
|
766 |
+
" <td>Flip Flops</td>\n",
|
767 |
+
" <td>Flip Flops</td>\n",
|
768 |
+
" <td>Red</td>\n",
|
769 |
+
" <td>Summer</td>\n",
|
770 |
+
" <td>2011</td>\n",
|
771 |
+
" <td>Casual</td>\n",
|
772 |
+
" <td>Lotto Men's Soccer Track Flip Flop</td>\n",
|
773 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
774 |
+
" <td>[-0.06830623, 0.023115562, 0.028224507, 0.0283...</td>\n",
|
775 |
+
" </tr>\n",
|
776 |
+
" <tr>\n",
|
777 |
+
" <th>4434</th>\n",
|
778 |
+
" <td>44421</td>\n",
|
779 |
+
" <td>18842</td>\n",
|
780 |
+
" <td>Men</td>\n",
|
781 |
+
" <td>Apparel</td>\n",
|
782 |
+
" <td>Topwear</td>\n",
|
783 |
+
" <td>Tshirts</td>\n",
|
784 |
+
" <td>Blue</td>\n",
|
785 |
+
" <td>Fall</td>\n",
|
786 |
+
" <td>2011</td>\n",
|
787 |
+
" <td>Casual</td>\n",
|
788 |
+
" <td>Puma Men Graphic Stellar Blue Tshirt</td>\n",
|
789 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
790 |
+
" <td>[-0.058011707, 0.022569647, 0.0293498, 0.00073...</td>\n",
|
791 |
+
" </tr>\n",
|
792 |
+
" <tr>\n",
|
793 |
+
" <th>4435</th>\n",
|
794 |
+
" <td>44422</td>\n",
|
795 |
+
" <td>46694</td>\n",
|
796 |
+
" <td>Women</td>\n",
|
797 |
+
" <td>Personal Care</td>\n",
|
798 |
+
" <td>Fragrance</td>\n",
|
799 |
+
" <td>Perfume and Body Mist</td>\n",
|
800 |
+
" <td>Blue</td>\n",
|
801 |
+
" <td>Spring</td>\n",
|
802 |
+
" <td>2017</td>\n",
|
803 |
+
" <td>Casual</td>\n",
|
804 |
+
" <td>Rasasi Women Blue Lady Perfume</td>\n",
|
805 |
+
" <td>http://assets.myntassets.com/v1/images/style/p...</td>\n",
|
806 |
+
" <td>[-0.0127937365, 0.002269573, 0.016845196, -0.0...</td>\n",
|
807 |
+
" </tr>\n",
|
808 |
+
" <tr>\n",
|
809 |
+
" <th>4436</th>\n",
|
810 |
+
" <td>44423</td>\n",
|
811 |
+
" <td>51623</td>\n",
|
812 |
+
" <td>Women</td>\n",
|
813 |
+
" <td>Accessories</td>\n",
|
814 |
+
" <td>Watches</td>\n",
|
815 |
+
" <td>Watches</td>\n",
|
816 |
+
" <td>Pink</td>\n",
|
817 |
+
" <td>Winter</td>\n",
|
818 |
+
" <td>2016</td>\n",
|
819 |
+
" <td>Casual</td>\n",
|
820 |
+
" <td>Fossil Women Pink Dial Chronograph Watch ES3050</td>\n",
|
821 |
+
" <td>http://assets.myntassets.com/assets/images/516...</td>\n",
|
822 |
+
" <td>[-0.007802535, -0.030409014, -0.01775647, -0.0...</td>\n",
|
823 |
+
" </tr>\n",
|
824 |
+
" </tbody>\n",
|
825 |
+
"</table>\n",
|
826 |
+
"<p>44424 rows × 13 columns</p>\n",
|
827 |
+
"</div>"
|
828 |
+
],
|
829 |
+
"text/plain": [
|
830 |
+
" index id gender masterCategory subCategory articleType \\\n",
|
831 |
+
"0 0 15970 Men Apparel Topwear Shirts \n",
|
832 |
+
"1 1 39386 Men Apparel Bottomwear Jeans \n",
|
833 |
+
"2 2 59263 Women Accessories Watches Watches \n",
|
834 |
+
"3 3 21379 Men Apparel Bottomwear Track Pants \n",
|
835 |
+
"4 4 53759 Men Apparel Topwear Tshirts \n",
|
836 |
+
"... ... ... ... ... ... ... \n",
|
837 |
+
"4432 44419 17036 Men Footwear Shoes Casual Shoes \n",
|
838 |
+
"4433 44420 6461 Men Footwear Flip Flops Flip Flops \n",
|
839 |
+
"4434 44421 18842 Men Apparel Topwear Tshirts \n",
|
840 |
+
"4435 44422 46694 Women Personal Care Fragrance Perfume and Body Mist \n",
|
841 |
+
"4436 44423 51623 Women Accessories Watches Watches \n",
|
842 |
+
"\n",
|
843 |
+
" baseColour season year usage \\\n",
|
844 |
+
"0 Navy Blue Fall 2011 Casual \n",
|
845 |
+
"1 Blue Summer 2012 Casual \n",
|
846 |
+
"2 Silver Winter 2016 Casual \n",
|
847 |
+
"3 Black Fall 2011 Casual \n",
|
848 |
+
"4 Grey Summer 2012 Casual \n",
|
849 |
+
"... ... ... ... ... \n",
|
850 |
+
"4432 White Summer 2013 Casual \n",
|
851 |
+
"4433 Red Summer 2011 Casual \n",
|
852 |
+
"4434 Blue Fall 2011 Casual \n",
|
853 |
+
"4435 Blue Spring 2017 Casual \n",
|
854 |
+
"4436 Pink Winter 2016 Casual \n",
|
855 |
+
"\n",
|
856 |
+
" productDisplayName \\\n",
|
857 |
+
"0 Turtle Check Men Navy Blue Shirt \n",
|
858 |
+
"1 Peter England Men Party Blue Jeans \n",
|
859 |
+
"2 Titan Women Silver Watch \n",
|
860 |
+
"3 Manchester United Men Solid Black Track Pants \n",
|
861 |
+
"4 Puma Men Grey T-shirt \n",
|
862 |
+
"... ... \n",
|
863 |
+
"4432 Gas Men Caddy Casual Shoe \n",
|
864 |
+
"4433 Lotto Men's Soccer Track Flip Flop \n",
|
865 |
+
"4434 Puma Men Graphic Stellar Blue Tshirt \n",
|
866 |
+
"4435 Rasasi Women Blue Lady Perfume \n",
|
867 |
+
"4436 Fossil Women Pink Dial Chronograph Watch ES3050 \n",
|
868 |
+
"\n",
|
869 |
+
" link \\\n",
|
870 |
+
"0 http://assets.myntassets.com/v1/images/style/p... \n",
|
871 |
+
"1 http://assets.myntassets.com/v1/images/style/p... \n",
|
872 |
+
"2 http://assets.myntassets.com/v1/images/style/p... \n",
|
873 |
+
"3 http://assets.myntassets.com/v1/images/style/p... \n",
|
874 |
+
"4 http://assets.myntassets.com/v1/images/style/p... \n",
|
875 |
+
"... ... \n",
|
876 |
+
"4432 http://assets.myntassets.com/v1/images/style/p... \n",
|
877 |
+
"4433 http://assets.myntassets.com/v1/images/style/p... \n",
|
878 |
+
"4434 http://assets.myntassets.com/v1/images/style/p... \n",
|
879 |
+
"4435 http://assets.myntassets.com/v1/images/style/p... \n",
|
880 |
+
"4436 http://assets.myntassets.com/assets/images/516... \n",
|
881 |
+
"\n",
|
882 |
+
" embedding \n",
|
883 |
+
"0 [-0.04959992691874504, 0.030256308615207672, 0... \n",
|
884 |
+
"1 [-0.04374004527926445, 0.0014770406996831298, ... \n",
|
885 |
+
"2 [-0.017907867208123207, -0.008326959796249866,... \n",
|
886 |
+
"3 [-0.06801198422908783, 0.011990022845566273, 0... \n",
|
887 |
+
"4 [-0.08272361010313034, 0.017822109162807465, 0... \n",
|
888 |
+
"... ... \n",
|
889 |
+
"4432 [-0.062232204, -0.011351791, -0.0027062385, 0.... \n",
|
890 |
+
"4433 [-0.06830623, 0.023115562, 0.028224507, 0.0283... \n",
|
891 |
+
"4434 [-0.058011707, 0.022569647, 0.0293498, 0.00073... \n",
|
892 |
+
"4435 [-0.0127937365, 0.002269573, 0.016845196, -0.0... \n",
|
893 |
+
"4436 [-0.007802535, -0.030409014, -0.01775647, -0.0... \n",
|
894 |
+
"\n",
|
895 |
+
"[44424 rows x 13 columns]"
|
896 |
+
]
|
897 |
+
},
|
898 |
+
"execution_count": 68,
|
899 |
+
"metadata": {},
|
900 |
+
"output_type": "execute_result"
|
901 |
+
}
|
902 |
+
],
|
903 |
+
"source": [
|
904 |
+
"df = pd.DataFrame()\n",
|
905 |
+
"for i in range(0,n_steps):\n",
|
906 |
+
" df = pd.concat([df,pd.read_feather(f\"data_{i}.feather\")])"
|
907 |
+
]
|
908 |
+
},
|
909 |
+
{
|
910 |
+
"cell_type": "code",
|
911 |
+
"execution_count": 54,
|
912 |
+
"metadata": {},
|
913 |
+
"outputs": [],
|
914 |
+
"source": [
|
915 |
+
"import google.generativeai as genai\n",
|
916 |
+
"import numpy as np\n",
|
917 |
+
"genai.configure(api_key=KEYS.api_key.GOOGLE_API_KEY)"
|
918 |
+
]
|
919 |
+
},
|
920 |
+
{
|
921 |
+
"cell_type": "code",
|
922 |
+
"execution_count": 77,
|
923 |
+
"metadata": {},
|
924 |
+
"outputs": [],
|
925 |
+
"source": [
|
926 |
+
"def get_results(top_n = 6,query = \"men shirt\"):\n",
|
927 |
+
" query_embedding = genai.embed_content(model=\"models/text-embedding-004\",\n",
|
928 |
+
" content=query,\n",
|
929 |
+
" task_type=\"retrieval_query\")['embedding']\n",
|
930 |
+
" scores = final_df['embedding'].apply(lambda x: np.dot(x,query_embedding))\n",
|
931 |
+
" scores = scores.sort_values(ascending=False)[0:top_n]\n",
|
932 |
+
" return final_df.loc[scores.index][['productDisplayName','link']].to_numpy()"
|
933 |
+
]
|
934 |
+
},
|
935 |
+
{
|
936 |
+
"cell_type": "code",
|
937 |
+
"execution_count": 78,
|
938 |
+
"metadata": {},
|
939 |
+
"outputs": [
|
940 |
+
{
|
941 |
+
"data": {
|
942 |
+
"text/plain": [
|
943 |
+
"array([['French Connection Men Black Shirt',\n",
|
944 |
+
" 'http://assets.myntassets.com/v1/images/style/properties/9a6ead385ff56471fc6f376da807c617_images.jpg'],\n",
|
945 |
+
" ['Flying Machine Men Check Green Shirts',\n",
|
946 |
+
" 'http://assets.myntassets.com/v1/images/style/properties/3f4c47753110a3f6c093e6bc3e4123df_images.jpg'],\n",
|
947 |
+
" ['Peter England Men Multi Coloured Casual Shirt',\n",
|
948 |
+
" 'http://assets.myntassets.com/v1/images/style/properties/19d194298ca2009e5cc6f0184f2a0f7d_images.jpg'],\n",
|
949 |
+
" ['Flying Machine Men Printed White Shirt',\n",
|
950 |
+
" 'http://assets.myntassets.com/v1/images/style/properties/02fc0c611bca206ed4cd2e0bd17bfd8d_images.jpg'],\n",
|
951 |
+
" ['Flying Machine Men Check Blue Shirts',\n",
|
952 |
+
" 'http://assets.myntassets.com/v1/images/style/properties/c2984f58de4e666b5a3fe6a3b8e36f23_images.jpg'],\n",
|
953 |
+
" ['Flying Machine Men Check Blue Shirts',\n",
|
954 |
+
" 'http://assets.myntassets.com/v1/images/style/properties/eaca895bbca83fbc080ce26ced471a0d_images.jpg']],\n",
|
955 |
+
" dtype=object)"
|
956 |
+
]
|
957 |
+
},
|
958 |
+
"execution_count": 78,
|
959 |
+
"metadata": {},
|
960 |
+
"output_type": "execute_result"
|
961 |
+
}
|
962 |
+
],
|
963 |
+
"source": [
|
964 |
+
"get_results()"
|
965 |
+
]
|
966 |
+
}
|
967 |
+
],
|
968 |
+
"metadata": {
|
969 |
+
"kernelspec": {
|
970 |
+
"display_name": "Python 3",
|
971 |
+
"language": "python",
|
972 |
+
"name": "python3"
|
973 |
+
},
|
974 |
+
"language_info": {
|
975 |
+
"codemirror_mode": {
|
976 |
+
"name": "ipython",
|
977 |
+
"version": 3
|
978 |
+
},
|
979 |
+
"file_extension": ".py",
|
980 |
+
"mimetype": "text/x-python",
|
981 |
+
"name": "python",
|
982 |
+
"nbconvert_exporter": "python",
|
983 |
+
"pygments_lexer": "ipython3",
|
984 |
+
"version": "3.9.6"
|
985 |
+
}
|
986 |
+
},
|
987 |
+
"nbformat": 4,
|
988 |
+
"nbformat_minor": 2
|
989 |
+
}
|
helloworld.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
+
from flask_socketio import SocketIO
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
socketio = SocketIO(app)
|
6 |
+
|
7 |
+
@app.route('/')
|
8 |
+
def index():
|
9 |
+
return 'Hello, World!'
|
10 |
+
|
11 |
+
if __name__ == '__main__':
|
12 |
+
socketio.run(app,port=7860,allow_unsafe_werkzeug=True,host='0.0.0.0')
|
images.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
flask
|
2 |
+
flask-socketio
|
3 |
+
numpy
|
4 |
+
pandas
|
5 |
+
google-generativeai
|
static/scripts.js
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
document.addEventListener("DOMContentLoaded", () => {
|
2 |
+
const socket = io();
|
3 |
+
|
4 |
+
function performSearch() {
|
5 |
+
// Collect all included search history
|
6 |
+
const searches = [];
|
7 |
+
document.querySelectorAll('.search-item input:checked').forEach(item => {
|
8 |
+
searches.push(item.parentElement.innerText.trim());
|
9 |
+
});
|
10 |
+
|
11 |
+
if (searches.length === 0) return;
|
12 |
+
|
13 |
+
// Combine search history into a single text with a prompt prefix
|
14 |
+
const combinedSearchText = `Search history: ${searches.join(' ')}`;
|
15 |
+
|
16 |
+
// Emit search event to server with combined search text
|
17 |
+
socket.emit('search', combinedSearchText);
|
18 |
+
}
|
19 |
+
|
20 |
+
function search() {
|
21 |
+
const searchInput = document.getElementById('search-input').value;
|
22 |
+
if (searchInput.trim() === "") return;
|
23 |
+
|
24 |
+
// Add search term to the search history
|
25 |
+
const searchList = document.getElementById('search-list');
|
26 |
+
const newSearch = document.createElement('div');
|
27 |
+
newSearch.className = 'search-item';
|
28 |
+
newSearch.innerHTML = `<input type="checkbox" checked> ${searchInput}`;
|
29 |
+
newSearch.querySelector('input').addEventListener('change', performSearch);
|
30 |
+
searchList.appendChild(newSearch);
|
31 |
+
|
32 |
+
performSearch();
|
33 |
+
|
34 |
+
document.getElementById('search-input').value = '';
|
35 |
+
}
|
36 |
+
|
37 |
+
function reset() {
|
38 |
+
document.getElementById('search-list').innerHTML = '';
|
39 |
+
document.getElementById('cards').innerHTML = '';
|
40 |
+
document.getElementById('search-input').value = '';
|
41 |
+
}
|
42 |
+
|
43 |
+
// Listen for data event from the server
|
44 |
+
socket.on('data', function(data) {
|
45 |
+
const cards = document.getElementById('cards');
|
46 |
+
cards.innerHTML = ''; // Clear previous cards
|
47 |
+
|
48 |
+
data.forEach(item => {
|
49 |
+
const card = document.createElement('div');
|
50 |
+
card.className = 'card';
|
51 |
+
card.innerHTML = `<img src="${item.url}" alt="Product Image"><p>${item.name}</p>`;
|
52 |
+
cards.appendChild(card);
|
53 |
+
});
|
54 |
+
});
|
55 |
+
|
56 |
+
// Attach the search and reset functions to global scope
|
57 |
+
window.search = search;
|
58 |
+
window.reset = reset;
|
59 |
+
});
|
static/styles.css
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
font-family: Arial, sans-serif;
|
3 |
+
background-color: #f0f0f0;
|
4 |
+
margin: 0;
|
5 |
+
padding: 0;
|
6 |
+
display: flex;
|
7 |
+
justify-content: center;
|
8 |
+
}
|
9 |
+
|
10 |
+
.container {
|
11 |
+
background-color: #ffffff;
|
12 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
13 |
+
border-radius: 8px;
|
14 |
+
width: 80%;
|
15 |
+
max-width: 1000px;
|
16 |
+
padding: 20px;
|
17 |
+
box-sizing: border-box;
|
18 |
+
}
|
19 |
+
|
20 |
+
.header {
|
21 |
+
text-align: center;
|
22 |
+
margin-bottom: 20px;
|
23 |
+
}
|
24 |
+
|
25 |
+
.search-section {
|
26 |
+
margin-bottom: 20px;
|
27 |
+
}
|
28 |
+
|
29 |
+
.search-section input[type="text"] {
|
30 |
+
width: calc(100% - 20px);
|
31 |
+
padding: 10px;
|
32 |
+
border: 1px solid #ddd;
|
33 |
+
border-radius: 4px;
|
34 |
+
margin-bottom: 10px;
|
35 |
+
box-sizing: border-box;
|
36 |
+
box-shadow: 0px 10px 30px 0px rgba(0,0,0,0.1);
|
37 |
+
border-color: chocolate;
|
38 |
+
}
|
39 |
+
|
40 |
+
.buttons {
|
41 |
+
display: flex;
|
42 |
+
justify-content: center;
|
43 |
+
}
|
44 |
+
|
45 |
+
.search-btn {
|
46 |
+
padding: 10px 20px;
|
47 |
+
border: none;
|
48 |
+
border-radius: 4px;
|
49 |
+
background-color: #007bff;
|
50 |
+
color: white;
|
51 |
+
cursor: pointer;
|
52 |
+
margin-right: 20px;
|
53 |
+
}
|
54 |
+
|
55 |
+
.search-btn:active {
|
56 |
+
background-color: #0056b3;
|
57 |
+
}
|
58 |
+
|
59 |
+
.reset-btn {
|
60 |
+
padding: 10px 20px;
|
61 |
+
border: none;
|
62 |
+
border-radius: 4px;
|
63 |
+
background-color: #dc3545;
|
64 |
+
color: white;
|
65 |
+
cursor: pointer;
|
66 |
+
}
|
67 |
+
|
68 |
+
.reset-btn:active {
|
69 |
+
background-color: #b21f2d;
|
70 |
+
}
|
71 |
+
|
72 |
+
.content {
|
73 |
+
display: flex;
|
74 |
+
justify-content: space-between;
|
75 |
+
}
|
76 |
+
|
77 |
+
.cards {
|
78 |
+
display: grid;
|
79 |
+
grid-template-columns: repeat(3, 1fr);
|
80 |
+
gap: 20px;
|
81 |
+
width: 70%;
|
82 |
+
}
|
83 |
+
|
84 |
+
.card {
|
85 |
+
background-color: #f9f9f9;
|
86 |
+
border-radius: 8px;
|
87 |
+
padding: 20px;
|
88 |
+
text-align: center;
|
89 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
90 |
+
}
|
91 |
+
|
92 |
+
.card img {
|
93 |
+
width: 150px;
|
94 |
+
height: 150px;
|
95 |
+
object-fit: cover;
|
96 |
+
border-radius: 4px;
|
97 |
+
}
|
98 |
+
|
99 |
+
.searches {
|
100 |
+
width: 25%;
|
101 |
+
padding-left: 20px;
|
102 |
+
border-left: 2px solid #f0f0f0;
|
103 |
+
overflow-y: auto;
|
104 |
+
max-height: 400px; /* Adjust this height as needed */
|
105 |
+
}
|
106 |
+
|
107 |
+
.searches h3 {
|
108 |
+
margin-top: 0;
|
109 |
+
}
|
110 |
+
|
111 |
+
.search-item {
|
112 |
+
background-color: #e9e9e9;
|
113 |
+
padding: 10px;
|
114 |
+
border-radius: 4px;
|
115 |
+
margin-bottom: 10px;
|
116 |
+
display: flex;
|
117 |
+
align-items: center;
|
118 |
+
}
|
119 |
+
|
120 |
+
.search-item input[type="checkbox"] {
|
121 |
+
margin-right: 10px;
|
122 |
+
}
|
styles.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
templates/index.html
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Fashion Product Search</title>
|
7 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
|
11 |
+
<div class="container">
|
12 |
+
<div class="header">
|
13 |
+
<h1>LLM Search - Fashion Products</h1>
|
14 |
+
<h4>A natural language search with filters</h4>
|
15 |
+
</div>
|
16 |
+
<div class="search-section">
|
17 |
+
<input type="text" id="search-input" placeholder="Describe your product">
|
18 |
+
<div class="buttons">
|
19 |
+
<button class="search-btn" onclick="search()">Search</button>
|
20 |
+
<button class="reset-btn" onclick="reset()">Reset</button>
|
21 |
+
</div>
|
22 |
+
</div>
|
23 |
+
<div class="content">
|
24 |
+
<div class="cards" id="cards">
|
25 |
+
<!-- Product cards will be inserted here -->
|
26 |
+
</div>
|
27 |
+
<div class="searches">
|
28 |
+
<h3>Your Searches</h3>
|
29 |
+
<div id="search-list">
|
30 |
+
<!-- Search history will be inserted here -->
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
|
36 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.min.js"></script>
|
37 |
+
<script src="{{ url_for('static', filename='scripts.js') }}"></script>
|
38 |
+
</body>
|
39 |
+
</html>
|