CrystalMo commited on
Commit
fffc0a5
·
verified ·
1 Parent(s): e06331f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -23
app.py CHANGED
@@ -67,32 +67,11 @@ def download_glove_embeddings_gdrive(model_type):
67
 
68
  # @st.cache_data()
69
  def load_glove_embeddings_gdrive(model_type):
70
- # word_index_temp = "word_index_dict_" + str(model_type) + "_temp.pkl"
71
- # embeddings_temp = "embeddings_" + str(model_type) + "_temp.npy"
72
-
73
- # # Load word index dictionary
74
- # word_index_dict = pickle.load(open(word_index_temp, "rb"), encoding="latin")
75
-
76
- # # Load embeddings numpy
77
- # embeddings = np.load(embeddings_temp)
78
-
79
- # return word_index_dict, embeddings
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)
 
67
 
68
  # @st.cache_data()
69
  def load_glove_embeddings_gdrive(model_type):
 
 
 
 
 
 
 
 
 
 
70
  word_index_temp = "word_index_dict_" + str(model_type) + "_temp.pkl"
71
  embeddings_temp = "embeddings_" + str(model_type) + "_temp.npy"
72
 
73
+ # Load word index dictionary
74
+ word_index_dict = pickle.load(open(word_index_temp, "rb"), encoding="latin")
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  # Load embeddings numpy
77
  embeddings = np.load(embeddings_temp)