mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2025-02-07 06:02:49 +08:00
Total_fea not needed. Better and faster retrieval performance
Total_fea not needed now. Better and faster retrieval performance.
This commit is contained in:
parent
a21f7ec11f
commit
9be8048302
@ -119,8 +119,15 @@ class VC(object):
|
|||||||
npy = feats[0].cpu().numpy()
|
npy = feats[0].cpu().numpy()
|
||||||
if self.is_half:
|
if self.is_half:
|
||||||
npy = npy.astype("float32")
|
npy = npy.astype("float32")
|
||||||
_, I = index.search(npy, 1)
|
|
||||||
npy = big_npy[I.squeeze()]
|
# _, I = index.search(npy, 1)
|
||||||
|
# npy = big_npy[I.squeeze()]
|
||||||
|
|
||||||
|
score, ix = index.search(npy, k=8)
|
||||||
|
weight = np.square(1 / score)
|
||||||
|
weight /= weight.sum(axis=1, keepdims=True)
|
||||||
|
npy = np.sum(big_npy[ix] * np.expand_dims(weight, axis=2), axis=1)
|
||||||
|
|
||||||
if self.is_half:
|
if self.is_half:
|
||||||
npy = npy.astype("float16")
|
npy = npy.astype("float16")
|
||||||
feats = (
|
feats = (
|
||||||
@ -172,21 +179,23 @@ class VC(object):
|
|||||||
f0_up_key,
|
f0_up_key,
|
||||||
f0_method,
|
f0_method,
|
||||||
file_index,
|
file_index,
|
||||||
file_big_npy,
|
# file_big_npy,
|
||||||
index_rate,
|
index_rate,
|
||||||
if_f0,
|
if_f0,
|
||||||
f0_file=None,
|
f0_file=None,
|
||||||
):
|
):
|
||||||
|
print(file_index!= "",os.path.exists(file_index) == True,index_rate != 0)
|
||||||
if (
|
if (
|
||||||
file_big_npy != ""
|
file_index != ""
|
||||||
and file_index != ""
|
# and file_big_npy != ""
|
||||||
and os.path.exists(file_big_npy) == True
|
# and os.path.exists(file_big_npy) == True
|
||||||
and os.path.exists(file_index) == True
|
and os.path.exists(file_index) == True
|
||||||
and index_rate != 0
|
and index_rate != 0
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
index = faiss.read_index(file_index)
|
index = faiss.read_index(file_index)
|
||||||
big_npy = np.load(file_big_npy)
|
# big_npy = np.load(file_big_npy)
|
||||||
|
big_npy = index.reconstruct_n(0, index.ntotal)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
index = big_npy = None
|
index = big_npy = None
|
||||||
|
Loading…
Reference in New Issue
Block a user