From da34d75ec93ff915ef0f17e773b27db6eb4d5fc3 Mon Sep 17 00:00:00 2001 From: RVC-Boss <129054828+RVC-Boss@users.noreply.github.com> Date: Thu, 4 May 2023 22:22:46 +0800 Subject: [PATCH] Add files via upload --- config.py | 3 ++- gui.py | 18 +++++++++++++----- infer-web.py | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config.py b/config.py index 75ac4ce..958dbe2 100644 --- a/config.py +++ b/config.py @@ -55,10 +55,11 @@ class Config: if ( ("16" in self.gpu_name and "V100" not in self.gpu_name.upper()) or "P40" in self.gpu_name.upper() + or "1060" in self.gpu_name or "1070" in self.gpu_name or "1080" in self.gpu_name ): - print("16系显卡强制单精度") + print("16系/10系显卡和P40强制单精度") self.is_half = False for config_file in ["32k.json", "40k.json", "48k.json"]: with open(f"configs/{config_file}", "r") as f: diff --git a/gui.py b/gui.py index 882291a..c205beb 100644 --- a/gui.py +++ b/gui.py @@ -38,7 +38,8 @@ class RVC: self.window = 160 if index_rate != 0: self.index = faiss.read_index(index_path) - self.big_npy = np.load(npy_path) + # self.big_npy = np.load(npy_path) + self.big_npy = index.reconstruct_n(0, self.index.ntotal) print("index search enabled") self.index_rate = index_rate model_path = hubert_path @@ -125,8 +126,15 @@ class RVC: ####索引优化 if hasattr(self, "index") and hasattr(self, "big_npy") and self.index_rate != 0: npy = feats[0].cpu().numpy().astype("float32") - _, I = self.index.search(npy, 1) - npy = self.big_npy[I.squeeze()].astype("float16") + + # _, I = self.index.search(npy, 1) + # npy = self.big_npy[I.squeeze()].astype("float16") + + 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).astype("float16") + feats = ( torch.from_numpy(npy).unsqueeze(0).to(device) * self.index_rate + (1 - self.index_rate) * feats @@ -204,7 +212,7 @@ class GUI: layout=[ [ sg.Input( - default_text="TEMP\\hubert_base.pt", key="hubert_path" + default_text="hubert_base.pt", key="hubert_path" ), sg.FileBrowse(i18n("Hubert模型")), ], @@ -221,7 +229,7 @@ class GUI: ], [ sg.Input( - default_text="TEMP\\big_src_feature_atri.npy", + default_text="你不需要填写这个You don't need write this.", key="npy_path", ), sg.FileBrowse(i18n("选择.npy文件")), diff --git a/infer-web.py b/infer-web.py index 53e187e..792179e 100644 --- a/infer-web.py +++ b/infer-web.py @@ -1312,7 +1312,7 @@ with gr.Blocks() as app: interactive=True, ) batch_size12 = gr.Slider( - minimum=0, + minimum=1, maximum=40, step=1, label=i18n("每张显卡的batch_size"), @@ -1540,4 +1540,4 @@ with gr.Blocks() as app: inbrowser=not config.noautoopen, server_port=config.listen_port, quiet=True, - ) + ) \ No newline at end of file