Ransaka commited on
Commit
f678cb2
·
verified ·
1 Parent(s): 0409001

Update recommendation.py

Browse files
Files changed (1) hide show
  1. recommendation.py +2 -4
recommendation.py CHANGED
@@ -3,13 +3,11 @@ from sentence_transformers import SentenceTransformer
3
  from torchvision import transforms
4
  from models.encoder import Encoder
5
  from indexer import Indexer
6
- import dotenv
7
  import torch
8
  import os
9
 
10
- dotenv.load_dotenv()
11
 
12
- model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
13
 
14
  encoder = Encoder()
15
  encoder.load_state_dict(torch.load('./models/encoder.bin', map_location=torch.device('cpu')))
@@ -25,7 +23,7 @@ image_embedding_index = Indexer(latent_data)
25
 
26
  def get_recommendations(image, title):
27
  # title = [dataset[product_id]['title']]
28
- title_embeds = torch.randn(1,768)#model.encode(title, normalize_embeddings=True)
29
  image = transforms.ToTensor()(image.convert("L"))
30
  image_embeds = encoder(image).detach().numpy()
31
 
 
3
  from torchvision import transforms
4
  from models.encoder import Encoder
5
  from indexer import Indexer
 
6
  import torch
7
  import os
8
 
 
9
 
10
+ model = SentenceTransformer('intfloat/multilingual-e5-base')
11
 
12
  encoder = Encoder()
13
  encoder.load_state_dict(torch.load('./models/encoder.bin', map_location=torch.device('cpu')))
 
23
 
24
  def get_recommendations(image, title):
25
  # title = [dataset[product_id]['title']]
26
+ title_embeds = model.encode(title, normalize_embeddings=True)
27
  image = transforms.ToTensor()(image.convert("L"))
28
  image_embeds = encoder(image).detach().numpy()
29