mirror of
https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-06-05 01:10:22 +08:00
feat: update to latest torch & gradio version
This commit is contained in:
1
.github/workflows/unitest.yml
vendored
1
.github/workflows/unitest.yml
vendored
@@ -21,7 +21,6 @@ jobs:
|
||||
wget https://github.com/fumiama/RVC-Models-Downloader/releases/download/v0.2.5/rvcmd_linux_amd64.deb
|
||||
sudo apt -y install ./rvcmd_linux_amd64.deb
|
||||
pip install --force pip==24.0 # fix fairseq installing issue https://github.com/facebookresearch/fairseq/issues/5552
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade setuptools
|
||||
python -m pip install --upgrade wheel
|
||||
pip install torch torchvision torchaudio
|
||||
|
||||
2
gui.py
2
gui.py
@@ -251,7 +251,7 @@ if __name__ == "__main__":
|
||||
sg.FileBrowse(
|
||||
i18n("Select the .pth file"),
|
||||
initial_folder=os.path.join(
|
||||
os.getcwd(), "assets/weights"
|
||||
os.getcwd(), "assets", "weights"
|
||||
),
|
||||
file_types=[("Model File", "*.pth")],
|
||||
),
|
||||
|
||||
@@ -111,7 +111,7 @@ class TextAudioLoaderMultiNSFsid(torch.utils.data.Dataset):
|
||||
spec_filename = filename.replace(".wav", ".spec.pt")
|
||||
if os.path.exists(spec_filename):
|
||||
try:
|
||||
spec = torch.load(spec_filename)
|
||||
spec = torch.load(spec_filename, weights_only=True)
|
||||
except:
|
||||
logger.warning("%s %s", spec_filename, traceback.format_exc())
|
||||
spec = spectrogram_torch(
|
||||
|
||||
@@ -71,9 +71,7 @@ def load_checkpoint_d(checkpoint_path, combd, sbd, optimizer=None, load_opt=1):
|
||||
|
||||
def load_checkpoint(checkpoint_path, model, optimizer=None, load_opt=1):
|
||||
assert os.path.isfile(checkpoint_path)
|
||||
checkpoint_dict = torch.load(checkpoint_path, map_location="cpu")
|
||||
|
||||
saved_state_dict = checkpoint_dict["model"]
|
||||
saved_state_dict = torch.load(checkpoint_path, map_location="cpu", weights_only=True)["model"]
|
||||
if hasattr(model, "module"):
|
||||
state_dict = model.module.state_dict()
|
||||
else:
|
||||
|
||||
@@ -131,9 +131,14 @@ def run(rank, n_gpus, hps: utils.HParams, logger: logging.Logger):
|
||||
writer = SummaryWriter(log_dir=hps.model_dir)
|
||||
writer_eval = SummaryWriter(log_dir=os.path.join(hps.model_dir, "eval"))
|
||||
|
||||
dist.init_process_group(
|
||||
backend="gloo", init_method="env://", world_size=n_gpus, rank=rank
|
||||
)
|
||||
try:
|
||||
dist.init_process_group(
|
||||
backend="gloo" if os.name == "nt" or not torch.cuda.is_available() else "nccl", init_method="env://", world_size=n_gpus, rank=rank
|
||||
)
|
||||
except:
|
||||
dist.init_process_group(
|
||||
backend="gloo" if os.name == "nt" or not torch.cuda.is_available() else "nccl", init_method="env://?use_libuv=False", world_size=n_gpus, rank=rank
|
||||
)
|
||||
torch.manual_seed(hps.train.seed)
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.set_device(rank)
|
||||
@@ -238,13 +243,13 @@ def run(rank, n_gpus, hps: utils.HParams, logger: logging.Logger):
|
||||
if hasattr(net_g, "module"):
|
||||
logger.info(
|
||||
net_g.module.load_state_dict(
|
||||
torch.load(hps.pretrainG, map_location="cpu")["model"]
|
||||
torch.load(hps.pretrainG, map_location="cpu", weights_only=True)["model"]
|
||||
)
|
||||
) ##测试不加载优化器
|
||||
else:
|
||||
logger.info(
|
||||
net_g.load_state_dict(
|
||||
torch.load(hps.pretrainG, map_location="cpu")["model"]
|
||||
torch.load(hps.pretrainG, map_location="cpu", weights_only=True)["model"]
|
||||
)
|
||||
) ##测试不加载优化器
|
||||
if hps.pretrainD != "":
|
||||
@@ -253,13 +258,13 @@ def run(rank, n_gpus, hps: utils.HParams, logger: logging.Logger):
|
||||
if hasattr(net_d, "module"):
|
||||
logger.info(
|
||||
net_d.module.load_state_dict(
|
||||
torch.load(hps.pretrainD, map_location="cpu")["model"]
|
||||
torch.load(hps.pretrainD, map_location="cpu", weights_only=True)["model"]
|
||||
)
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
net_d.load_state_dict(
|
||||
torch.load(hps.pretrainD, map_location="cpu")["model"]
|
||||
torch.load(hps.pretrainD, map_location="cpu", weights_only=True)["model"]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import os
|
||||
import os, pathlib
|
||||
|
||||
from fairseq import checkpoint_utils
|
||||
|
||||
@@ -8,7 +8,7 @@ def get_index_path_from_model(sid):
|
||||
(
|
||||
f
|
||||
for f in [
|
||||
os.path.join(root, name)
|
||||
str(pathlib.Path(root, name))
|
||||
for path in [os.getenv("outside_index_root"), os.getenv("index_root")]
|
||||
for root, _, files in os.walk(path, topdown=False)
|
||||
for name in files
|
||||
|
||||
@@ -7,8 +7,9 @@ def get_rmvpe(
|
||||
from rvc.f0.e2e import E2E
|
||||
|
||||
model = E2E(4, 1, (2, 2))
|
||||
ckpt = torch.load(model_path, map_location=device)
|
||||
ckpt = torch.load(model_path, map_location=device, weights_only=True)
|
||||
model.load_state_dict(ckpt)
|
||||
del ckpt
|
||||
model.eval()
|
||||
if is_half:
|
||||
model = model.half()
|
||||
|
||||
42
web.py
42
web.py
@@ -46,7 +46,7 @@ tmp = os.path.join(now_dir, "TEMP")
|
||||
shutil.rmtree(tmp, ignore_errors=True)
|
||||
os.makedirs(tmp, exist_ok=True)
|
||||
os.makedirs(os.path.join(now_dir, "logs"), exist_ok=True)
|
||||
os.makedirs(os.path.join(now_dir, "assets/weights"), exist_ok=True)
|
||||
os.makedirs(os.path.join(now_dir, "assets", "weights"), exist_ok=True)
|
||||
os.environ["TEMP"] = tmp
|
||||
warnings.filterwarnings("ignore")
|
||||
torch.manual_seed(114514)
|
||||
@@ -142,20 +142,22 @@ index_root = os.getenv("index_root")
|
||||
outside_index_root = os.getenv("outside_index_root")
|
||||
|
||||
names = []
|
||||
for name in os.listdir(weight_root):
|
||||
if name.endswith(".pth"):
|
||||
names.append(name)
|
||||
index_paths = []
|
||||
|
||||
def lookup_names(weight_root):
|
||||
global names
|
||||
for name in os.listdir(weight_root):
|
||||
if name.endswith(".pth"):
|
||||
names.append(name)
|
||||
|
||||
def lookup_indices(index_root):
|
||||
global index_paths
|
||||
for root, dirs, files in os.walk(index_root, topdown=False):
|
||||
for root, _, files in os.walk(index_root, topdown=False):
|
||||
for name in files:
|
||||
if name.endswith(".index") and "trained" not in name:
|
||||
index_paths.append("%s/%s" % (root, name))
|
||||
|
||||
index_paths.append(str(pathlib.Path(root, name)))
|
||||
|
||||
lookup_names(weight_root)
|
||||
lookup_indices(index_root)
|
||||
lookup_indices(outside_index_root)
|
||||
uvr5_names = []
|
||||
@@ -165,15 +167,12 @@ for name in os.listdir(weight_uvr5_root):
|
||||
|
||||
|
||||
def change_choices():
|
||||
global index_paths, names
|
||||
names = []
|
||||
for name in os.listdir(weight_root):
|
||||
if name.endswith(".pth"):
|
||||
names.append(name)
|
||||
lookup_names(weight_root)
|
||||
index_paths = []
|
||||
for root, dirs, files in os.walk(index_root, topdown=False):
|
||||
for name in files:
|
||||
if name.endswith(".index") and "trained" not in name:
|
||||
index_paths.append("%s/%s" % (root, name))
|
||||
lookup_indices(index_root)
|
||||
lookup_indices(outside_index_root)
|
||||
return {"choices": sorted(names), "__type__": "update"}, {
|
||||
"choices": sorted(index_paths),
|
||||
"__type__": "update",
|
||||
@@ -223,16 +222,17 @@ def if_done_multi(done, ps):
|
||||
|
||||
def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
|
||||
sr = sr_dict[sr]
|
||||
os.makedirs("%s/logs/%s" % (now_dir, exp_dir), exist_ok=True)
|
||||
f = open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "w")
|
||||
exp_path = pathlib.Path(now_dir, "logs", exp_dir)
|
||||
os.makedirs(exp_path, exist_ok=True)
|
||||
log_file_path = exp_path / "preprocess.log"
|
||||
f = open(log_file_path, "w")
|
||||
f.close()
|
||||
cmd = '"%s" infer/modules/train/preprocess.py "%s" %s %s "%s/logs/%s" %s %.1f' % (
|
||||
cmd = '"%s" infer/modules/train/preprocess.py "%s" %s %s "%s" %s %.1f' % (
|
||||
config.python_cmd,
|
||||
trainset_dir,
|
||||
sr,
|
||||
n_p,
|
||||
now_dir,
|
||||
exp_dir,
|
||||
str(exp_path),
|
||||
config.noparallel,
|
||||
config.preprocess_per,
|
||||
)
|
||||
@@ -249,12 +249,12 @@ def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
|
||||
),
|
||||
).start()
|
||||
while 1:
|
||||
with open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "r") as f:
|
||||
with open(log_file_path, "r") as f:
|
||||
yield (f.read())
|
||||
sleep(1)
|
||||
if done[0]:
|
||||
break
|
||||
with open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "r") as f:
|
||||
with open(log_file_path, "r") as f:
|
||||
log = f.read()
|
||||
logger.info(log)
|
||||
yield log
|
||||
|
||||
Reference in New Issue
Block a user