From 58e32b6def8a19dbeb04afd2a036784964898548 Mon Sep 17 00:00:00 2001 From: Ftps <63702646+Tps-F@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:08:31 +0900 Subject: [PATCH] format --- configs/config.py | 8 ++-- gui_v1.py | 32 +++++++++------ i18n/i18n.py | 2 +- i18n/locale/scan_i18n.py | 1 - infer/lib/audio.py | 2 +- infer/lib/infer_pack/attentions.py | 4 +- infer/lib/infer_pack/commons.py | 1 + infer/lib/infer_pack/models.py | 20 ++++----- infer/lib/infer_pack/models_onnx.py | 20 ++++----- infer/lib/infer_pack/modules.py | 9 ++-- .../modules/F0Predictor/DioF0Predictor.py | 5 ++- .../modules/F0Predictor/HarvestF0Predictor.py | 5 ++- .../modules/F0Predictor/PMF0Predictor.py | 5 ++- infer/lib/infer_pack/onnx_inference.py | 2 +- infer/lib/infer_pack/transforms.py | 4 +- infer/lib/rmvpe.py | 13 +++--- infer/lib/train/data_utils.py | 6 ++- infer/lib/train/mel_processing.py | 1 - infer/lib/train/process_ckpt.py | 9 ++-- infer/lib/train/utils.py | 12 +++--- infer/lib/uvr5_pack/lib_v5/layers.py | 2 +- .../lib/uvr5_pack/lib_v5/layers_123812KB .py | 2 +- infer/lib/uvr5_pack/lib_v5/layers_123821KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/layers_33966KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/layers_537227KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/layers_537238KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/layers_new.py | 2 +- infer/lib/uvr5_pack/lib_v5/nets.py | 8 ++-- infer/lib/uvr5_pack/lib_v5/nets_123812KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/nets_123821KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/nets_33966KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/nets_537227KB.py | 4 +- infer/lib/uvr5_pack/lib_v5/nets_537238KB.py | 4 +- infer/lib/uvr5_pack/lib_v5/nets_61968KB.py | 2 +- infer/lib/uvr5_pack/lib_v5/nets_new.py | 3 +- infer/lib/uvr5_pack/lib_v5/spec_utils.py | 13 ++++-- infer/lib/uvr5_pack/utils.py | 7 ++-- .../modules/train/extract/extract_f0_print.py | 12 ++++-- .../modules/train/extract/extract_f0_rmvpe.py | 12 ++++-- .../train/extract/extract_f0_rmvpe_dml.py | 12 ++++-- infer/modules/train/extract_feature_print.py | 10 +++-- infer/modules/train/preprocess.py | 16 +++++--- infer/modules/train/train.py | 41 +++++++++++-------- infer/modules/uvr5/mdxnet.py | 4 +- infer/modules/uvr5/modules.py | 4 +- infer/modules/uvr5/preprocess.py | 11 +++-- infer/modules/vc/modules.py | 4 +- infer/modules/vc/pipeline.py | 9 +++- tools/calc_rvc_model_similarity.py | 4 +- tools/export_onnx.py | 2 +- tools/infer/infer-pm-index256.py | 26 ++++++------ tools/infer/train-index-v2.py | 7 +++- tools/infer/train-index.py | 5 ++- tools/infer/trans_weights.py | 4 +- tools/onnx_inference_demo.py | 1 + 55 files changed, 237 insertions(+), 169 deletions(-) diff --git a/configs/config.py b/configs/config.py index 250b1ea..90b9bc0 100644 --- a/configs/config.py +++ b/configs/config.py @@ -1,9 +1,10 @@ -import os import argparse +import os import sys -import torch from multiprocessing import cpu_count +import torch + def use_fp32_config(): for config_file in [ @@ -198,6 +199,3 @@ class Config: except: pass return x_pad, x_query, x_center, x_max - - -defaultconfig = Config() diff --git a/gui_v1.py b/gui_v1.py index 9486508..07cf5be 100644 --- a/gui_v1.py +++ b/gui_v1.py @@ -1,4 +1,6 @@ -import os, sys, pdb +import os +import pdb +import sys os.environ["OMP_NUM_THREADS"] = "2" if sys.platform == "darwin": @@ -16,7 +18,8 @@ class Harvest(multiprocessing.Process): self.opt_q = opt_q def run(self): - import numpy as np, pyworld + import numpy as np + import pyworld while 1: idx, x, res_f0, n_cpu, ts = self.inp_q.get() @@ -33,21 +36,26 @@ class Harvest(multiprocessing.Process): if __name__ == "__main__": - from multiprocessing import Queue - from queue import Empty - import numpy as np - import multiprocessing - import traceback, re import json - import PySimpleGUI as sg - import sounddevice as sd + import multiprocessing + import re + import threading + import time + import traceback + from multiprocessing import Queue, cpu_count + from queue import Empty + + import librosa import noisereduce as nr - from multiprocessing import cpu_count - import librosa, torch, time, threading + import numpy as np + import PySimpleGUI as sg + import rvc_for_realtime + import sounddevice as sd + import torch import torch.nn.functional as F import torchaudio.transforms as tat + from i18n import I18nAuto - import rvc_for_realtime i18n = I18nAuto() device = rvc_for_realtime.config.device diff --git a/i18n/i18n.py b/i18n/i18n.py index 28b17c7..f4fb9b3 100644 --- a/i18n/i18n.py +++ b/i18n/i18n.py @@ -1,5 +1,5 @@ -import locale import json +import locale import os diff --git a/i18n/locale/scan_i18n.py b/i18n/locale/scan_i18n.py index ce875c9..b5fe055 100644 --- a/i18n/locale/scan_i18n.py +++ b/i18n/locale/scan_i18n.py @@ -1,7 +1,6 @@ import ast import glob import json - from collections import OrderedDict diff --git a/infer/lib/audio.py b/infer/lib/audio.py index 61db726..045055c 100644 --- a/infer/lib/audio.py +++ b/infer/lib/audio.py @@ -1,5 +1,5 @@ -import librosa import ffmpeg +import librosa import numpy as np diff --git a/infer/lib/infer_pack/attentions.py b/infer/lib/infer_pack/attentions.py index fc3538b..2b6060c 100644 --- a/infer/lib/infer_pack/attentions.py +++ b/infer/lib/infer_pack/attentions.py @@ -1,12 +1,12 @@ import copy import math + import numpy as np import torch from torch import nn from torch.nn import functional as F -from infer.lib.infer_pack import commons -from infer.lib.infer_pack import modules +from infer.lib.infer_pack import commons, modules from infer.lib.infer_pack.modules import LayerNorm diff --git a/infer/lib/infer_pack/commons.py b/infer/lib/infer_pack/commons.py index 4937729..7ba7d21 100644 --- a/infer/lib/infer_pack/commons.py +++ b/infer/lib/infer_pack/commons.py @@ -1,4 +1,5 @@ import math + import numpy as np import torch from torch import nn diff --git a/infer/lib/infer_pack/models.py b/infer/lib/infer_pack/models.py index 8c598cf..9878048 100644 --- a/infer/lib/infer_pack/models.py +++ b/infer/lib/infer_pack/models.py @@ -1,17 +1,17 @@ -import math, pdb, os +import math +import os +import pdb from time import time as ttime + +import numpy as np import torch from torch import nn +from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d from torch.nn import functional as F -from infer.lib.infer_pack import modules -from infer.lib.infer_pack import attentions -from infer.lib.infer_pack import commons -from infer.lib.infer_pack.commons import init_weights, get_padding -from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d -from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm -from infer.lib.infer_pack.commons import init_weights -import numpy as np -from infer.lib.infer_pack import commons +from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm + +from infer.lib.infer_pack import attentions, commons, modules +from infer.lib.infer_pack.commons import get_padding, init_weights class TextEncoder256(nn.Module): diff --git a/infer/lib/infer_pack/models_onnx.py b/infer/lib/infer_pack/models_onnx.py index f4b2a15..4642a90 100644 --- a/infer/lib/infer_pack/models_onnx.py +++ b/infer/lib/infer_pack/models_onnx.py @@ -1,17 +1,17 @@ -import math, pdb, os +import math +import os +import pdb from time import time as ttime + +import numpy as np import torch from torch import nn +from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d from torch.nn import functional as F -from infer.lib.infer_pack import modules -from infer.lib.infer_pack import attentions -from infer.lib.infer_pack import commons -from infer.lib.infer_pack.commons import init_weights, get_padding -from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d -from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm -from infer.lib.infer_pack.commons import init_weights -import numpy as np -from infer.lib.infer_pack import commons +from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm + +from infer.lib.infer_pack import attentions, commons, modules +from infer.lib.infer_pack.commons import get_padding, init_weights class TextEncoder256(nn.Module): diff --git a/infer/lib/infer_pack/modules.py b/infer/lib/infer_pack/modules.py index 386f7a2..edf2207 100644 --- a/infer/lib/infer_pack/modules.py +++ b/infer/lib/infer_pack/modules.py @@ -1,19 +1,18 @@ import copy import math + import numpy as np import scipy import torch from torch import nn +from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d from torch.nn import functional as F - -from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d -from torch.nn.utils import weight_norm, remove_weight_norm +from torch.nn.utils import remove_weight_norm, weight_norm from infer.lib.infer_pack import commons -from infer.lib.infer_pack.commons import init_weights, get_padding +from infer.lib.infer_pack.commons import get_padding, init_weights from infer.lib.infer_pack.transforms import piecewise_rational_quadratic_transform - LRELU_SLOPE = 0.1 diff --git a/infer/lib/infer_pack/modules/F0Predictor/DioF0Predictor.py b/infer/lib/infer_pack/modules/F0Predictor/DioF0Predictor.py index e82a7fe..e69a603 100644 --- a/infer/lib/infer_pack/modules/F0Predictor/DioF0Predictor.py +++ b/infer/lib/infer_pack/modules/F0Predictor/DioF0Predictor.py @@ -1,6 +1,7 @@ -from infer.lib.infer_pack.modules.F0Predictor.F0Predictor import F0Predictor -import pyworld import numpy as np +import pyworld + +from infer.lib.infer_pack.modules.F0Predictor.F0Predictor import F0Predictor class DioF0Predictor(F0Predictor): diff --git a/infer/lib/infer_pack/modules/F0Predictor/HarvestF0Predictor.py b/infer/lib/infer_pack/modules/F0Predictor/HarvestF0Predictor.py index eb96c52..27f3356 100644 --- a/infer/lib/infer_pack/modules/F0Predictor/HarvestF0Predictor.py +++ b/infer/lib/infer_pack/modules/F0Predictor/HarvestF0Predictor.py @@ -1,6 +1,7 @@ -from infer.lib.infer_pack.modules.F0Predictor.F0Predictor import F0Predictor -import pyworld import numpy as np +import pyworld + +from infer.lib.infer_pack.modules.F0Predictor.F0Predictor import F0Predictor class HarvestF0Predictor(F0Predictor): diff --git a/infer/lib/infer_pack/modules/F0Predictor/PMF0Predictor.py b/infer/lib/infer_pack/modules/F0Predictor/PMF0Predictor.py index 384ff4c..957ec46 100644 --- a/infer/lib/infer_pack/modules/F0Predictor/PMF0Predictor.py +++ b/infer/lib/infer_pack/modules/F0Predictor/PMF0Predictor.py @@ -1,6 +1,7 @@ -from infer.lib.infer_pack.modules.F0Predictor.F0Predictor import F0Predictor -import parselmouth import numpy as np +import parselmouth + +from infer.lib.infer_pack.modules.F0Predictor.F0Predictor import F0Predictor class PMF0Predictor(F0Predictor): diff --git a/infer/lib/infer_pack/onnx_inference.py b/infer/lib/infer_pack/onnx_inference.py index b4aba75..3901d76 100644 --- a/infer/lib/infer_pack/onnx_inference.py +++ b/infer/lib/infer_pack/onnx_inference.py @@ -1,6 +1,6 @@ -import onnxruntime import librosa import numpy as np +import onnxruntime import soundfile diff --git a/infer/lib/infer_pack/transforms.py b/infer/lib/infer_pack/transforms.py index 7d93c48..6d07b3b 100644 --- a/infer/lib/infer_pack/transforms.py +++ b/infer/lib/infer_pack/transforms.py @@ -1,9 +1,7 @@ +import numpy as np import torch from torch.nn import functional as F -import numpy as np - - DEFAULT_MIN_BIN_WIDTH = 1e-3 DEFAULT_MIN_BIN_HEIGHT = 1e-3 DEFAULT_MIN_DERIVATIVE = 1e-3 diff --git a/infer/lib/rmvpe.py b/infer/lib/rmvpe.py index e5fa613..0c288b2 100644 --- a/infer/lib/rmvpe.py +++ b/infer/lib/rmvpe.py @@ -1,11 +1,11 @@ -import torch, numpy as np, pdb +import pdb + +import numpy as np +import torch import torch.nn as nn import torch.nn.functional as F -import torch, pdb -import numpy as np -import torch.nn.functional as F +from librosa.util import normalize, pad_center, tiny from scipy.signal import get_window -from librosa.util import pad_center, tiny, normalize ###stft codes from https://github.com/pseeth/torch-stft/blob/master/torch_stft/util.py @@ -670,7 +670,8 @@ class RMVPE: if __name__ == "__main__": - import soundfile as sf, librosa + import librosa + import soundfile as sf audio, sampling_rate = sf.read(r"C:\Users\liujing04\Desktop\Z\冬之花clip1.wav") if len(audio.shape) > 1: diff --git a/infer/lib/train/data_utils.py b/infer/lib/train/data_utils.py index 7793f15..db4e78f 100644 --- a/infer/lib/train/data_utils.py +++ b/infer/lib/train/data_utils.py @@ -1,10 +1,12 @@ -import os, traceback +import os +import traceback + import numpy as np import torch import torch.utils.data from infer.lib.train.mel_processing import spectrogram_torch -from infer.lib.train.utils import load_wav_to_torch, load_filepaths_and_text +from infer.lib.train.utils import load_filepaths_and_text, load_wav_to_torch class TextAudioLoaderMultiNSFsid(torch.utils.data.Dataset): diff --git a/infer/lib/train/mel_processing.py b/infer/lib/train/mel_processing.py index 3cc3687..85342c4 100644 --- a/infer/lib/train/mel_processing.py +++ b/infer/lib/train/mel_processing.py @@ -2,7 +2,6 @@ import torch import torch.utils.data from librosa.filters import mel as librosa_mel_fn - MAX_WAV_VALUE = 32768.0 diff --git a/infer/lib/train/process_ckpt.py b/infer/lib/train/process_ckpt.py index f2d73af..887dc71 100644 --- a/infer/lib/train/process_ckpt.py +++ b/infer/lib/train/process_ckpt.py @@ -1,7 +1,10 @@ -import torch, traceback, os, sys - - +import os +import sys +import traceback from collections import OrderedDict + +import torch + from i18n.i18n import I18nAuto i18n = I18nAuto() diff --git a/infer/lib/train/utils.py b/infer/lib/train/utils.py index 337422b..314eee7 100644 --- a/infer/lib/train/utils.py +++ b/infer/lib/train/utils.py @@ -1,13 +1,15 @@ -import os, traceback -import glob -import sys import argparse -import logging +import glob import json +import logging +import os import subprocess +import sys +import traceback + import numpy as np -from scipy.io.wavfile import read import torch +from scipy.io.wavfile import read MATPLOTLIB_FLAG = False diff --git a/infer/lib/uvr5_pack/lib_v5/layers.py b/infer/lib/uvr5_pack/lib_v5/layers.py index b82f06b..4fc1b5c 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers.py +++ b/infer/lib/uvr5_pack/lib_v5/layers.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/layers_123812KB .py b/infer/lib/uvr5_pack/lib_v5/layers_123812KB .py index b82f06b..4fc1b5c 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers_123812KB .py +++ b/infer/lib/uvr5_pack/lib_v5/layers_123812KB .py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/layers_123821KB.py b/infer/lib/uvr5_pack/lib_v5/layers_123821KB.py index b82f06b..4fc1b5c 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers_123821KB.py +++ b/infer/lib/uvr5_pack/lib_v5/layers_123821KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/layers_33966KB.py b/infer/lib/uvr5_pack/lib_v5/layers_33966KB.py index a38b7bb..9b127bc 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers_33966KB.py +++ b/infer/lib/uvr5_pack/lib_v5/layers_33966KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/layers_537227KB.py b/infer/lib/uvr5_pack/lib_v5/layers_537227KB.py index a38b7bb..9b127bc 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers_537227KB.py +++ b/infer/lib/uvr5_pack/lib_v5/layers_537227KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/layers_537238KB.py b/infer/lib/uvr5_pack/lib_v5/layers_537238KB.py index a38b7bb..9b127bc 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers_537238KB.py +++ b/infer/lib/uvr5_pack/lib_v5/layers_537238KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/layers_new.py b/infer/lib/uvr5_pack/lib_v5/layers_new.py index 0c13e60..44153b6 100644 --- a/infer/lib/uvr5_pack/lib_v5/layers_new.py +++ b/infer/lib/uvr5_pack/lib_v5/layers_new.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/nets.py b/infer/lib/uvr5_pack/lib_v5/nets.py index db4c5e3..5da3948 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets.py +++ b/infer/lib/uvr5_pack/lib_v5/nets.py @@ -1,8 +1,8 @@ -import torch -from torch import nn -import torch.nn.functional as F - import layers +import torch +import torch.nn.functional as F +from torch import nn + from . import spec_utils diff --git a/infer/lib/uvr5_pack/lib_v5/nets_123812KB.py b/infer/lib/uvr5_pack/lib_v5/nets_123812KB.py index becbfae..167d4cb 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_123812KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_123812KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import layers_123821KB as layers diff --git a/infer/lib/uvr5_pack/lib_v5/nets_123821KB.py b/infer/lib/uvr5_pack/lib_v5/nets_123821KB.py index becbfae..167d4cb 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_123821KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_123821KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import layers_123821KB as layers diff --git a/infer/lib/uvr5_pack/lib_v5/nets_33966KB.py b/infer/lib/uvr5_pack/lib_v5/nets_33966KB.py index b8986f9..73a5b83 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_33966KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_33966KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import layers_33966KB as layers diff --git a/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py b/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py index a1bb530..823b44f 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py @@ -1,7 +1,7 @@ -import torch import numpy as np -from torch import nn +import torch import torch.nn.functional as F +from torch import nn from . import layers_537238KB as layers diff --git a/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py b/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py index a1bb530..823b44f 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py @@ -1,7 +1,7 @@ -import torch import numpy as np -from torch import nn +import torch import torch.nn.functional as F +from torch import nn from . import layers_537238KB as layers diff --git a/infer/lib/uvr5_pack/lib_v5/nets_61968KB.py b/infer/lib/uvr5_pack/lib_v5/nets_61968KB.py index becbfae..167d4cb 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_61968KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_61968KB.py @@ -1,6 +1,6 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn from . import layers_123821KB as layers diff --git a/infer/lib/uvr5_pack/lib_v5/nets_new.py b/infer/lib/uvr5_pack/lib_v5/nets_new.py index bfaf72e..1c0f4fa 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_new.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_new.py @@ -1,6 +1,7 @@ import torch -from torch import nn import torch.nn.functional as F +from torch import nn + from . import layers_new diff --git a/infer/lib/uvr5_pack/lib_v5/spec_utils.py b/infer/lib/uvr5_pack/lib_v5/spec_utils.py index a3fd46d..a9634fd 100644 --- a/infer/lib/uvr5_pack/lib_v5/spec_utils.py +++ b/infer/lib/uvr5_pack/lib_v5/spec_utils.py @@ -1,8 +1,12 @@ -import os, librosa +import hashlib +import json +import math +import os + +import librosa import numpy as np import soundfile as sf from tqdm import tqdm -import json, math, hashlib def crop_center(h1, h2): @@ -519,10 +523,11 @@ def istft(spec, hl): if __name__ == "__main__": - import cv2 + import argparse import sys import time - import argparse + + import cv2 from model_param_init import ModelParameters p = argparse.ArgumentParser() diff --git a/infer/lib/uvr5_pack/utils.py b/infer/lib/uvr5_pack/utils.py index a04c001..f4805cd 100644 --- a/infer/lib/uvr5_pack/utils.py +++ b/infer/lib/uvr5_pack/utils.py @@ -1,8 +1,9 @@ -import torch -import numpy as np -from tqdm import tqdm import json +import numpy as np +import torch +from tqdm import tqdm + def load_data(file_name: str = "./infer/lib/uvr5_pack/name_params.json") -> dict: with open(file_name, "r") as f: diff --git a/infer/modules/train/extract/extract_f0_print.py b/infer/modules/train/extract/extract_f0_print.py index d95548e..d97c766 100644 --- a/infer/modules/train/extract/extract_f0_print.py +++ b/infer/modules/train/extract/extract_f0_print.py @@ -1,10 +1,16 @@ -import os, traceback, sys, parselmouth +import os +import sys +import traceback + +import parselmouth now_dir = os.getcwd() sys.path.append(now_dir) -from lib.audio import load_audio +import logging + +import numpy as np import pyworld -import numpy as np, logging +from lib.audio import load_audio logging.getLogger("numba").setLevel(logging.WARNING) from multiprocessing import Process diff --git a/infer/modules/train/extract/extract_f0_rmvpe.py b/infer/modules/train/extract/extract_f0_rmvpe.py index 33517e0..0bb2a3e 100644 --- a/infer/modules/train/extract/extract_f0_rmvpe.py +++ b/infer/modules/train/extract/extract_f0_rmvpe.py @@ -1,10 +1,16 @@ -import os, traceback, sys, parselmouth +import os +import sys +import traceback + +import parselmouth now_dir = os.getcwd() sys.path.append(now_dir) -from lib.audio import load_audio +import logging + +import numpy as np import pyworld -import numpy as np, logging +from lib.audio import load_audio logging.getLogger("numba").setLevel(logging.WARNING) diff --git a/infer/modules/train/extract/extract_f0_rmvpe_dml.py b/infer/modules/train/extract/extract_f0_rmvpe_dml.py index 744c69f..1616e72 100644 --- a/infer/modules/train/extract/extract_f0_rmvpe_dml.py +++ b/infer/modules/train/extract/extract_f0_rmvpe_dml.py @@ -1,10 +1,16 @@ -import os, traceback, sys, parselmouth +import os +import sys +import traceback + +import parselmouth now_dir = os.getcwd() sys.path.append(now_dir) -from lib.audio import load_audio +import logging + +import numpy as np import pyworld -import numpy as np, logging +from lib.audio import load_audio logging.getLogger("numba").setLevel(logging.WARNING) diff --git a/infer/modules/train/extract_feature_print.py b/infer/modules/train/extract_feature_print.py index 32e0492..f8bfc2a 100644 --- a/infer/modules/train/extract_feature_print.py +++ b/infer/modules/train/extract_feature_print.py @@ -1,4 +1,6 @@ -import os, sys, traceback +import os +import sys +import traceback os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0" @@ -14,11 +16,11 @@ else: exp_dir = sys.argv[5] os.environ["CUDA_VISIBLE_DEVICES"] = str(i_gpu) version = sys.argv[6] +import fairseq +import numpy as np +import soundfile as sf import torch import torch.nn.functional as F -import soundfile as sf -import numpy as np -import fairseq if "privateuseone" not in device: device = "cpu" diff --git a/infer/modules/train/preprocess.py b/infer/modules/train/preprocess.py index 62671ba..a7cab57 100644 --- a/infer/modules/train/preprocess.py +++ b/infer/modules/train/preprocess.py @@ -1,4 +1,7 @@ -import sys, os, multiprocessing +import multiprocessing +import os +import sys + from scipy import signal now_dir = os.getcwd() @@ -9,12 +12,15 @@ sr = int(sys.argv[2]) n_p = int(sys.argv[3]) exp_dir = sys.argv[4] noparallel = sys.argv[5] == "True" -import numpy as np, os, traceback -from lib.slicer2 import Slicer -import librosa, traceback -from scipy.io import wavfile import multiprocessing +import os +import traceback + +import librosa +import numpy as np from lib.audio import load_audio +from lib.slicer2 import Slicer +from scipy.io import wavfile mutex = multiprocessing.Lock() f = open("%s/preprocess.log" % exp_dir, "a+") diff --git a/infer/modules/train/train.py b/infer/modules/train/train.py index 3dca6c7..ac52cf6 100644 --- a/infer/modules/train/train.py +++ b/infer/modules/train/train.py @@ -1,43 +1,47 @@ -import os, sys +import os +import sys now_dir = os.getcwd() sys.path.append(os.path.join(now_dir)) -from infer.lib.train import utils import datetime +from infer.lib.train import utils + hps = utils.get_hparams() os.environ["CUDA_VISIBLE_DEVICES"] = hps.gpus.replace("-", ",") n_gpus = len(hps.gpus.split("-")) -from random import shuffle, randint +from random import randint, shuffle import torch torch.backends.cudnn.deterministic = False torch.backends.cudnn.benchmark = False -from torch.nn import functional as F -from torch.utils.data import DataLoader -from torch.utils.tensorboard import SummaryWriter -import torch.multiprocessing as mp -import torch.distributed as dist -from torch.nn.parallel import DistributedDataParallel as DDP -from torch.cuda.amp import autocast, GradScaler -from infer.lib.infer_pack import commons from time import sleep from time import time as ttime + +import torch.distributed as dist +import torch.multiprocessing as mp +from torch.cuda.amp import GradScaler, autocast +from torch.nn import functional as F +from torch.nn.parallel import DistributedDataParallel as DDP +from torch.utils.data import DataLoader +from torch.utils.tensorboard import SummaryWriter + +from infer.lib.infer_pack import commons from infer.lib.train.data_utils import ( - TextAudioLoaderMultiNSFsid, - TextAudioLoader, - TextAudioCollateMultiNSFsid, - TextAudioCollate, DistributedBucketSampler, + TextAudioCollate, + TextAudioCollateMultiNSFsid, + TextAudioLoader, + TextAudioLoaderMultiNSFsid, ) if hps.version == "v1": + from infer.lib.infer_pack.models import MultiPeriodDiscriminator + from infer.lib.infer_pack.models import SynthesizerTrnMs256NSFsid as RVC_Model_f0 from infer.lib.infer_pack.models import ( - SynthesizerTrnMs256NSFsid as RVC_Model_f0, SynthesizerTrnMs256NSFsid_nono as RVC_Model_nof0, - MultiPeriodDiscriminator, ) else: from infer.lib.infer_pack.models import ( @@ -45,10 +49,11 @@ else: SynthesizerTrnMs768NSFsid_nono as RVC_Model_nof0, MultiPeriodDiscriminatorV2 as MultiPeriodDiscriminator, ) + from infer.lib.train.losses import ( - generator_loss, discriminator_loss, feature_loss, + generator_loss, kl_loss, ) from infer.lib.train.mel_processing import mel_spectrogram_torch, spec_to_mel_torch diff --git a/infer/modules/uvr5/mdxnet.py b/infer/modules/uvr5/mdxnet.py index bd84f82..4a70469 100644 --- a/infer/modules/uvr5/mdxnet.py +++ b/infer/modules/uvr5/mdxnet.py @@ -1,12 +1,12 @@ import os import warnings -import soundfile as sf import librosa import numpy as np import onnxruntime as ort -from tqdm import tqdm +import soundfile as sf import torch +from tqdm import tqdm cpu = torch.device("cpu") diff --git a/infer/modules/uvr5/modules.py b/infer/modules/uvr5/modules.py index 4f5269a..16ad0a9 100644 --- a/infer/modules/uvr5/modules.py +++ b/infer/modules/uvr5/modules.py @@ -1,12 +1,12 @@ import os import traceback -import torch import ffmpeg +import torch from configs.config import Config -from infer.modules.uvr5.preprocess import AudioPre, AudioPreDeEcho from infer.modules.uvr5.mdxnet import MDXNetDereverb +from infer.modules.uvr5.preprocess import AudioPre, AudioPreDeEcho config = Config() diff --git a/infer/modules/uvr5/preprocess.py b/infer/modules/uvr5/preprocess.py index dae2739..26aeada 100644 --- a/infer/modules/uvr5/preprocess.py +++ b/infer/modules/uvr5/preprocess.py @@ -1,16 +1,15 @@ import os -import torch import librosa import numpy as np import soundfile as sf +import torch -from infer.lib.uvr5_pack.lib_v5 import spec_utils -from infer.lib.uvr5_pack.utils import inference -from infer.lib.uvr5_pack.lib_v5.model_param_init import ModelParameters - -from infer.lib.uvr5_pack.lib_v5.nets_new import CascadedNet from infer.lib.uvr5_pack.lib_v5 import nets_61968KB as Nets +from infer.lib.uvr5_pack.lib_v5 import spec_utils +from infer.lib.uvr5_pack.lib_v5.model_param_init import ModelParameters +from infer.lib.uvr5_pack.lib_v5.nets_new import CascadedNet +from infer.lib.uvr5_pack.utils import inference class AudioPre: diff --git a/infer/modules/vc/modules.py b/infer/modules/vc/modules.py index f3626a9..ac37f44 100644 --- a/infer/modules/vc/modules.py +++ b/infer/modules/vc/modules.py @@ -1,9 +1,10 @@ import traceback import numpy as np -import torch import soundfile as sf +import torch +from infer.lib.audio import load_audio from infer.lib.infer_pack.models import ( SynthesizerTrnMs256NSFsid, SynthesizerTrnMs256NSFsid_nono, @@ -12,7 +13,6 @@ from infer.lib.infer_pack.models import ( ) from infer.modules.vc.pipeline import Pipeline from infer.modules.vc.utils import * -from infer.lib.audio import load_audio class VC: diff --git a/infer/modules/vc/pipeline.py b/infer/modules/vc/pipeline.py index eed97e0..31e5399 100644 --- a/infer/modules/vc/pipeline.py +++ b/infer/modules/vc/pipeline.py @@ -1,13 +1,18 @@ +import os import sys +import traceback +from functools import lru_cache from time import time as ttime +import faiss +import librosa import numpy as np import parselmouth +import pyworld import torch import torch.nn.functional as F -import pyworld, os, traceback, faiss, librosa, torchcrepe +import torchcrepe from scipy import signal -from functools import lru_cache now_dir = os.getcwd() sys.path.append(now_dir) diff --git a/tools/calc_rvc_model_similarity.py b/tools/calc_rvc_model_similarity.py index edc1cf8..3f74ca5 100644 --- a/tools/calc_rvc_model_similarity.py +++ b/tools/calc_rvc_model_similarity.py @@ -1,6 +1,8 @@ # This code references https://huggingface.co/JosephusCheung/ASimilarityCalculatior/blob/main/qwerty.py # Fill in the path of the model to be queried and the root directory of the reference models, and this script will return the similarity between the model to be queried and all reference models. -import sys, os +import os +import sys + import torch import torch.nn as nn import torch.nn.functional as F diff --git a/tools/export_onnx.py b/tools/export_onnx.py index 2d334a6..a38f943 100644 --- a/tools/export_onnx.py +++ b/tools/export_onnx.py @@ -1,5 +1,5 @@ -from lib.infer_pack.models_onnx import SynthesizerTrnMsNSFsidM import torch +from lib.infer_pack.models_onnx import SynthesizerTrnMsNSFsidM if __name__ == "__main__": MoeVS = True # 模型是否为MoeVoiceStudio(原MoeSS)使用 diff --git a/tools/infer/infer-pm-index256.py b/tools/infer/infer-pm-index256.py index 2ab44e1..92be320 100644 --- a/tools/infer/infer-pm-index256.py +++ b/tools/infer/infer-pm-index256.py @@ -2,34 +2,36 @@ 对源特征进行检索 """ -import torch, pdb, os, parselmouth +import os +import pdb + +import parselmouth +import torch os.environ["CUDA_VISIBLE_DEVICES"] = "0" +# import torchcrepe +from time import time as ttime + +# import pyworld +import librosa import numpy as np +import scipy.signal as signal import soundfile as sf +import torch.nn.functional as F +from fairseq import checkpoint_utils # from models import SynthesizerTrn256#hifigan_nonsf # from lib.infer_pack.models import SynthesizerTrn256NSF as SynthesizerTrn256#hifigan_nsf from lib.infer_pack.models import ( SynthesizerTrnMs256NSFsid as SynthesizerTrn256, ) # hifigan_nsf +from scipy.io import wavfile # from lib.infer_pack.models import SynthesizerTrnMs256NSFsid_sim as SynthesizerTrn256#hifigan_nsf # from models import SynthesizerTrn256NSFsim as SynthesizerTrn256#hifigan_nsf # from models import SynthesizerTrn256NSFsimFlow as SynthesizerTrn256#hifigan_nsf -from scipy.io import wavfile -from fairseq import checkpoint_utils - -# import pyworld -import librosa -import torch.nn.functional as F -import scipy.signal as signal - -# import torchcrepe -from time import time as ttime - device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model_path = r"E:\codes\py39\vits_vc_gpu_train\hubert_base.pt" # print("load model(s) from {}".format(model_path)) diff --git a/tools/infer/train-index-v2.py b/tools/infer/train-index-v2.py index 77dfa0b..e72ffe7 100644 --- a/tools/infer/train-index-v2.py +++ b/tools/infer/train-index-v2.py @@ -1,11 +1,14 @@ """ 格式:直接cid为自带的index位;aid放不下了,通过字典来查,反正就5w个 """ -import faiss, numpy as np, os -from sklearn.cluster import MiniBatchKMeans +import os import traceback from multiprocessing import cpu_count +import faiss +import numpy as np +from sklearn.cluster import MiniBatchKMeans + # ###########如果是原始特征要先写save n_cpu = 0 if n_cpu == 0: diff --git a/tools/infer/train-index.py b/tools/infer/train-index.py index c49f24b..2446e4c 100644 --- a/tools/infer/train-index.py +++ b/tools/infer/train-index.py @@ -1,7 +1,10 @@ """ 格式:直接cid为自带的index位;aid放不下了,通过字典来查,反正就5w个 """ -import faiss, numpy as np, os +import os + +import faiss +import numpy as np # ###########如果是原始特征要先写save inp_root = r"E:\codes\py39\dataset\mi\2-co256" diff --git a/tools/infer/trans_weights.py b/tools/infer/trans_weights.py index e0f7f0c..a8ff3b0 100644 --- a/tools/infer/trans_weights.py +++ b/tools/infer/trans_weights.py @@ -1,4 +1,6 @@ -import torch, pdb +import pdb + +import torch # a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-suc\G_1000.pth")["model"]#sim_nsf# # a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-freeze-vocoder-flow-enc_q\G_1000.pth")["model"]#sim_nsf# diff --git a/tools/onnx_inference_demo.py b/tools/onnx_inference_demo.py index a4a9490..03bb868 100644 --- a/tools/onnx_inference_demo.py +++ b/tools/onnx_inference_demo.py @@ -1,4 +1,5 @@ import soundfile + from ..lib.infer_pack.onnx_inference import OnnxRVC hop_size = 512