Update app.py
Browse files
app.py
CHANGED
|
@@ -80,9 +80,19 @@ def load_glove_embeddings_gdrive(model_type):
|
|
| 80 |
word_index_temp = "word_index_dict_" + str(model_type) + "_temp.pkl"
|
| 81 |
embeddings_temp = "embeddings_" + str(model_type) + "_temp.npy"
|
| 82 |
|
| 83 |
-
#
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
# Load embeddings numpy
|
| 88 |
embeddings = np.load(embeddings_temp)
|
|
|
|
| 80 |
word_index_temp = "word_index_dict_" + str(model_type) + "_temp.pkl"
|
| 81 |
embeddings_temp = "embeddings_" + str(model_type) + "_temp.npy"
|
| 82 |
|
| 83 |
+
# Use a more robust unpickling method
|
| 84 |
+
try:
|
| 85 |
+
with open(word_index_temp, "rb") as f:
|
| 86 |
+
# Try different encoding methods
|
| 87 |
+
try:
|
| 88 |
+
word_index_dict = pickle.load(f)
|
| 89 |
+
except:
|
| 90 |
+
f.seek(0) # Reset file pointer
|
| 91 |
+
word_index_dict = pickle.load(f, encoding='bytes')
|
| 92 |
+
|
| 93 |
+
except Exception as e:
|
| 94 |
+
print(f"Error loading pickle file: {e}")
|
| 95 |
+
word_index_dict = {} # Provide a fallback empty dictionary
|
| 96 |
|
| 97 |
# Load embeddings numpy
|
| 98 |
embeddings = np.load(embeddings_temp)
|