mirror of
https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-06-07 10:10:23 +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
|
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
|
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
|
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 setuptools
|
||||||
python -m pip install --upgrade wheel
|
python -m pip install --upgrade wheel
|
||||||
pip install torch torchvision torchaudio
|
pip install torch torchvision torchaudio
|
||||||
|
|||||||
2
gui.py
2
gui.py
@@ -251,7 +251,7 @@ if __name__ == "__main__":
|
|||||||
sg.FileBrowse(
|
sg.FileBrowse(
|
||||||
i18n("Select the .pth file"),
|
i18n("Select the .pth file"),
|
||||||
initial_folder=os.path.join(
|
initial_folder=os.path.join(
|
||||||
os.getcwd(), "assets/weights"
|
os.getcwd(), "assets", "weights"
|
||||||
),
|
),
|
||||||
file_types=[("Model File", "*.pth")],
|
file_types=[("Model File", "*.pth")],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class TextAudioLoaderMultiNSFsid(torch.utils.data.Dataset):
|
|||||||
spec_filename = filename.replace(".wav", ".spec.pt")
|
spec_filename = filename.replace(".wav", ".spec.pt")
|
||||||
if os.path.exists(spec_filename):
|
if os.path.exists(spec_filename):
|
||||||
try:
|
try:
|
||||||
spec = torch.load(spec_filename)
|
spec = torch.load(spec_filename, weights_only=True)
|
||||||
except:
|
except:
|
||||||
logger.warning("%s %s", spec_filename, traceback.format_exc())
|
logger.warning("%s %s", spec_filename, traceback.format_exc())
|
||||||
spec = spectrogram_torch(
|
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):
|
def load_checkpoint(checkpoint_path, model, optimizer=None, load_opt=1):
|
||||||
assert os.path.isfile(checkpoint_path)
|
assert os.path.isfile(checkpoint_path)
|
||||||
checkpoint_dict = torch.load(checkpoint_path, map_location="cpu")
|
saved_state_dict = torch.load(checkpoint_path, map_location="cpu", weights_only=True)["model"]
|
||||||
|
|
||||||
saved_state_dict = checkpoint_dict["model"]
|
|
||||||
if hasattr(model, "module"):
|
if hasattr(model, "module"):
|
||||||
state_dict = model.module.state_dict()
|
state_dict = model.module.state_dict()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -131,9 +131,14 @@ def run(rank, n_gpus, hps: utils.HParams, logger: logging.Logger):
|
|||||||
writer = SummaryWriter(log_dir=hps.model_dir)
|
writer = SummaryWriter(log_dir=hps.model_dir)
|
||||||
writer_eval = SummaryWriter(log_dir=os.path.join(hps.model_dir, "eval"))
|
writer_eval = SummaryWriter(log_dir=os.path.join(hps.model_dir, "eval"))
|
||||||
|
|
||||||
dist.init_process_group(
|
try:
|
||||||
backend="gloo", init_method="env://", world_size=n_gpus, rank=rank
|
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)
|
torch.manual_seed(hps.train.seed)
|
||||||
if torch.cuda.is_available():
|
if torch.cuda.is_available():
|
||||||
torch.cuda.set_device(rank)
|
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"):
|
if hasattr(net_g, "module"):
|
||||||
logger.info(
|
logger.info(
|
||||||
net_g.module.load_state_dict(
|
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:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
net_g.load_state_dict(
|
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 != "":
|
if hps.pretrainD != "":
|
||||||
@@ -253,13 +258,13 @@ def run(rank, n_gpus, hps: utils.HParams, logger: logging.Logger):
|
|||||||
if hasattr(net_d, "module"):
|
if hasattr(net_d, "module"):
|
||||||
logger.info(
|
logger.info(
|
||||||
net_d.module.load_state_dict(
|
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:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
net_d.load_state_dict(
|
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
|
from fairseq import checkpoint_utils
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ def get_index_path_from_model(sid):
|
|||||||
(
|
(
|
||||||
f
|
f
|
||||||
for f in [
|
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 path in [os.getenv("outside_index_root"), os.getenv("index_root")]
|
||||||
for root, _, files in os.walk(path, topdown=False)
|
for root, _, files in os.walk(path, topdown=False)
|
||||||
for name in files
|
for name in files
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ def get_rmvpe(
|
|||||||
from rvc.f0.e2e import E2E
|
from rvc.f0.e2e import E2E
|
||||||
|
|
||||||
model = E2E(4, 1, (2, 2))
|
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)
|
model.load_state_dict(ckpt)
|
||||||
|
del ckpt
|
||||||
model.eval()
|
model.eval()
|
||||||
if is_half:
|
if is_half:
|
||||||
model = model.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)
|
shutil.rmtree(tmp, ignore_errors=True)
|
||||||
os.makedirs(tmp, exist_ok=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, "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
|
os.environ["TEMP"] = tmp
|
||||||
warnings.filterwarnings("ignore")
|
warnings.filterwarnings("ignore")
|
||||||
torch.manual_seed(114514)
|
torch.manual_seed(114514)
|
||||||
@@ -142,20 +142,22 @@ index_root = os.getenv("index_root")
|
|||||||
outside_index_root = os.getenv("outside_index_root")
|
outside_index_root = os.getenv("outside_index_root")
|
||||||
|
|
||||||
names = []
|
names = []
|
||||||
for name in os.listdir(weight_root):
|
|
||||||
if name.endswith(".pth"):
|
|
||||||
names.append(name)
|
|
||||||
index_paths = []
|
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):
|
def lookup_indices(index_root):
|
||||||
global index_paths
|
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:
|
for name in files:
|
||||||
if name.endswith(".index") and "trained" not in name:
|
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(index_root)
|
||||||
lookup_indices(outside_index_root)
|
lookup_indices(outside_index_root)
|
||||||
uvr5_names = []
|
uvr5_names = []
|
||||||
@@ -165,15 +167,12 @@ for name in os.listdir(weight_uvr5_root):
|
|||||||
|
|
||||||
|
|
||||||
def change_choices():
|
def change_choices():
|
||||||
|
global index_paths, names
|
||||||
names = []
|
names = []
|
||||||
for name in os.listdir(weight_root):
|
lookup_names(weight_root)
|
||||||
if name.endswith(".pth"):
|
|
||||||
names.append(name)
|
|
||||||
index_paths = []
|
index_paths = []
|
||||||
for root, dirs, files in os.walk(index_root, topdown=False):
|
lookup_indices(index_root)
|
||||||
for name in files:
|
lookup_indices(outside_index_root)
|
||||||
if name.endswith(".index") and "trained" not in name:
|
|
||||||
index_paths.append("%s/%s" % (root, name))
|
|
||||||
return {"choices": sorted(names), "__type__": "update"}, {
|
return {"choices": sorted(names), "__type__": "update"}, {
|
||||||
"choices": sorted(index_paths),
|
"choices": sorted(index_paths),
|
||||||
"__type__": "update",
|
"__type__": "update",
|
||||||
@@ -223,16 +222,17 @@ def if_done_multi(done, ps):
|
|||||||
|
|
||||||
def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
|
def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
|
||||||
sr = sr_dict[sr]
|
sr = sr_dict[sr]
|
||||||
os.makedirs("%s/logs/%s" % (now_dir, exp_dir), exist_ok=True)
|
exp_path = pathlib.Path(now_dir, "logs", exp_dir)
|
||||||
f = open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "w")
|
os.makedirs(exp_path, exist_ok=True)
|
||||||
|
log_file_path = exp_path / "preprocess.log"
|
||||||
|
f = open(log_file_path, "w")
|
||||||
f.close()
|
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,
|
config.python_cmd,
|
||||||
trainset_dir,
|
trainset_dir,
|
||||||
sr,
|
sr,
|
||||||
n_p,
|
n_p,
|
||||||
now_dir,
|
str(exp_path),
|
||||||
exp_dir,
|
|
||||||
config.noparallel,
|
config.noparallel,
|
||||||
config.preprocess_per,
|
config.preprocess_per,
|
||||||
)
|
)
|
||||||
@@ -249,12 +249,12 @@ def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
|
|||||||
),
|
),
|
||||||
).start()
|
).start()
|
||||||
while 1:
|
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())
|
yield (f.read())
|
||||||
sleep(1)
|
sleep(1)
|
||||||
if done[0]:
|
if done[0]:
|
||||||
break
|
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()
|
log = f.read()
|
||||||
logger.info(log)
|
logger.info(log)
|
||||||
yield log
|
yield log
|
||||||
|
|||||||
Reference in New Issue
Block a user