Skip to content

Commit a3ee455

Browse files
authored
Add files via upload
1 parent c22b912 commit a3ee455

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

infer-web.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from i18n.i18n import I18nAuto
1717
from configs.config import Config
1818
from sklearn.cluster import MiniBatchKMeans
19-
import torch
19+
import torch,platform
2020
import numpy as np
2121
import gradio as gr
2222
import faiss
@@ -673,24 +673,6 @@ def train_index(exp_dir1, version19):
673673
"%s/trained_IVF%s_Flat_nprobe_%s_%s_%s.index"
674674
% (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
675675
)
676-
try:
677-
os.link(
678-
"%s/trained_IVF%s_Flat_nprobe_%s_%s_%s.index"
679-
% (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
680-
"%s/%s_IVF%s_Flat_nprobe_%s_%s_%s.index"
681-
% (
682-
outside_index_root,
683-
exp_dir,
684-
n_ivf,
685-
index_ivf.nprobe,
686-
exp_dir1,
687-
version19,
688-
),
689-
)
690-
infos.append("链接索引到%s" % (outside_index_root))
691-
except:
692-
infos.append("链接索引到%s失败" % (outside_index_root))
693-
694676
infos.append("adding")
695677
yield "\n".join(infos)
696678
batch_size_add = 8192
@@ -705,6 +687,25 @@ def train_index(exp_dir1, version19):
705687
"成功构建索引 added_IVF%s_Flat_nprobe_%s_%s_%s.index"
706688
% (n_ivf, index_ivf.nprobe, exp_dir1, version19)
707689
)
690+
try:
691+
link=os.link if platform.system()=="Windows" else os.symlink
692+
link(
693+
"%s/added_IVF%s_Flat_nprobe_%s_%s_%s.index"
694+
% (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
695+
"%s/%s_IVF%s_Flat_nprobe_%s_%s_%s.index"
696+
% (
697+
outside_index_root,
698+
exp_dir1,
699+
n_ivf,
700+
index_ivf.nprobe,
701+
exp_dir1,
702+
version19,
703+
),
704+
)
705+
infos.append("链接索引到外部-%s" % (outside_index_root))
706+
except:
707+
infos.append("链接索引到外部-%s失败" % (outside_index_root))
708+
708709
# faiss.write_index(index, '%s/added_IVF%s_Flat_FastScan_%s.index'%(exp_dir,n_ivf,version19))
709710
# infos.append("成功构建索引,added_IVF%s_Flat_FastScan_%s.index"%(n_ivf,version19))
710711
yield "\n".join(infos)

0 commit comments

Comments
 (0)