Spaces:
Running
Running
sebastiansarasti
commited on
Commit
•
b8c7cfd
1
Parent(s):
1151934
downloading the model from HF
Browse files
search.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from transformers import ViTModel, AutoModelForMaskedLM, AutoTokenizer, ViTImageProcessor, DistilBertModel
|
2 |
from pinecone import Pinecone
|
3 |
import torch
|
|
|
4 |
|
5 |
|
6 |
pc = Pinecone()
|
@@ -11,9 +12,6 @@ from io import BytesIO
|
|
11 |
import base64
|
12 |
from PIL import Image
|
13 |
|
14 |
-
import sys
|
15 |
-
|
16 |
-
sys.path.append('../src')
|
17 |
|
18 |
from model import CLIPChemistryModel, TextEncoderHead, ImageEncoderHead
|
19 |
|
@@ -25,7 +23,12 @@ image_encoder = ImageEncoderHead(model=IMAGE_BASE)
|
|
25 |
|
26 |
clip_model = CLIPChemistryModel(text_encoder=text_encoder, image_encoder=image_encoder)
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
te_final = clip_model.text_encoder
|
31 |
ie_final = clip_model.image_encoder
|
|
|
1 |
from transformers import ViTModel, AutoModelForMaskedLM, AutoTokenizer, ViTImageProcessor, DistilBertModel
|
2 |
from pinecone import Pinecone
|
3 |
import torch
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
|
6 |
|
7 |
pc = Pinecone()
|
|
|
12 |
import base64
|
13 |
from PIL import Image
|
14 |
|
|
|
|
|
|
|
15 |
|
16 |
from model import CLIPChemistryModel, TextEncoderHead, ImageEncoderHead
|
17 |
|
|
|
23 |
|
24 |
clip_model = CLIPChemistryModel(text_encoder=text_encoder, image_encoder=image_encoder)
|
25 |
|
26 |
+
model_name = "sebastiansarasti/clip_fashion"
|
27 |
+
filename = "best_model.pth"
|
28 |
+
|
29 |
+
file_path = hf_hub_download(repo_id=model_name, filename=filename)
|
30 |
+
|
31 |
+
clip_model.load_state_dict(torch.load('best_model_fashion.pth', map_location=torch.device('cpu')))
|
32 |
|
33 |
te_final = clip_model.text_encoder
|
34 |
ie_final = clip_model.image_encoder
|