16
16
from i18n .i18n import I18nAuto
17
17
from configs .config import Config
18
18
from sklearn .cluster import MiniBatchKMeans
19
- import torch
19
+ import torch , platform
20
20
import numpy as np
21
21
import gradio as gr
22
22
import faiss
@@ -673,24 +673,6 @@ def train_index(exp_dir1, version19):
673
673
"%s/trained_IVF%s_Flat_nprobe_%s_%s_%s.index"
674
674
% (exp_dir , n_ivf , index_ivf .nprobe , exp_dir1 , version19 ),
675
675
)
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
-
694
676
infos .append ("adding" )
695
677
yield "\n " .join (infos )
696
678
batch_size_add = 8192
@@ -705,6 +687,25 @@ def train_index(exp_dir1, version19):
705
687
"成功构建索引 added_IVF%s_Flat_nprobe_%s_%s_%s.index"
706
688
% (n_ivf , index_ivf .nprobe , exp_dir1 , version19 )
707
689
)
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
+
708
709
# faiss.write_index(index, '%s/added_IVF%s_Flat_FastScan_%s.index'%(exp_dir,n_ivf,version19))
709
710
# infos.append("成功构建索引,added_IVF%s_Flat_FastScan_%s.index"%(n_ivf,version19))
710
711
yield "\n " .join (infos )
0 commit comments