diff --git a/infer-web.py b/infer-web.py index 3f63cd5..33902b5 100644 --- a/infer-web.py +++ b/infer-web.py @@ -7,17 +7,11 @@ sys.path.append(now_dir) load_dotenv() from infer.modules.vc.modules import VC from configs.config import Config -from sklearn.cluster import MiniBatchKMeans -import torch, platform -import numpy as np +import torch import gradio as gr -import faiss import fairseq -import pathlib -import json from time import sleep from subprocess import Popen -from random import shuffle import warnings import traceback import threading diff --git a/infer/lib/audio.py b/infer/lib/audio.py index 60ef07c..f488149 100644 --- a/infer/lib/audio.py +++ b/infer/lib/audio.py @@ -2,7 +2,6 @@ import platform, os import ffmpeg import numpy as np import av -from io import BytesIO import traceback import re diff --git a/infer/lib/infer_pack/attentions.py b/infer/lib/infer_pack/attentions.py index 2cc745a..d6030b8 100644 --- a/infer/lib/infer_pack/attentions.py +++ b/infer/lib/infer_pack/attentions.py @@ -1,13 +1,11 @@ -import copy import math from typing import Optional -import numpy as np import torch from torch import nn from torch.nn import functional as F -from infer.lib.infer_pack import commons, modules +from infer.lib.infer_pack import commons from infer.lib.infer_pack.modules import LayerNorm diff --git a/infer/lib/infer_pack/attentions_onnx.py b/infer/lib/infer_pack/attentions_onnx.py index a32abc1..949eb31 100644 --- a/infer/lib/infer_pack/attentions_onnx.py +++ b/infer/lib/infer_pack/attentions_onnx.py @@ -6,16 +6,14 @@ # Do Not Use All Of Non-Torch Types! # # # ############################## Warning! ############################## -import copy import math from typing import Optional -import numpy as np import torch from torch import nn from torch.nn import functional as F -from infer.lib.infer_pack import commons, modules +from infer.lib.infer_pack import commons 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 4ec6c24..faa6ed9 100644 --- a/infer/lib/infer_pack/commons.py +++ b/infer/lib/infer_pack/commons.py @@ -1,9 +1,7 @@ from typing import List, Optional import math -import numpy as np import torch -from torch import nn from torch.nn import functional as F diff --git a/infer/lib/infer_pack/models.py b/infer/lib/infer_pack/models.py index e7d93b3..288193f 100644 --- a/infer/lib/infer_pack/models.py +++ b/infer/lib/infer_pack/models.py @@ -7,7 +7,7 @@ logger = logging.getLogger(__name__) import numpy as np import torch from torch import nn -from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d +from torch.nn import Conv1d, Conv2d, ConvTranspose1d from torch.nn import functional as F from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm from infer.lib.infer_pack import attentions, commons, modules diff --git a/infer/lib/infer_pack/models_onnx.py b/infer/lib/infer_pack/models_onnx.py index e327019..f0de1cc 100644 --- a/infer/lib/infer_pack/models_onnx.py +++ b/infer/lib/infer_pack/models_onnx.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) import numpy as np import torch from torch import nn -from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d +from torch.nn import Conv1d, Conv2d, ConvTranspose1d from torch.nn import functional as F from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm diff --git a/infer/lib/infer_pack/modules.py b/infer/lib/infer_pack/modules.py index 51aeaf0..5a0f0fb 100644 --- a/infer/lib/infer_pack/modules.py +++ b/infer/lib/infer_pack/modules.py @@ -1,12 +1,9 @@ -import copy import math from typing import Optional, Tuple -import numpy as np -import scipy import torch from torch import nn -from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d +from torch.nn import Conv1d from torch.nn import functional as F from torch.nn.utils import remove_weight_norm, weight_norm diff --git a/infer/lib/infer_pack/modules/F0Predictor/F0Predictor.py b/infer/lib/infer_pack/modules/F0Predictor/F0Predictor.py index 0d81b05..0acf3d1 100644 --- a/infer/lib/infer_pack/modules/F0Predictor/F0Predictor.py +++ b/infer/lib/infer_pack/modules/F0Predictor/F0Predictor.py @@ -5,7 +5,6 @@ class F0Predictor(object): p_len:int output: f0:[signal_length//hop_length] """ - pass def compute_f0_uv(self, wav, p_len): """ @@ -13,4 +12,3 @@ class F0Predictor(object): p_len:int output: f0:[signal_length//hop_length],uv:[signal_length//hop_length] """ - pass diff --git a/infer/lib/infer_pack/onnx_inference.py b/infer/lib/infer_pack/onnx_inference.py index 3d8328b..4f25428 100644 --- a/infer/lib/infer_pack/onnx_inference.py +++ b/infer/lib/infer_pack/onnx_inference.py @@ -1,7 +1,6 @@ import librosa import numpy as np import onnxruntime -import soundfile import logging diff --git a/infer/lib/rmvpe.py b/infer/lib/rmvpe.py index 86c6899..89d7bea 100644 --- a/infer/lib/rmvpe.py +++ b/infer/lib/rmvpe.py @@ -1,6 +1,6 @@ from io import BytesIO import os -from typing import List, Optional, Tuple +from typing import List import numpy as np import torch @@ -18,7 +18,7 @@ except Exception: # pylint: disable=broad-exception-caught pass import torch.nn as nn import torch.nn.functional as F -from librosa.util import normalize, pad_center, tiny +from librosa.util import pad_center from scipy.signal import get_window import logging diff --git a/infer/lib/uvr5_pack/lib_v5/model_param_init.py b/infer/lib/uvr5_pack/lib_v5/model_param_init.py index b995c0b..5d818db 100644 --- a/infer/lib/uvr5_pack/lib_v5/model_param_init.py +++ b/infer/lib/uvr5_pack/lib_v5/model_param_init.py @@ -1,5 +1,4 @@ import json -import os import pathlib default_param = {} diff --git a/infer/lib/uvr5_pack/lib_v5/nets.py b/infer/lib/uvr5_pack/lib_v5/nets.py index 5da3948..5a3191b 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets.py +++ b/infer/lib/uvr5_pack/lib_v5/nets.py @@ -3,7 +3,6 @@ import torch import torch.nn.functional as F from torch import nn -from . import spec_utils class BaseASPPNet(nn.Module): diff --git a/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py b/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py index 823b44f..9bb1df1 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_537227KB.py @@ -1,4 +1,3 @@ -import numpy as np import torch import torch.nn.functional as F from torch import nn diff --git a/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py b/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py index 823b44f..9bb1df1 100644 --- a/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py +++ b/infer/lib/uvr5_pack/lib_v5/nets_537238KB.py @@ -1,4 +1,3 @@ -import numpy as np import torch import torch.nn.functional as F from torch import nn diff --git a/infer/lib/uvr5_pack/lib_v5/spec_utils.py b/infer/lib/uvr5_pack/lib_v5/spec_utils.py index 3766a94..4753e07 100644 --- a/infer/lib/uvr5_pack/lib_v5/spec_utils.py +++ b/infer/lib/uvr5_pack/lib_v5/spec_utils.py @@ -528,7 +528,6 @@ def istft(spec, hl): if __name__ == "__main__": import argparse - import sys import time import cv2 diff --git a/infer/modules/train/extract/extract_f0_rmvpe.py b/infer/modules/train/extract/extract_f0_rmvpe.py index 90b2073..66dc2b6 100644 --- a/infer/modules/train/extract/extract_f0_rmvpe.py +++ b/infer/modules/train/extract/extract_f0_rmvpe.py @@ -2,14 +2,12 @@ import os import sys import traceback -import parselmouth now_dir = os.getcwd() sys.path.append(now_dir) import logging import numpy as np -import pyworld from infer.lib.audio import load_audio diff --git a/infer/modules/train/extract/extract_f0_rmvpe_dml.py b/infer/modules/train/extract/extract_f0_rmvpe_dml.py index 243e825..7da6440 100644 --- a/infer/modules/train/extract/extract_f0_rmvpe_dml.py +++ b/infer/modules/train/extract/extract_f0_rmvpe_dml.py @@ -2,14 +2,12 @@ import os import sys import traceback -import parselmouth now_dir = os.getcwd() sys.path.append(now_dir) import logging import numpy as np -import pyworld from infer.lib.audio import load_audio diff --git a/poetry.lock b/poetry.lock index 6c70457..cd9127e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -239,6 +239,21 @@ files = [ [package.extras] test = ["tox"] +[[package]] +name = "autoflake" +version = "2.3.1" +description = "Removes unused imports and unused variables" +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "autoflake-2.3.1-py3-none-any.whl", hash = "sha256:3ae7495db9084b7b32818b4140e6dc4fc280b712fb414f5b8fe57b0a8e85a840"}, + {file = "autoflake-2.3.1.tar.gz", hash = "sha256:c98b75dc5b0a86459c4f01a1d32ac7eb4338ec4317a4469515ff1e687ecd909e"}, +] + +[package.dependencies] +pyflakes = ">=3.0.0" + [[package]] name = "av" version = "12.3.0" @@ -3189,6 +3204,18 @@ files = [ {file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"}, ] +[[package]] +name = "pyflakes" +version = "3.2.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + [[package]] name = "pygments" version = "2.18.0" @@ -4545,4 +4572,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.1" python-versions = ">=3.11,<3.12" -content-hash = "e8a01f5b9b6ce9748c030a0366ebcda95bcd7dc4325ac501634230bacb9f0f11" +content-hash = "5ef0f447e5d31988bef98d041d4d80a69fa118d05ac27c1a5cbe1e8d3cb5c8f1" diff --git a/pyproject.toml b/pyproject.toml index 40f47ae..2ff97ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,9 @@ torchaudio = "2.4.1" torch-directml = "^0.2.5.dev240914" # --------------------------------------------------------------------------- +# Depndenciees for temp_tools +autoflake = "^2.3.1" + [tool.poetry.group.dev.dependencies] # Add any development dependencies here diff --git a/temp_tools/remove_unused_imports.py b/temp_tools/remove_unused_imports.py new file mode 100644 index 0000000..38ae06d --- /dev/null +++ b/temp_tools/remove_unused_imports.py @@ -0,0 +1,32 @@ +import os +import subprocess + +def process_file(file_path): + """ + Run autoflake on the file to remove unused imports in-place. + """ + try: + # The --in-place option modifies the file, and + # --remove-all-unused-imports removes unused imports. + subprocess.run( + ["autoflake", "--in-place", "--remove-all-unused-imports", file_path], + check=True + ) + print(f"Processed: {file_path}") + except subprocess.CalledProcessError as e: + print(f"Error processing {file_path}: {e}") + +def process_directory(root_dir): + """ + Walk recursively through root_dir and process all .py files. + """ + for dirpath, _, filenames in os.walk(root_dir): + for filename in filenames: + if filename.endswith(".py"): + file_path = os.path.join(dirpath, filename) + process_file(file_path) + +if __name__ == '__main__': + # Start from the current directory (you can change this to your project root) + project_root = os.getcwd() + process_directory(project_root) diff --git a/tools/download_model.py b/tools/download_model.py index 41bc029..f563725 100644 --- a/tools/download_model.py +++ b/tools/download_model.py @@ -1,4 +1,3 @@ -import os import requests import zipfile import argparse diff --git a/tools/infer/trans_weights.py b/tools/infer/trans_weights.py index a8ff3b0..ae26f73 100644 --- a/tools/infer/trans_weights.py +++ b/tools/infer/trans_weights.py @@ -1,4 +1,3 @@ -import pdb import torch diff --git a/tools/torchgate/__init__.py b/tools/torchgate/__init__.py index 8c1b549..66b81ec 100644 --- a/tools/torchgate/__init__.py +++ b/tools/torchgate/__init__.py @@ -10,4 +10,3 @@ torchgate imports all the functions from PyTorch, and in addition provides: """ -from .torchgate import TorchGate