Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,7 @@ from werkzeug.utils import secure_filename
|
|
27 |
from geopy.geocoders import Nominatim
|
28 |
import pickle
|
29 |
import numpy as np
|
|
|
30 |
|
31 |
# Configure logging
|
32 |
logging.basicConfig(level=logging.INFO)
|
@@ -59,7 +60,14 @@ conversation_context = {}
|
|
59 |
def load_sentence_transformer():
|
60 |
print("Loading SentenceTransformer model...")
|
61 |
try:
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if not os.path.exists(MODEL_PATH):
|
64 |
raise FileNotFoundError(f"Model state dict not found at {MODEL_PATH}. Please ensure the file exists.")
|
65 |
state_dict = torch.load(MODEL_PATH, map_location=device)
|
|
|
27 |
from geopy.geocoders import Nominatim
|
28 |
import pickle
|
29 |
import numpy as np
|
30 |
+
from huggingface_hub import snapshot_download
|
31 |
|
32 |
# Configure logging
|
33 |
logging.basicConfig(level=logging.INFO)
|
|
|
60 |
def load_sentence_transformer():
|
61 |
print("Loading SentenceTransformer model...")
|
62 |
try:
|
63 |
+
# First download the model
|
64 |
+
model_path = snapshot_download(
|
65 |
+
repo_id="jinaai/jina-embeddings-v3",
|
66 |
+
trust_remote_code=True
|
67 |
+
)
|
68 |
+
# Then load it with SentenceTransformer
|
69 |
+
model_embedding = SentenceTransformer(model_path).to(device)
|
70 |
+
|
71 |
if not os.path.exists(MODEL_PATH):
|
72 |
raise FileNotFoundError(f"Model state dict not found at {MODEL_PATH}. Please ensure the file exists.")
|
73 |
state_dict = torch.load(MODEL_PATH, map_location=device)
|