Skip to content

Commit a2ef4cc

Browse files
Tps-FRVC-Boss
andauthored
fix Config, GUIConfig and self (#340)
Co-authored-by: RVC-Boss <[email protected]>
1 parent 0729c9d commit a2ef4cc

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

gui.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
sys.path.append(now_dir)
1717
from config import Config as MyConfig
1818

19-
is_half = MyConfig().is_half
19+
Config = Config()
2020
import PySimpleGUI as sg
2121
import sounddevice as sd
2222
import noisereduce as nr
@@ -71,7 +71,7 @@ def __init__(
7171
)
7272
self.model = models[0]
7373
self.model = self.model.to(device)
74-
if is_half == True:
74+
if Config.is_half:
7575
self.model = self.model.half()
7676
else:
7777
self.model = self.model.float()
@@ -81,25 +81,24 @@ def __init__(
8181
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
8282
self.if_f0 = cpt.get("f0", 1)
8383
self.version = cpt.get("version", "v1")
84-
8584
if self.version == "v1":
8685
if self.if_f0 == 1:
8786
self.net_g = SynthesizerTrnMs256NSFsid(
88-
*cpt["config"], is_half=self.config.is_half
87+
*cpt["config"], is_half=Config.is_half
8988
)
9089
else:
9190
self.net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
9291
elif self.version == "v2":
9392
if self.if_f0 == 1:
9493
self.net_g = SynthesizerTrnMs768NSFsid(
95-
*cpt["config"], is_half=self.config.is_half
94+
*cpt["config"], is_half=Config.is_half
9695
)
9796
else:
9897
self.net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
9998
del self.net_g.enc_q
10099
print(self.net_g.load_state_dict(cpt["weight"], strict=False))
101100
self.net_g.eval().to(device)
102-
if is_half == True:
101+
if Config.is_half:
103102
self.net_g = self.net_g.half()
104103
else:
105104
self.net_g = self.net_g.float()
@@ -160,7 +159,7 @@ def infer(self, feats: torch.Tensor) -> np.ndarray:
160159
torch.cuda.synchronize()
161160
with torch.no_grad():
162161
logits = self.model.extract_features(**inputs)
163-
feats = model.final_proj(logits[0]) if self.version == "v1" else logits[0]
162+
feats = self.model.final_proj(logits[0]) if self.version == "v1" else logits[0]
164163

165164
####索引优化
166165
try:
@@ -174,7 +173,7 @@ def infer(self, feats: torch.Tensor) -> np.ndarray:
174173
weight = np.square(1 / score)
175174
weight /= weight.sum(axis=1, keepdims=True)
176175
npy = np.sum(self.big_npy[ix] * np.expand_dims(weight, axis=2), axis=1)
177-
if is_half == True:
176+
if Config.is_half:
178177
npy = npy.astype("float16")
179178
feats = (
180179
torch.from_numpy(npy).unsqueeze(0).to(device) * self.index_rate
@@ -220,7 +219,7 @@ def infer(self, feats: torch.Tensor) -> np.ndarray:
220219
return infered_audio
221220

222221

223-
class Config:
222+
class GUIConfig:
224223
def __init__(self) -> None:
225224
self.hubert_path: str = ""
226225
self.pth_path: str = ""
@@ -240,7 +239,7 @@ def __init__(self) -> None:
240239

241240
class GUI:
242241
def __init__(self) -> None:
243-
self.config = Config()
242+
self.config = GUIConfig()
244243
self.flag_vc = False
245244

246245
self.launcher()

0 commit comments

Comments
 (0)