mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-08-21 02:29:47 +08:00
Update training scripts for utils
This commit is contained in:
parent
b4c6e3e72a
commit
079f1e61e0
@ -3,7 +3,7 @@ import warnings
|
||||
warnings.filterwarnings("ignore")
|
||||
import os
|
||||
|
||||
import utils
|
||||
import GPT_SoVITS.utils as utils
|
||||
|
||||
hps = utils.get_hparams(stage=2)
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = hps.train.gpu_numbers.replace("-", ",")
|
||||
@ -71,7 +71,7 @@ def main():
|
||||
def run(rank, n_gpus, hps):
|
||||
global global_step
|
||||
if rank == 0:
|
||||
logger = GPT_SoVITS.utils.get_logger(hps.data.exp_dir)
|
||||
logger = utils.get_logger(hps.data.exp_dir)
|
||||
logger.info(hps)
|
||||
# utils.check_git_hash(hps.s2_ckpt_dir)
|
||||
writer = SummaryWriter(log_dir=hps.s2_ckpt_dir)
|
||||
@ -204,7 +204,7 @@ def run(rank, n_gpus, hps):
|
||||
net_d = net_d.to(device)
|
||||
|
||||
try: # 如果能加载自动resume
|
||||
_, _, _, epoch_str = GPT_SoVITS.utils.load_checkpoint(
|
||||
_, _, _, epoch_str = utils.load_checkpoint(
|
||||
utils.latest_checkpoint_path("%s/logs_s2_%s" % (hps.data.exp_dir, hps.model.version), "D_*.pth"),
|
||||
net_d,
|
||||
optim_d,
|
||||
@ -212,7 +212,7 @@ def run(rank, n_gpus, hps):
|
||||
if rank == 0:
|
||||
logger.info("loaded D")
|
||||
# _, _, _, epoch_str = utils.load_checkpoint(utils.latest_checkpoint_path(hps.model_dir, "G_*.pth"), net_g, optim_g,load_opt=0)
|
||||
_, _, _, epoch_str = GPT_SoVITS.utils.load_checkpoint(
|
||||
_, _, _, epoch_str = utils.load_checkpoint(
|
||||
utils.latest_checkpoint_path("%s/logs_s2_%s" % (hps.data.exp_dir, hps.model.version), "G_*.pth"),
|
||||
net_g,
|
||||
optim_g,
|
||||
@ -479,30 +479,30 @@ def train_and_evaluate(rank, epoch, hps, nets, optims, schedulers, scaler, loade
|
||||
image_dict = None
|
||||
try: ###Some people installed the wrong version of matplotlib.
|
||||
image_dict = {
|
||||
"slice/mel_org": GPT_SoVITS.utils.plot_spectrogram_to_numpy(
|
||||
"slice/mel_org": utils.plot_spectrogram_to_numpy(
|
||||
y_mel[0].data.cpu().numpy(),
|
||||
),
|
||||
"slice/mel_gen": GPT_SoVITS.utils.plot_spectrogram_to_numpy(
|
||||
"slice/mel_gen": utils.plot_spectrogram_to_numpy(
|
||||
y_hat_mel[0].data.cpu().numpy(),
|
||||
),
|
||||
"all/mel": GPT_SoVITS.utils.plot_spectrogram_to_numpy(
|
||||
"all/mel": utils.plot_spectrogram_to_numpy(
|
||||
mel[0].data.cpu().numpy(),
|
||||
),
|
||||
"all/stats_ssl": GPT_SoVITS.utils.plot_spectrogram_to_numpy(
|
||||
"all/stats_ssl": utils.plot_spectrogram_to_numpy(
|
||||
stats_ssl[0].data.cpu().numpy(),
|
||||
),
|
||||
}
|
||||
except:
|
||||
pass
|
||||
if image_dict:
|
||||
GPT_SoVITS.utils.summarize(
|
||||
utils.summarize(
|
||||
writer=writer,
|
||||
global_step=global_step,
|
||||
images=image_dict,
|
||||
scalars=scalar_dict,
|
||||
)
|
||||
else:
|
||||
GPT_SoVITS.utils.summarize(
|
||||
utils.summarize(
|
||||
writer=writer,
|
||||
global_step=global_step,
|
||||
scalars=scalar_dict,
|
||||
@ -510,7 +510,7 @@ def train_and_evaluate(rank, epoch, hps, nets, optims, schedulers, scaler, loade
|
||||
global_step += 1
|
||||
if epoch % hps.train.save_every_epoch == 0 and rank == 0:
|
||||
if hps.train.if_save_latest == 0:
|
||||
GPT_SoVITS.utils.save_checkpoint(
|
||||
utils.save_checkpoint(
|
||||
net_g,
|
||||
optim_g,
|
||||
hps.train.learning_rate,
|
||||
@ -520,7 +520,7 @@ def train_and_evaluate(rank, epoch, hps, nets, optims, schedulers, scaler, loade
|
||||
"G_{}.pth".format(global_step),
|
||||
),
|
||||
)
|
||||
GPT_SoVITS.utils.save_checkpoint(
|
||||
utils.save_checkpoint(
|
||||
net_d,
|
||||
optim_d,
|
||||
hps.train.learning_rate,
|
||||
@ -531,7 +531,7 @@ def train_and_evaluate(rank, epoch, hps, nets, optims, schedulers, scaler, loade
|
||||
),
|
||||
)
|
||||
else:
|
||||
GPT_SoVITS.utils.save_checkpoint(
|
||||
utils.save_checkpoint(
|
||||
net_g,
|
||||
optim_g,
|
||||
hps.train.learning_rate,
|
||||
@ -541,7 +541,7 @@ def train_and_evaluate(rank, epoch, hps, nets, optims, schedulers, scaler, loade
|
||||
"G_{}.pth".format(233333333333),
|
||||
),
|
||||
)
|
||||
GPT_SoVITS.utils.save_checkpoint(
|
||||
utils.save_checkpoint(
|
||||
net_d,
|
||||
optim_d,
|
||||
hps.train.learning_rate,
|
||||
@ -644,7 +644,7 @@ def evaluate(hps, generator, eval_loader, writer_eval):
|
||||
)
|
||||
image_dict.update(
|
||||
{
|
||||
f"gen/mel_{batch_idx}_{test}": GPT_SoVITS.utils.plot_spectrogram_to_numpy(
|
||||
f"gen/mel_{batch_idx}_{test}": utils.plot_spectrogram_to_numpy(
|
||||
y_hat_mel[0].cpu().numpy(),
|
||||
),
|
||||
}
|
||||
@ -656,7 +656,7 @@ def evaluate(hps, generator, eval_loader, writer_eval):
|
||||
)
|
||||
image_dict.update(
|
||||
{
|
||||
f"gt/mel_{batch_idx}": GPT_SoVITS.utils.plot_spectrogram_to_numpy(mel[0].cpu().numpy()),
|
||||
f"gt/mel_{batch_idx}": utils.plot_spectrogram_to_numpy(mel[0].cpu().numpy()),
|
||||
},
|
||||
)
|
||||
audio_dict.update({f"gt/audio_{batch_idx}": y[0, :, : y_lengths[0]]})
|
||||
@ -666,7 +666,7 @@ def evaluate(hps, generator, eval_loader, writer_eval):
|
||||
# f"gen/audio_{batch_idx}_style_pred": y_hat[0, :, :]
|
||||
# })
|
||||
|
||||
GPT_SoVITS.utils.summarize(
|
||||
utils.summarize(
|
||||
writer=writer_eval,
|
||||
global_step=global_step,
|
||||
images=image_dict,
|
||||
|
@ -3,7 +3,7 @@ import warnings
|
||||
warnings.filterwarnings("ignore")
|
||||
import os
|
||||
|
||||
import utils
|
||||
import GPT_SoVITS.utils as utils
|
||||
|
||||
hps = utils.get_hparams(stage=2)
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = hps.train.gpu_numbers.replace("-", ",")
|
||||
@ -23,20 +23,20 @@ logging.getLogger("h5py").setLevel(logging.INFO)
|
||||
logging.getLogger("numba").setLevel(logging.INFO)
|
||||
from random import randint
|
||||
|
||||
from module import commons
|
||||
from module.data_utils import (
|
||||
from GPT_SoVITS.module import commons
|
||||
from GPT_SoVITS.module.data_utils import (
|
||||
DistributedBucketSampler,
|
||||
)
|
||||
from module.data_utils import (
|
||||
from GPT_SoVITS.module.data_utils import (
|
||||
TextAudioSpeakerCollateV3 as TextAudioSpeakerCollate,
|
||||
)
|
||||
from module.data_utils import (
|
||||
from GPT_SoVITS.module.data_utils import (
|
||||
TextAudioSpeakerLoaderV3 as TextAudioSpeakerLoader,
|
||||
)
|
||||
from module.models import (
|
||||
from GPT_SoVITS.module.models import (
|
||||
SynthesizerTrnV3 as SynthesizerTrn,
|
||||
)
|
||||
from process_ckpt import savee
|
||||
from GPT_SoVITS.process_ckpt import savee
|
||||
|
||||
torch.backends.cudnn.benchmark = False
|
||||
torch.backends.cudnn.deterministic = False
|
||||
|
@ -3,7 +3,7 @@ import warnings
|
||||
warnings.filterwarnings("ignore")
|
||||
import os
|
||||
|
||||
import utils
|
||||
import GPT_SoVITS.utils as utils
|
||||
|
||||
hps = utils.get_hparams(stage=2)
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = hps.train.gpu_numbers.replace("-", ",")
|
||||
@ -24,8 +24,8 @@ logging.getLogger("numba").setLevel(logging.INFO)
|
||||
from collections import OrderedDict as od
|
||||
from random import randint
|
||||
|
||||
from module import commons
|
||||
from module.data_utils import (
|
||||
from GPT_SoVITS.module import commons
|
||||
from GPT_SoVITS.module.data_utils import (
|
||||
DistributedBucketSampler,
|
||||
TextAudioSpeakerCollateV3,
|
||||
TextAudioSpeakerLoaderV3,
|
||||
@ -33,7 +33,7 @@ from module.data_utils import (
|
||||
TextAudioSpeakerLoaderV4,
|
||||
|
||||
)
|
||||
from module.models import (
|
||||
from GPT_SoVITS.module.models import (
|
||||
SynthesizerTrnV3 as SynthesizerTrn,
|
||||
)
|
||||
from peft import LoraConfig, get_peft_model
|
||||
|
Loading…
x
Reference in New Issue
Block a user