Spaces:
Runtime error
Runtime error
File size: 1,550 Bytes
a8c39f5 1378843 a8c39f5 1378843 a8c39f5 1378843 a8c39f5 1378843 a8c39f5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import os
import shutil
import sys
import gradio as gr
from assets.i18n.i18n import I18nAuto
i18n = I18nAuto()
now_dir = os.getcwd()
sys.path.append(now_dir)
# Custom Pretraineds
pretraineds_custom_path = os.path.join(now_dir, "rvc", "models", "pretraineds", "pretraineds_custom")
pretraineds_custom_path_relative = os.path.relpath(pretraineds_custom_path, now_dir)
custom_embedder_root = os.path.join(now_dir, "rvc", "models", "embedders", "embedders_custom")
os.makedirs(custom_embedder_root, exist_ok=True)
os.makedirs(pretraineds_custom_path_relative, exist_ok=True)
def get_pretrained_list(suffix):
return [
os.path.join(dirpath, filename)
for dirpath, _, filenames in os.walk(pretraineds_custom_path_relative)
for filename in filenames
if filename.endswith(".pth") and suffix in filename
]
# Dataset Creator
datasets_path = os.path.join(now_dir, "assets", "datasets")
if not os.path.exists(datasets_path):
os.makedirs(datasets_path)
# Drop Model
def save_drop_model(dropbox):
if ".pth" not in dropbox:
gr.Info(i18n("The file you dropped is not a valid pretrained file. Please try again."))
else:
file_name = os.path.basename(dropbox)
pretrained_path = os.path.join(pretraineds_custom_path_relative, file_name)
if os.path.exists(pretrained_path):
os.remove(pretrained_path)
shutil.copy(dropbox, pretrained_path)
gr.Info(i18n("Click the refresh button to see the pretrained file in the dropdown menu."))
return None
|