mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2025-05-07 04:09:06 +08:00
chore(format): run black on dev (#1986)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
cb38717d44
commit
652f33ed1c
@ -7,17 +7,19 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def sha256(f) -> str:
|
def sha256(f) -> str:
|
||||||
sha256_hash = hashlib.sha256()
|
sha256_hash = hashlib.sha256()
|
||||||
# Read and update hash in chunks of 4M
|
# Read and update hash in chunks of 4M
|
||||||
for byte_block in iter(lambda: f.read(4*1024*1024), b""):
|
for byte_block in iter(lambda: f.read(4 * 1024 * 1024), b""):
|
||||||
sha256_hash.update(byte_block)
|
sha256_hash.update(byte_block)
|
||||||
return sha256_hash.hexdigest()
|
return sha256_hash.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def check_model(dir_name: Path, model_name: str, hash: str) -> bool:
|
def check_model(dir_name: Path, model_name: str, hash: str) -> bool:
|
||||||
target = dir_name / model_name
|
target = dir_name / model_name
|
||||||
relname = str(target)
|
relname = str(target)
|
||||||
relname = relname[relname.rindex("assets/"):]
|
relname = relname[relname.rindex("assets/") :]
|
||||||
logger.debug(f"checking {relname}...")
|
logger.debug(f"checking {relname}...")
|
||||||
if not os.path.exists(target):
|
if not os.path.exists(target):
|
||||||
logger.info(f"{target} not exist.")
|
logger.info(f"{target} not exist.")
|
||||||
@ -31,16 +33,25 @@ def check_model(dir_name: Path, model_name: str, hash: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def check_all_assets() -> bool:
|
def check_all_assets() -> bool:
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||||
|
|
||||||
logger.info("checking hubret & rmvpe...")
|
logger.info("checking hubret & rmvpe...")
|
||||||
|
|
||||||
if not check_model(BASE_DIR / "assets/hubert", "hubert_base.pt", os.environ["sha256_hubert_base_pt"]):
|
if not check_model(
|
||||||
|
BASE_DIR / "assets/hubert",
|
||||||
|
"hubert_base.pt",
|
||||||
|
os.environ["sha256_hubert_base_pt"],
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
if not check_model(BASE_DIR / "assets/rmvpe", "rmvpe.pt", os.environ["sha256_rmvpe_pt"]):
|
if not check_model(
|
||||||
|
BASE_DIR / "assets/rmvpe", "rmvpe.pt", os.environ["sha256_rmvpe_pt"]
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
if not check_model(BASE_DIR / "assets/rmvpe", "rmvpe.onnx", os.environ["sha256_rmvpe_onnx"]):
|
if not check_model(
|
||||||
|
BASE_DIR / "assets/rmvpe", "rmvpe.onnx", os.environ["sha256_rmvpe_onnx"]
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
rvc_models_dir = BASE_DIR / "assets/pretrained"
|
rvc_models_dir = BASE_DIR / "assets/pretrained"
|
||||||
@ -91,13 +102,16 @@ def check_all_assets() -> bool:
|
|||||||
BASE_DIR / "assets/uvr5_weights/onnx_dereverb_By_FoxJoy",
|
BASE_DIR / "assets/uvr5_weights/onnx_dereverb_By_FoxJoy",
|
||||||
"vocals.onnx",
|
"vocals.onnx",
|
||||||
os.environ[f"sha256_uvr5_vocals_onnx"],
|
os.environ[f"sha256_uvr5_vocals_onnx"],
|
||||||
): return False
|
):
|
||||||
|
return False
|
||||||
|
|
||||||
logger.info("all assets are already latest.")
|
logger.info("all assets are already latest.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def download_and_extract_tar_gz(url: str, folder: str):
|
def download_and_extract_tar_gz(url: str, folder: str):
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
logger.info(f"downloading {url}")
|
logger.info(f"downloading {url}")
|
||||||
response = requests.get(url, stream=True)
|
response = requests.get(url, stream=True)
|
||||||
with BytesIO() as out_file:
|
with BytesIO() as out_file:
|
||||||
@ -108,8 +122,10 @@ def download_and_extract_tar_gz(url: str, folder: str):
|
|||||||
tar.extractall(folder)
|
tar.extractall(folder)
|
||||||
logger.info(f"extracted into {folder}")
|
logger.info(f"extracted into {folder}")
|
||||||
|
|
||||||
|
|
||||||
def download_and_extract_zip(url: str, folder: str):
|
def download_and_extract_zip(url: str, folder: str):
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
logger.info(f"downloading {url}")
|
logger.info(f"downloading {url}")
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
with BytesIO() as out_file:
|
with BytesIO() as out_file:
|
||||||
@ -120,14 +136,22 @@ def download_and_extract_zip(url: str, folder: str):
|
|||||||
zip_ref.extractall(folder)
|
zip_ref.extractall(folder)
|
||||||
logger.info(f"extracted into {folder}")
|
logger.info(f"extracted into {folder}")
|
||||||
|
|
||||||
|
|
||||||
def download_all_assets(tmpdir: str, version="0.2.1"):
|
def download_all_assets(tmpdir: str, version="0.2.1"):
|
||||||
import subprocess
|
import subprocess
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
archs = {
|
archs = {
|
||||||
"aarch64": "arm64", "armv8l": "arm64", "arm64": "arm64",
|
"aarch64": "arm64",
|
||||||
"x86": "386", "i386": "386", "i686": "386", "386": "386",
|
"armv8l": "arm64",
|
||||||
"x86_64": "amd64", "x64": "amd64", "amd64": "amd64",
|
"arm64": "arm64",
|
||||||
|
"x86": "386",
|
||||||
|
"i386": "386",
|
||||||
|
"i686": "386",
|
||||||
|
"386": "386",
|
||||||
|
"x86_64": "amd64",
|
||||||
|
"x64": "amd64",
|
||||||
|
"amd64": "amd64",
|
||||||
}
|
}
|
||||||
system_type = platform.system().lower()
|
system_type = platform.system().lower()
|
||||||
architecture = platform.machine().lower()
|
architecture = platform.machine().lower()
|
||||||
@ -139,7 +163,7 @@ def download_all_assets(tmpdir: str, version="0.2.1"):
|
|||||||
exit(1)
|
exit(1)
|
||||||
BASE_URL = "https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/"
|
BASE_URL = "https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/"
|
||||||
suffix = "zip" if is_win else "tar.gz"
|
suffix = "zip" if is_win else "tar.gz"
|
||||||
RVCMD_URL = BASE_URL+f"v{version}/rvcmd_{system_type}_{architecture}.{suffix}"
|
RVCMD_URL = BASE_URL + f"v{version}/rvcmd_{system_type}_{architecture}.{suffix}"
|
||||||
cmdfile = tmpdir + "/rvcmd"
|
cmdfile = tmpdir + "/rvcmd"
|
||||||
if is_win:
|
if is_win:
|
||||||
download_and_extract_zip(RVCMD_URL, tmpdir)
|
download_and_extract_zip(RVCMD_URL, tmpdir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user