Skip to content

Commit 9be8048

Browse files
authored
Total_fea not needed. Better and faster retrieval performance
Total_fea not needed now. Better and faster retrieval performance.
1 parent a21f7ec commit 9be8048

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

vc_infer_pipeline.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ def vc(
119119
npy = feats[0].cpu().numpy()
120120
if self.is_half:
121121
npy = npy.astype("float32")
122-
_, I = index.search(npy, 1)
123-
npy = big_npy[I.squeeze()]
122+
123+
# _, I = index.search(npy, 1)
124+
# npy = big_npy[I.squeeze()]
125+
126+
score, ix = index.search(npy, k=8)
127+
weight = np.square(1 / score)
128+
weight /= weight.sum(axis=1, keepdims=True)
129+
npy = np.sum(big_npy[ix] * np.expand_dims(weight, axis=2), axis=1)
130+
124131
if self.is_half:
125132
npy = npy.astype("float16")
126133
feats = (
@@ -172,21 +179,23 @@ def pipeline(
172179
f0_up_key,
173180
f0_method,
174181
file_index,
175-
file_big_npy,
182+
# file_big_npy,
176183
index_rate,
177184
if_f0,
178185
f0_file=None,
179186
):
187+
print(file_index!= "",os.path.exists(file_index) == True,index_rate != 0)
180188
if (
181-
file_big_npy != ""
182-
and file_index != ""
183-
and os.path.exists(file_big_npy) == True
189+
file_index != ""
190+
# and file_big_npy != ""
191+
# and os.path.exists(file_big_npy) == True
184192
and os.path.exists(file_index) == True
185193
and index_rate != 0
186194
):
187195
try:
188196
index = faiss.read_index(file_index)
189-
big_npy = np.load(file_big_npy)
197+
# big_npy = np.load(file_big_npy)
198+
big_npy = index.reconstruct_n(0, index.ntotal)
190199
except:
191200
traceback.print_exc()
192201
index = big_npy = None

0 commit comments

Comments
 (0)