Skip to content

Commit

Permalink
chore(format): run black on main
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 7, 2025
1 parent 64d51a0 commit d7eec79
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 33 deletions.
4 changes: 1 addition & 3 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions rvc/configs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -71,6 +72,7 @@ def max_vram_gpu(gpu):
else:
return "8"


def get_gpu_info():
ngpu = torch.cuda.device_count()
gpu_infos = []
Expand Down
4 changes: 1 addition & 3 deletions rvc/lib/algorithm/discriminators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion rvc/lib/algorithm/generators/refinegan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import math
import numpy as np
import torch
from torch.nn.utils.parametrizations import weight_norm
Expand Down
3 changes: 2 additions & 1 deletion rvc/lib/predictors/RMVPE.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions rvc/train/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 2 additions & 6 deletions rvc/train/extract/preparing_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down
1 change: 0 additions & 1 deletion rvc/train/process/extract_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
.cluster_centers_
)


n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39)

# index_added
Expand Down
6 changes: 3 additions & 3 deletions rvc/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion rvc/train/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})")
Expand Down
22 changes: 11 additions & 11 deletions tabs/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit d7eec79

Please sign in to comment.