Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,7 +66,6 @@ def hybrid_scale(dense, sparse, alpha):
|
|
66 |
'values': [v * (1 - alpha) for v in sparse['values']]
|
67 |
}
|
68 |
hdense = [v * alpha for v in dense]
|
69 |
-
|
70 |
return hdense, hsparse
|
71 |
|
72 |
|
@@ -78,9 +77,7 @@ def process_input(query, slider_value):
|
|
78 |
pattern = r"(?=.*\b" + r"\b)(?=.*\b".join(map(re.escape, search_words)) + r"\b)"
|
79 |
filtered_items = [item for item in item_list if re.search(pattern, item)]
|
80 |
print(f"Filtered items: {filtered_items}")
|
81 |
-
# filtered_df = fashion.filter(lambda x: x['productDisplayName'] in filtered_items)
|
82 |
filtered_df = fashion_df[fashion_df['productDisplayName'].isin(filtered_items)]
|
83 |
-
print(f"Length of filtered_df: {len(filtered_df)}")
|
84 |
#####################
|
85 |
try:
|
86 |
slider_value = float(slider_value)
|
@@ -98,26 +95,12 @@ def process_input(query, slider_value):
|
|
98 |
imgs = [images[int(r["id"])] for r in result["matches"]]
|
99 |
matches = [x["metadata"]['productDisplayName'] for x in result["matches"]]
|
100 |
|
101 |
-
|
102 |
-
print(f"1st matches: {matches}")
|
103 |
-
##############################
|
104 |
-
|
105 |
-
###########
|
106 |
-
# exact_match = filtered_df.filter(lambda x: x['productDisplayName'] == query)[0]['productDisplayName']
|
107 |
-
# exact_img = filtered_df.filter(lambda x: x['productDisplayName'] == query)[0]['image
|
108 |
-
|
109 |
-
# exact_match = filtered_df.loc[filtered_df['productDisplayName']==query, 'productDisplayName'].iat[0]
|
110 |
-
# print(f"Exact match: {exact_match}")
|
111 |
-
# exact_img = filtered_df.loc[filtered_df['productDisplayName']==query, 'image'].iat[0]
|
112 |
-
|
113 |
if query in filtered_items:
|
114 |
-
exact_match = filtered_df.loc[filtered_df['productDisplayName']==query, 'productDisplayName'].iat[0]
|
115 |
exact_img = filtered_df.loc[filtered_df['productDisplayName']==query, 'image'].iat[0]
|
116 |
imgs.insert(0, exact_img)
|
117 |
-
matches.insert(0,
|
118 |
-
# if exact_match:
|
119 |
-
# imgs.insert(0, exact_img)
|
120 |
-
# matches.insert(0, exact_match)
|
121 |
##########
|
122 |
|
123 |
print(f"No. of matching images: {len(imgs)}")
|
@@ -134,11 +117,8 @@ def update_textbox(choice):
|
|
134 |
|
135 |
def text_process(search_string):
|
136 |
search_words = search_string.title().split()
|
137 |
-
|
138 |
pattern = r"(?=.*\b" + r"\b)(?=.*\b".join(map(re.escape, search_words)) + r"\b)"
|
139 |
-
|
140 |
filtered_items = [item for item in item_list if re.search(pattern, item)]
|
141 |
-
|
142 |
return gr.update(visible=True), gr.update(choices=filtered_items, value=filtered_items[0] if filtered_items else "")
|
143 |
|
144 |
|
|
|
66 |
'values': [v * (1 - alpha) for v in sparse['values']]
|
67 |
}
|
68 |
hdense = [v * alpha for v in dense]
|
|
|
69 |
return hdense, hsparse
|
70 |
|
71 |
|
|
|
77 |
pattern = r"(?=.*\b" + r"\b)(?=.*\b".join(map(re.escape, search_words)) + r"\b)"
|
78 |
filtered_items = [item for item in item_list if re.search(pattern, item)]
|
79 |
print(f"Filtered items: {filtered_items}")
|
|
|
80 |
filtered_df = fashion_df[fashion_df['productDisplayName'].isin(filtered_items)]
|
|
|
81 |
#####################
|
82 |
try:
|
83 |
slider_value = float(slider_value)
|
|
|
95 |
imgs = [images[int(r["id"])] for r in result["matches"]]
|
96 |
matches = [x["metadata"]['productDisplayName'] for x in result["matches"]]
|
97 |
|
98 |
+
##########
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
if query in filtered_items:
|
100 |
+
# exact_match = filtered_df.loc[filtered_df['productDisplayName']==query, 'productDisplayName'].iat[0]
|
101 |
exact_img = filtered_df.loc[filtered_df['productDisplayName']==query, 'image'].iat[0]
|
102 |
imgs.insert(0, exact_img)
|
103 |
+
matches.insert(0, query)
|
|
|
|
|
|
|
104 |
##########
|
105 |
|
106 |
print(f"No. of matching images: {len(imgs)}")
|
|
|
117 |
|
118 |
def text_process(search_string):
|
119 |
search_words = search_string.title().split()
|
|
|
120 |
pattern = r"(?=.*\b" + r"\b)(?=.*\b".join(map(re.escape, search_words)) + r"\b)"
|
|
|
121 |
filtered_items = [item for item in item_list if re.search(pattern, item)]
|
|
|
122 |
return gr.update(visible=True), gr.update(choices=filtered_items, value=filtered_items[0] if filtered_items else "")
|
123 |
|
124 |
|