From d7eec79b118aa4768deeeebba8d87a31a682ff44 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 7 Jan 2025 12:10:52 +0000 Subject: [PATCH] chore(format): run black on main --- core.py | 4 +--- rvc/configs/config.py | 2 ++ rvc/lib/algorithm/discriminators.py | 4 +--- rvc/lib/algorithm/generators/refinegan.py | 1 - rvc/lib/predictors/RMVPE.py | 3 ++- rvc/train/extract/extract.py | 4 +--- rvc/train/extract/preparing_files.py | 8 ++------ rvc/train/process/extract_index.py | 1 - rvc/train/train.py | 6 +++--- rvc/train/utils.py | 2 +- tabs/train/train.py | 22 +++++++++++----------- 11 files changed, 24 insertions(+), 33 deletions(-) diff --git a/core.py b/core.py index cf74948f..f45edb4e 100644 --- a/core.py +++ b/core.py @@ -518,9 +518,7 @@ def run_train_script( from rvc.lib.tools.pretrained_selector import pretrained_selector if custom_pretrained == False: - pg, pd = pretrained_selector( - str(vocoder), int(sample_rate) - ) + pg, pd = pretrained_selector(str(vocoder), int(sample_rate)) else: if g_pretrained_path is None or d_pretrained_path is None: raise ValueError( diff --git a/rvc/configs/config.py b/rvc/configs/config.py index dcccf29a..1a5653e9 100644 --- a/rvc/configs/config.py +++ b/rvc/configs/config.py @@ -63,6 +63,7 @@ def set_cuda_config(self): 1024**3 ) + def max_vram_gpu(gpu): if torch.cuda.is_available(): gpu_properties = torch.cuda.get_device_properties(gpu) @@ -71,6 +72,7 @@ def max_vram_gpu(gpu): else: return "8" + def get_gpu_info(): ngpu = torch.cuda.device_count() gpu_infos = [] diff --git a/rvc/lib/algorithm/discriminators.py b/rvc/lib/algorithm/discriminators.py index ecd968ca..5bee31e7 100644 --- a/rvc/lib/algorithm/discriminators.py +++ b/rvc/lib/algorithm/discriminators.py @@ -20,9 +20,7 @@ class MultiPeriodDiscriminator(torch.nn.Module): Defaults to False. """ - def __init__( - self, use_spectral_norm: bool = False, checkpointing: bool = False - ): + def __init__(self, use_spectral_norm: bool = False, checkpointing: bool = False): super(MultiPeriodDiscriminator, self).__init__() periods = [2, 3, 5, 7, 11, 17, 23, 37] self.checkpointing = checkpointing diff --git a/rvc/lib/algorithm/generators/refinegan.py b/rvc/lib/algorithm/generators/refinegan.py index 4c526825..dbe2465d 100644 --- a/rvc/lib/algorithm/generators/refinegan.py +++ b/rvc/lib/algorithm/generators/refinegan.py @@ -1,4 +1,3 @@ -import math import numpy as np import torch from torch.nn.utils.parametrizations import weight_norm diff --git a/rvc/lib/predictors/RMVPE.py b/rvc/lib/predictors/RMVPE.py index eeeed208..961b6fa2 100644 --- a/rvc/lib/predictors/RMVPE.py +++ b/rvc/lib/predictors/RMVPE.py @@ -435,7 +435,8 @@ def __init__(self, model_path, device=None): self.model = model self.resample_kernel = {} self.device = device - self.mel_extractor = MelSpectrogram(N_MELS, 16000, 1024, 160, None, 30, 8000 + self.mel_extractor = MelSpectrogram( + N_MELS, 16000, 1024, 160, None, 30, 8000 ).to(device) self.model = self.model.to(device) cents_mapping = 20 * np.arange(N_CLASS) + 1997.3794084376191 diff --git a/rvc/train/extract/extract.py b/rvc/train/extract/extract.py index b388264f..d3d52402 100644 --- a/rvc/train/extract/extract.py +++ b/rvc/train/extract/extract.py @@ -232,9 +232,7 @@ def run_embedding_extraction( file, os.path.join(exp_dir, "f0", file_name + ".npy"), os.path.join(exp_dir, "f0_voiced", file_name + ".npy"), - os.path.join( - exp_dir, "extracted", file_name.replace("wav", "npy") - ), + os.path.join(exp_dir, "extracted", file_name.replace("wav", "npy")), ] files.append(file_info) diff --git a/rvc/train/extract/preparing_files.py b/rvc/train/extract/preparing_files.py index e5df05ba..1ae4fc08 100644 --- a/rvc/train/extract/preparing_files.py +++ b/rvc/train/extract/preparing_files.py @@ -15,9 +15,7 @@ def generate_config(sample_rate: int, model_path: str): shutil.copyfile(config_path, config_save_path) -def generate_filelist( - model_path: str, sample_rate: int, include_mutes: int = 2 -): +def generate_filelist(model_path: str, sample_rate: int, include_mutes: int = 2): gt_wavs_dir = os.path.join(model_path, "sliced_audios") feature_dir = os.path.join(model_path, f"extracted") @@ -47,9 +45,7 @@ def generate_filelist( mute_audio_path = os.path.join( mute_base_path, "sliced_audios", f"mute{sample_rate}.wav" ) - mute_feature_path = os.path.join( - mute_base_path, f"extracted", "mute.npy" - ) + mute_feature_path = os.path.join(mute_base_path, f"extracted", "mute.npy") mute_f0_path = os.path.join(mute_base_path, "f0", "mute.wav.npy") mute_f0nsf_path = os.path.join(mute_base_path, "f0_voiced", "mute.wav.npy") diff --git a/rvc/train/process/extract_index.py b/rvc/train/process/extract_index.py index 3613ded6..ab89578b 100644 --- a/rvc/train/process/extract_index.py +++ b/rvc/train/process/extract_index.py @@ -48,7 +48,6 @@ .cluster_centers_ ) - n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39) # index_added diff --git a/rvc/train/train.py b/rvc/train/train.py index 5eb7acd7..69de23de 100644 --- a/rvc/train/train.py +++ b/rvc/train/train.py @@ -658,7 +658,7 @@ def train_and_evaluate( y_hat, ids_slice, x_mask, z_mask, (z, z_p, m_p, logs_p, m_q, logs_q) = ( model_output ) - # slice of the original waveform to match a generate slice + # slice of the original waveform to match a generate slice if randomized: wave = commons.slice_segments( wave, @@ -679,7 +679,7 @@ def train_and_evaluate( # Generator backward and update _, y_d_hat_g, fmap_r, fmap_g = net_d(wave, y_hat) - + loss_mel = fn_mel_loss(wave, y_hat) * config.train.c_mel / 3.0 loss_env = envelope_loss(wave, y_hat) loss_kl = kl_loss(z_p, logs_q, m_p, logs_p, z_mask) * config.train.c_kl @@ -741,7 +741,7 @@ def train_and_evaluate( pbar.update(1) # end of batch train - #end of tqdm + # end of tqdm with torch.no_grad(): torch.cuda.empty_cache() diff --git a/rvc/train/utils.py b/rvc/train/utils.py index 06e72bdd..8fd23dee 100644 --- a/rvc/train/utils.py +++ b/rvc/train/utils.py @@ -112,7 +112,7 @@ def save_checkpoint(model, optimizer, learning_rate, iteration, checkpoint_path) ".parametrizations.weight.original0", ".weight_g", ), - checkpoint_path + checkpoint_path, ) print(f"Saved model '{checkpoint_path}' (epoch {iteration})") diff --git a/tabs/train/train.py b/tabs/train/train.py index b561965c..4ada1d39 100644 --- a/tabs/train/train.py +++ b/tabs/train/train.py @@ -872,17 +872,17 @@ def disable_stop_train_button(): } def download_prerequisites(): - gr.Info( - "Checking for prerequisites with pitch guidance... Missing files will be downloaded. If you already have them, this step will be skipped." - ) - run_prerequisites_script( - pretraineds_hifigan=True, - models=False, - exe=False, - ) - gr.Info( - "Prerequisites check complete. Missing files were downloaded, and you may now start preprocessing." - ) + gr.Info( + "Checking for prerequisites with pitch guidance... Missing files will be downloaded. If you already have them, this step will be skipped." + ) + run_prerequisites_script( + pretraineds_hifigan=True, + models=False, + exe=False, + ) + gr.Info( + "Prerequisites check complete. Missing files were downloaded, and you may now start preprocessing." + ) def toggle_visible_embedder_custom(embedder_model): if embedder_model == "custom":