Add files via upload

This commit is contained in:
RVC-Boss 2023-05-04 22:22:46 +08:00 committed by GitHub
parent b18f921a50
commit da34d75ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -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:

18
gui.py
View File

@ -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文件")),

View File

@ -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,
)
)