ThornRugal commited on
Commit
0b60ac0
1 Parent(s): 18ee68e

update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -65,18 +65,18 @@ def get_predict_result(index,score,threshold,max_len):
65
  res = merge_set_to_list([set(i) for i in y_dict[res_index]])
66
  return res,x_dict[res_index]
67
 
68
- vec = np.empty(shape=[0,768],dtype="float32")
69
- bsize = 256
70
- with torch.no_grad():
71
- for i in range(0,len(x),bsize):
72
- tmp = model.encode(x[i:i+bsize])
73
- vec = np.concatenate([vec,tmp])
74
-
75
-
76
- index = faiss.IndexFlatIP(768)
77
- faiss.normalize_L2(vec)
78
- index.add(vec)
79
- faiss.write_index(index,"all_index.faiss")
80
  index = faiss.read_index("all_index.faiss")
81
 
82
  def predict_label(x,threshold=0.85,n_nearest=10,max_result_len=3):
 
65
  res = merge_set_to_list([set(i) for i in y_dict[res_index]])
66
  return res,x_dict[res_index]
67
 
68
+ # vec = np.empty(shape=[0,768],dtype="float32")
69
+ # bsize = 256
70
+ # with torch.no_grad():
71
+ # for i in range(0,len(x),bsize):
72
+ # tmp = model.encode(x[i:i+bsize])
73
+ # vec = np.concatenate([vec,tmp])
74
+
75
+
76
+ # index = faiss.IndexFlatIP(768)
77
+ # faiss.normalize_L2(vec)
78
+ # index.add(vec)
79
+ # faiss.write_index(index,"all_index.faiss")
80
  index = faiss.read_index("all_index.faiss")
81
 
82
  def predict_label(x,threshold=0.85,n_nearest=10,max_result_len=3):