Spaces:
Runtime error
Runtime error
Update recommendation.py
Browse files- recommendation.py +2 -2
recommendation.py
CHANGED
@@ -24,7 +24,7 @@ def row_wise_normalize_and_concatenate(array1, array2):
|
|
24 |
normalized_array1 = array1 / np.linalg.norm(array1, axis=1, keepdims=True)
|
25 |
normalized_array2 = array2 / np.linalg.norm(array2, axis=1, keepdims=True)
|
26 |
|
27 |
-
concatenated_array = np.concatenate((normalized_array1, normalized_array2), axis=
|
28 |
|
29 |
return concatenated_array
|
30 |
|
@@ -37,7 +37,7 @@ def get_recommendations(image, title, k):
|
|
37 |
title_embeds = model.encode([title], normalize_embeddings=True)
|
38 |
image = transforms.ToTensor()(image.convert("L"))
|
39 |
image_embeds = encoder(image).detach().numpy()
|
40 |
-
final_embeds = np.concatenate((image_embeds,title_embeds), axis=
|
41 |
|
42 |
candidates = image_embedding_index.topk(final_embeds,k=k)
|
43 |
# title_candidates = text_embedding_index.topk(title_embeds, k=k)
|
|
|
24 |
normalized_array1 = array1 / np.linalg.norm(array1, axis=1, keepdims=True)
|
25 |
normalized_array2 = array2 / np.linalg.norm(array2, axis=1, keepdims=True)
|
26 |
|
27 |
+
concatenated_array = np.concatenate((normalized_array1, normalized_array2), axis=1)
|
28 |
|
29 |
return concatenated_array
|
30 |
|
|
|
37 |
title_embeds = model.encode([title], normalize_embeddings=True)
|
38 |
image = transforms.ToTensor()(image.convert("L"))
|
39 |
image_embeds = encoder(image).detach().numpy()
|
40 |
+
final_embeds = np.concatenate((image_embeds,title_embeds), axis=1)
|
41 |
|
42 |
candidates = image_embedding_index.topk(final_embeds,k=k)
|
43 |
# title_candidates = text_embedding_index.topk(title_embeds, k=k)
|