mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-16 00:13:07 +00:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
# 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 torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
|
||||
def cal_cross_attn(to_q, to_k, to_v, rand_input):
|
||||
hidden_dim, embed_dim = to_q.shape
|
||||
attn_to_q = nn.Linear(hidden_dim, embed_dim, bias=False)
|
||||
attn_to_k = nn.Linear(hidden_dim, embed_dim, bias=False)
|
||||
attn_to_v = nn.Linear(hidden_dim, embed_dim, bias=False)
|
||||
attn_to_q.load_state_dict({"weight": to_q})
|
||||
attn_to_k.load_state_dict({"weight": to_k})
|
||||
attn_to_v.load_state_dict({"weight": to_v})
|
||||
|
||||
return torch.einsum(
|
||||
"ik, jk -> ik",
|
||||
F.softmax(
|
||||
torch.einsum("ij, kj -> ik", attn_to_q(rand_input), attn_to_k(rand_input)),
|
||||
dim=-1,
|
||||
),
|
||||
attn_to_v(rand_input),
|
||||
)
|
||||
|
||||
|
||||
def model_hash(filename):
|
||||
try:
|
||||
with open(filename, "rb") as file:
|
||||
import hashlib
|
||||
|
||||
m = hashlib.sha256()
|
||||
|
||||
file.seek(0x100000)
|
||||
m.update(file.read(0x10000))
|
||||
return m.hexdigest()[0:8]
|
||||
except FileNotFoundError:
|
||||
return "NOFILE"
|
||||
|
||||
|
||||
def eval(model, n, input):
|
||||
qk = f"enc_p.encoder.attn_layers.{n}.conv_q.weight"
|
||||
uk = f"enc_p.encoder.attn_layers.{n}.conv_k.weight"
|
||||
vk = f"enc_p.encoder.attn_layers.{n}.conv_v.weight"
|
||||
atoq, atok, atov = model[qk][:, :, 0], model[uk][:, :, 0], model[vk][:, :, 0]
|
||||
|
||||
attn = cal_cross_attn(atoq, atok, atov, input)
|
||||
return attn
|
||||
|
||||
|
||||
def main(path, root):
|
||||
torch.manual_seed(114514)
|
||||
model_a = torch.load(path, map_location="cpu")["weight"]
|
||||
|
||||
print("query:\t\t%s\t%s" % (path, model_hash(path)))
|
||||
|
||||
map_attn_a = {}
|
||||
map_rand_input = {}
|
||||
for n in range(6):
|
||||
hidden_dim, embed_dim, _ = model_a[
|
||||
f"enc_p.encoder.attn_layers.{n}.conv_v.weight"
|
||||
].shape
|
||||
rand_input = torch.randn([embed_dim, hidden_dim])
|
||||
|
||||
map_attn_a[n] = eval(model_a, n, rand_input)
|
||||
map_rand_input[n] = rand_input
|
||||
|
||||
del model_a
|
||||
|
||||
for name in sorted(list(os.listdir(root))):
|
||||
path = "%s/%s" % (root, name)
|
||||
model_b = torch.load(path, map_location="cpu")["weight"]
|
||||
|
||||
sims = []
|
||||
for n in range(6):
|
||||
attn_a = map_attn_a[n]
|
||||
attn_b = eval(model_b, n, map_rand_input[n])
|
||||
|
||||
sim = torch.mean(torch.cosine_similarity(attn_a, attn_b))
|
||||
sims.append(sim)
|
||||
|
||||
print(
|
||||
"reference:\t%s\t%s\t%s"
|
||||
% (path, model_hash(path), f"{torch.mean(torch.stack(sims)) * 1e2:.2f}%")
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
query_path = r"weights\mi v3.pth"
|
||||
reference_root = r"weights"
|
||||
main(query_path, reference_root)
|
||||
@@ -0,0 +1,348 @@
|
||||
@echo off && chcp 65001
|
||||
|
||||
echo working dir is %cd%
|
||||
echo downloading requirement aria2 check.
|
||||
echo=
|
||||
dir /a:d/b | findstr "aria2" > flag.txt
|
||||
findstr "aria2" flag.txt >nul
|
||||
if %errorlevel% ==0 (
|
||||
echo aria2 checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. please downloading aria2 from webpage!
|
||||
echo unzip it and put in this directory!
|
||||
timeout /T 5
|
||||
start https://github.com/aria2/aria2/releases/tag/release-1.36.0
|
||||
echo=
|
||||
goto end
|
||||
)
|
||||
|
||||
echo envfiles checking start.
|
||||
echo=
|
||||
|
||||
for /f %%x in ('findstr /i /c:"aria2" "flag.txt"') do (set aria2=%%x)&goto endSch
|
||||
:endSch
|
||||
|
||||
set d32=f0D32k.pth
|
||||
set d40=f0D40k.pth
|
||||
set d48=f0D48k.pth
|
||||
set g32=f0G32k.pth
|
||||
set g40=f0G40k.pth
|
||||
set g48=f0G48k.pth
|
||||
|
||||
set d40v2=f0D40k.pth
|
||||
set g40v2=f0G40k.pth
|
||||
|
||||
set dld32=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D32k.pth
|
||||
set dld40=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D40k.pth
|
||||
set dld48=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D48k.pth
|
||||
set dlg32=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G32k.pth
|
||||
set dlg40=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G40k.pth
|
||||
set dlg48=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G48k.pth
|
||||
|
||||
set dld40v2=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D40k.pth
|
||||
set dlg40v2=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G40k.pth
|
||||
|
||||
set hp2_all=HP2_all_vocals.pth
|
||||
set hp3_all=HP3_all_vocals.pth
|
||||
set hp5_only=HP5_only_main_vocal.pth
|
||||
set VR_DeEchoAggressive=VR-DeEchoAggressive.pth
|
||||
set VR_DeEchoDeReverb=VR-DeEchoDeReverb.pth
|
||||
set VR_DeEchoNormal=VR-DeEchoNormal.pth
|
||||
set onnx_dereverb=vocals.onnx
|
||||
|
||||
set dlhp2_all=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP2_all_vocals.pth
|
||||
set dlhp3_all=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP3_all_vocals.pth
|
||||
set dlhp5_only=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP5_only_main_vocal.pth
|
||||
set dlVR_DeEchoAggressive=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/VR-DeEchoAggressive.pth
|
||||
set dlVR_DeEchoDeReverb=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/VR-DeEchoDeReverb.pth
|
||||
set dlVR_DeEchoNormal=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/VR-DeEchoNormal.pth
|
||||
set dlonnx_dereverb=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/onnx_dereverb_By_FoxJoy/vocals.onnx
|
||||
|
||||
set hb=hubert_base.pt
|
||||
|
||||
set dlhb=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt
|
||||
|
||||
echo dir check start.
|
||||
echo=
|
||||
|
||||
if exist "%~dp0pretrained" (
|
||||
echo dir .\pretrained checked.
|
||||
) else (
|
||||
echo failed. generating dir .\pretrained.
|
||||
mkdir pretrained
|
||||
)
|
||||
if exist "%~dp0pretrained_v2" (
|
||||
echo dir .\pretrained_v2 checked.
|
||||
) else (
|
||||
echo failed. generating dir .\pretrained_v2.
|
||||
mkdir pretrained_v2
|
||||
)
|
||||
if exist "%~dp0uvr5_weights" (
|
||||
echo dir .\uvr5_weights checked.
|
||||
) else (
|
||||
echo failed. generating dir .\uvr5_weights.
|
||||
mkdir uvr5_weights
|
||||
)
|
||||
if exist "%~dp0uvr5_weights\onnx_dereverb_By_FoxJoy" (
|
||||
echo dir .\uvr5_weights\onnx_dereverb_By_FoxJoy checked.
|
||||
) else (
|
||||
echo failed. generating dir .\uvr5_weights\onnx_dereverb_By_FoxJoy.
|
||||
mkdir uvr5_weights\onnx_dereverb_By_FoxJoy
|
||||
)
|
||||
|
||||
echo=
|
||||
echo dir check finished.
|
||||
|
||||
echo=
|
||||
echo required files check start.
|
||||
|
||||
echo checking D32k.pth
|
||||
if exist "%~dp0pretrained\D32k.pth" (
|
||||
echo D32k.pth in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D32k.pth -d %~dp0pretrained -o D32k.pth
|
||||
if exist "%~dp0pretrained\D32k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking D40k.pth
|
||||
if exist "%~dp0pretrained\D40k.pth" (
|
||||
echo D40k.pth in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D40k.pth -d %~dp0pretrained -o D40k.pth
|
||||
if exist "%~dp0pretrained\D40k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking D40k.pth
|
||||
if exist "%~dp0pretrained_v2\D40k.pth" (
|
||||
echo D40k.pth in .\pretrained_v2 checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D40k.pth -d %~dp0pretrained_v2 -o D40k.pth
|
||||
if exist "%~dp0pretrained_v2\D40k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking D48k.pth
|
||||
if exist "%~dp0pretrained\D48k.pth" (
|
||||
echo D48k.pth in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D48k.pth -d %~dp0pretrained -o D48k.pth
|
||||
if exist "%~dp0pretrained\D48k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking G32k.pth
|
||||
if exist "%~dp0pretrained\G32k.pth" (
|
||||
echo G32k.pth in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G32k.pth -d %~dp0pretrained -o G32k.pth
|
||||
if exist "%~dp0pretrained\G32k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking G40k.pth
|
||||
if exist "%~dp0pretrained\G40k.pth" (
|
||||
echo G40k.pth in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G40k.pth -d %~dp0pretrained -o G40k.pth
|
||||
if exist "%~dp0pretrained\G40k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking G40k.pth
|
||||
if exist "%~dp0pretrained_v2\G40k.pth" (
|
||||
echo G40k.pth in .\pretrained_v2 checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G40k.pth -d %~dp0pretrained_v2 -o G40k.pth
|
||||
if exist "%~dp0pretrained_v2\G40k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking G48k.pth
|
||||
if exist "%~dp0pretrained\G48k.pth" (
|
||||
echo G48k.pth in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G48k.pth -d %~dp0pretrained -o G48k.pth
|
||||
if exist "%~dp0pretrained\G48k.pth" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
|
||||
echo checking %d32%
|
||||
if exist "%~dp0pretrained\%d32%" (
|
||||
echo %d32% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dld32% -d %~dp0pretrained -o %d32%
|
||||
if exist "%~dp0pretrained\%d32%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %d40%
|
||||
if exist "%~dp0pretrained\%d40%" (
|
||||
echo %d40% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dld40% -d %~dp0pretrained -o %d40%
|
||||
if exist "%~dp0pretrained\%d40%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %d40v2%
|
||||
if exist "%~dp0pretrained_v2\%d40v2%" (
|
||||
echo %d40v2% in .\pretrained_v2 checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dld40v2% -d %~dp0pretrained_v2 -o %d40v2%
|
||||
if exist "%~dp0pretrained_v2\%d40v2%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %d48%
|
||||
if exist "%~dp0pretrained\%d48%" (
|
||||
echo %d48% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dld48% -d %~dp0pretrained -o %d48%
|
||||
if exist "%~dp0pretrained\%d48%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %g32%
|
||||
if exist "%~dp0pretrained\%g32%" (
|
||||
echo %g32% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlg32% -d %~dp0pretrained -o %g32%
|
||||
if exist "%~dp0pretrained\%g32%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %g40%
|
||||
if exist "%~dp0pretrained\%g40%" (
|
||||
echo %g40% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlg40% -d %~dp0pretrained -o %g40%
|
||||
if exist "%~dp0pretrained\%g40%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %g40v2%
|
||||
if exist "%~dp0pretrained_v2\%g40v2%" (
|
||||
echo %g40v2% in .\pretrained_v2 checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlg40v2% -d %~dp0pretrained_v2 -o %g40v2%
|
||||
if exist "%~dp0pretrained_v2\%g40v2%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %g48%
|
||||
if exist "%~dp0pretrained\%g48%" (
|
||||
echo %g48% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlg48% -d %~dp0\pretrained -o %g48%
|
||||
if exist "%~dp0pretrained\%g48%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
|
||||
echo checking %hp2_all%
|
||||
if exist "%~dp0uvr5_weights\%hp2_all%" (
|
||||
echo %hp2_all% in .\uvr5_weights checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlhp2_all% -d %~dp0\uvr5_weights -o %hp2_all%
|
||||
if exist "%~dp0uvr5_weights\%hp2_all%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %hp3_all%
|
||||
if exist "%~dp0uvr5_weights\%hp3_all%" (
|
||||
echo %hp3_all% in .\uvr5_weights checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlhp3_all% -d %~dp0\uvr5_weights -o %hp3_all%
|
||||
if exist "%~dp0uvr5_weights\%hp3_all%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %hp5_only%
|
||||
if exist "%~dp0uvr5_weights\%hp5_only%" (
|
||||
echo %hp5_only% in .\uvr5_weights checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlhp5_only% -d %~dp0\uvr5_weights -o %hp5_only%
|
||||
if exist "%~dp0uvr5_weights\%hp5_only%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %VR_DeEchoAggressive%
|
||||
if exist "%~dp0uvr5_weights\%VR_DeEchoAggressive%" (
|
||||
echo %VR_DeEchoAggressive% in .\uvr5_weights checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlVR_DeEchoAggressive% -d %~dp0\uvr5_weights -o %VR_DeEchoAggressive%
|
||||
if exist "%~dp0uvr5_weights\%VR_DeEchoAggressive%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %VR_DeEchoDeReverb%
|
||||
if exist "%~dp0uvr5_weights\%VR_DeEchoDeReverb%" (
|
||||
echo %VR_DeEchoDeReverb% in .\uvr5_weights checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlVR_DeEchoDeReverb% -d %~dp0\uvr5_weights -o %VR_DeEchoDeReverb%
|
||||
if exist "%~dp0uvr5_weights\%VR_DeEchoDeReverb%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %VR_DeEchoNormal%
|
||||
if exist "%~dp0uvr5_weights\%VR_DeEchoNormal%" (
|
||||
echo %VR_DeEchoNormal% in .\uvr5_weights checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlVR_DeEchoNormal% -d %~dp0\uvr5_weights -o %VR_DeEchoNormal%
|
||||
if exist "%~dp0uvr5_weights\%VR_DeEchoNormal%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
echo checking %onnx_dereverb%
|
||||
if exist "%~dp0uvr5_weights\onnx_dereverb_By_FoxJoy\%onnx_dereverb%" (
|
||||
echo %onnx_dereverb% in .\uvr5_weights\onnx_dereverb_By_FoxJoy checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlonnx_dereverb% -d %~dp0\uvr5_weights\onnx_dereverb_By_FoxJoy -o %onnx_dereverb%
|
||||
if exist "%~dp0uvr5_weights\onnx_dereverb_By_FoxJoy\%onnx_dereverb%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
|
||||
echo checking %hb%
|
||||
if exist "%~dp0%hb%" (
|
||||
echo %hb% in .\pretrained checked.
|
||||
echo=
|
||||
) else (
|
||||
echo failed. starting download from huggingface.
|
||||
%~dp0%aria2%\aria2c --console-log-level=error -c -x 16 -s 16 -k 1M %dlhb% -d %~dp0 -o %hb%
|
||||
if exist "%~dp0%hb%" (echo download successful.) else (echo please try again!
|
||||
echo=)
|
||||
)
|
||||
|
||||
echo required files check finished.
|
||||
echo envfiles check complete.
|
||||
pause
|
||||
:end
|
||||
del flag.txt
|
||||
@@ -0,0 +1,546 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo working dir is $(pwd)
|
||||
echo downloading requirement aria2 check.
|
||||
|
||||
if command -v aria2c &> /dev/null
|
||||
then
|
||||
echo "aria2c command found"
|
||||
else
|
||||
echo failed. please install aria2
|
||||
sleep 5
|
||||
exit 1
|
||||
fi
|
||||
|
||||
d32="f0D32k.pth"
|
||||
d40="f0D40k.pth"
|
||||
d48="f0D48k.pth"
|
||||
g32="f0G32k.pth"
|
||||
g40="f0G40k.pth"
|
||||
g48="f0G48k.pth"
|
||||
|
||||
d40v2="f0D40k.pth"
|
||||
g40v2="f0G40k.pth"
|
||||
|
||||
dld32="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D32k.pth"
|
||||
dld40="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D40k.pth"
|
||||
dld48="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D48k.pth"
|
||||
dlg32="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G32k.pth"
|
||||
dlg40="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G40k.pth"
|
||||
dlg48="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G48k.pth"
|
||||
|
||||
dld40v2="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D40k.pth"
|
||||
dlg40v2="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G40k.pth"
|
||||
|
||||
hp2_all="HP2_all_vocals.pth"
|
||||
hp3_all="HP3_all_vocals.pth"
|
||||
hp5_only="HP5_only_main_vocal.pth"
|
||||
VR_DeEchoAggressive="VR-DeEchoAggressive.pth"
|
||||
VR_DeEchoDeReverb="VR-DeEchoDeReverb.pth"
|
||||
VR_DeEchoNormal="VR-DeEchoNormal.pth"
|
||||
onnx_dereverb="vocals.onnx"
|
||||
|
||||
dlhp2_all="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP2_all_vocals.pth"
|
||||
dlhp3_all="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP3_all_vocals.pth"
|
||||
dlhp5_only="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP5_only_main_vocal.pth"
|
||||
dlVR_DeEchoAggressive="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/VR-DeEchoAggressive.pth"
|
||||
dlVR_DeEchoDeReverb="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/VR-DeEchoDeReverb.pth"
|
||||
dlVR_DeEchoNormal="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/VR-DeEchoNormal.pth"
|
||||
dlonnx_dereverb="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/onnx_dereverb_By_FoxJoy/vocals.onnx"
|
||||
|
||||
hb="hubert_base.pt"
|
||||
|
||||
dlhb="https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt"
|
||||
|
||||
echo dir check start.
|
||||
|
||||
if [ -d "./pretrained" ]; then
|
||||
echo dir ./pretrained checked.
|
||||
else
|
||||
echo failed. generating dir ./pretrained.
|
||||
mkdir pretrained
|
||||
fi
|
||||
|
||||
if [ -d "./pretrained_v2" ]; then
|
||||
echo dir ./pretrained_v2 checked.
|
||||
else
|
||||
echo failed. generating dir ./pretrained_v2.
|
||||
mkdir pretrained_v2
|
||||
fi
|
||||
|
||||
if [ -d "./uvr5_weights" ]; then
|
||||
echo dir ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. generating dir ./uvr5_weights.
|
||||
mkdir uvr5_weights
|
||||
fi
|
||||
|
||||
if [ -d "./uvr5_weights/onnx_dereverb_By_FoxJoy" ]; then
|
||||
echo dir ./uvr5_weights/onnx_dereverb_By_FoxJoy checked.
|
||||
else
|
||||
echo failed. generating dir ./uvr5_weights/onnx_dereverb_By_FoxJoy.
|
||||
mkdir uvr5_weights/onnx_dereverb_By_FoxJoy
|
||||
fi
|
||||
|
||||
echo dir check finished.
|
||||
|
||||
echo required files check start.
|
||||
|
||||
echo checking D32k.pth
|
||||
if [ -f "./pretrained/D32k.pth" ]; then
|
||||
echo D32k.pth in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D32k.pth -d ./pretrained -o D32k.pth
|
||||
if [ -f "./pretrained/D32k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking D40k.pth
|
||||
if [ -f "./pretrained/D40k.pth" ]; then
|
||||
echo D40k.pth in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D40k.pth -d ./pretrained -o D40k.pth
|
||||
if [ -f "./pretrained/D40k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking D40k.pth
|
||||
if [ -f "./pretrained_v2/D40k.pth" ]; then
|
||||
echo D40k.pth in ./pretrained_v2 checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D40k.pth -d ./pretrained_v2 -o D40k.pth
|
||||
if [ -f "./pretrained_v2/D40k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking D48k.pth
|
||||
if [ -f "./pretrained/D48k.pth" ]; then
|
||||
echo D48k.pth in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D48k.pth -d ./pretrained -o D48k.pth
|
||||
if [ -f "./pretrained/D48k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking G32k.pth
|
||||
if [ -f "./pretrained/G32k.pth" ]; then
|
||||
echo G32k.pth in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G32k.pth -d ./pretrained -o G32k.pth
|
||||
if [ -f "./pretrained/G32k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking G40k.pth
|
||||
if [ -f "./pretrained/G40k.pth" ]; then
|
||||
echo G40k.pth in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G40k.pth -d ./pretrained -o G40k.pth
|
||||
if [ -f "./pretrained/G40k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking G40k.pth
|
||||
if [ -f "./pretrained_v2/G40k.pth" ]; then
|
||||
echo G40k.pth in ./pretrained_v2 checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G40k.pth -d ./pretrained_v2 -o G40k.pth
|
||||
if [ -f "./pretrained_v2/G40k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking G48k.pth
|
||||
if [ -f "./pretrained/G48k.pth" ]; then
|
||||
echo G48k.pth in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G48k.pth -d ./pretrained -o G48k.pth
|
||||
if [ -f "./pretrained/G48k.pth" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $d32
|
||||
if [ -f "./pretrained/$d32" ]; then
|
||||
echo $d32 in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dld32 -d ./pretrained -o $d32
|
||||
if [ -f "./pretrained/$d32" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $d40
|
||||
if [ -f "./pretrained/$d40" ]; then
|
||||
echo $d40 in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dld40 -d ./pretrained -o $d40
|
||||
if [ -f "./pretrained/$d40" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $d40v2
|
||||
if [ -f "./pretrained_v2/$d40v2" ]; then
|
||||
echo $d40v2 in ./pretrained_v2 checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dld40v2 -d ./pretrained_v2 -o $d40v2
|
||||
if [ -f "./pretrained_v2/$d40v2" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $d48
|
||||
if [ -f "./pretrained/$d48" ]; then
|
||||
echo $d48 in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dld48 -d ./pretrained -o $d48
|
||||
if [ -f "./pretrained/$d48" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $g32
|
||||
if [ -f "./pretrained/$g32" ]; then
|
||||
echo $g32 in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlg32 -d ./pretrained -o $g32
|
||||
if [ -f "./pretrained/$g32" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $g40
|
||||
if [ -f "./pretrained/$g40" ]; then
|
||||
echo $g40 in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlg40 -d ./pretrained -o $g40
|
||||
if [ -f "./pretrained/$g40" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $g40v2
|
||||
if [ -f "./pretrained_v2/$g40v2" ]; then
|
||||
echo $g40v2 in ./pretrained_v2 checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlg40v2 -d ./pretrained_v2 -o $g40v2
|
||||
if [ -f "./pretrained_v2/$g40v2" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $g48
|
||||
if [ -f "./pretrained/$g48" ]; then
|
||||
echo $g48 in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlg48 -d ./pretrained -o $g48
|
||||
if [ -f "./pretrained/$g48" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $hp2_all
|
||||
if [ -f "./uvr5_weights/$hp2_all" ]; then
|
||||
echo $hp2_all in ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlhp2_all -d ./uvr5_weights -o $hp2_all
|
||||
if [ -f "./uvr5_weights/$hp2_all" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $hp3_all
|
||||
if [ -f "./uvr5_weights/$hp3_all" ]; then
|
||||
echo $hp3_all in ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlhp3_all -d ./uvr5_weights -o $hp3_all
|
||||
if [ -f "./uvr5_weights/$hp3_all" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $hp5_only
|
||||
if [ -f "./uvr5_weights/$hp5_only" ]; then
|
||||
echo $hp5_only in ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlhp5_only -d ./uvr5_weights -o $hp5_only
|
||||
if [ -f "./uvr5_weights/$hp5_only" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $VR_DeEchoAggressive
|
||||
if [ -f "./uvr5_weights/$VR_DeEchoAggressive" ]; then
|
||||
echo $VR_DeEchoAggressive in ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlVR_DeEchoAggressive -d ./uvr5_weights -o $VR_DeEchoAggressive
|
||||
if [ -f "./uvr5_weights/$VR_DeEchoAggressive" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $VR_DeEchoDeReverb
|
||||
if [ -f "./uvr5_weights/$VR_DeEchoDeReverb" ]; then
|
||||
echo $VR_DeEchoDeReverb in ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlVR_DeEchoDeReverb -d ./uvr5_weights -o $VR_DeEchoDeReverb
|
||||
if [ -f "./uvr5_weights/$VR_DeEchoDeReverb" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $VR_DeEchoNormal
|
||||
if [ -f "./uvr5_weights/$VR_DeEchoNormal" ]; then
|
||||
echo $VR_DeEchoNormal in ./uvr5_weights checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlVR_DeEchoNormal -d ./uvr5_weights -o $VR_DeEchoNormal
|
||||
if [ -f "./uvr5_weights/$VR_DeEchoNormal" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $onnx_dereverb
|
||||
if [ -f "./uvr5_weights/onnx_dereverb_By_FoxJoy/$onnx_dereverb" ]; then
|
||||
echo $onnx_dereverb in ./uvr5_weights/onnx_dereverb_By_FoxJoy checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlonnx_dereverb -d ./uvr5_weights/onnx_dereverb_By_FoxJoy -o $onnx_dereverb
|
||||
if [ -f "./uvr5_weights/onnx_dereverb_By_FoxJoy/$onnx_dereverb" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo checking $hb
|
||||
if [ -f "./pretrained/$hb" ]; then
|
||||
echo $hb in ./pretrained checked.
|
||||
else
|
||||
echo failed. starting download from huggingface.
|
||||
if command -v aria2c &> /dev/null; then
|
||||
aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $dlhb -d ./ -o $hb
|
||||
if [ -f "./$hb" ]; then
|
||||
echo download successful.
|
||||
else
|
||||
echo please try again!
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo aria2c command not found. Please install aria2c and try again.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo required files check finished.
|
||||
read -p "Press any key to continue..." -n1 -s
|
||||
@@ -0,0 +1,54 @@
|
||||
from lib.infer_pack.models_onnx import SynthesizerTrnMsNSFsidM
|
||||
import torch
|
||||
|
||||
if __name__ == "__main__":
|
||||
MoeVS = True # 模型是否为MoeVoiceStudio(原MoeSS)使用
|
||||
|
||||
ModelPath = "Shiroha/shiroha.pth" # 模型路径
|
||||
ExportedPath = "model.onnx" # 输出路径
|
||||
hidden_channels = 256 # hidden_channels,为768Vec做准备
|
||||
cpt = torch.load(ModelPath, map_location="cpu")
|
||||
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
||||
print(*cpt["config"])
|
||||
|
||||
test_phone = torch.rand(1, 200, hidden_channels) # hidden unit
|
||||
test_phone_lengths = torch.tensor([200]).long() # hidden unit 长度(貌似没啥用)
|
||||
test_pitch = torch.randint(size=(1, 200), low=5, high=255) # 基频(单位赫兹)
|
||||
test_pitchf = torch.rand(1, 200) # nsf基频
|
||||
test_ds = torch.LongTensor([0]) # 说话人ID
|
||||
test_rnd = torch.rand(1, 192, 200) # 噪声(加入随机因子)
|
||||
|
||||
device = "cpu" # 导出时设备(不影响使用模型)
|
||||
|
||||
net_g = SynthesizerTrnMsNSFsidM(
|
||||
*cpt["config"], is_half=False
|
||||
) # fp32导出(C++要支持fp16必须手动将内存重新排列所以暂时不用fp16)
|
||||
net_g.load_state_dict(cpt["weight"], strict=False)
|
||||
input_names = ["phone", "phone_lengths", "pitch", "pitchf", "ds", "rnd"]
|
||||
output_names = [
|
||||
"audio",
|
||||
]
|
||||
# net_g.construct_spkmixmap(n_speaker) 多角色混合轨道导出
|
||||
torch.onnx.export(
|
||||
net_g,
|
||||
(
|
||||
test_phone.to(device),
|
||||
test_phone_lengths.to(device),
|
||||
test_pitch.to(device),
|
||||
test_pitchf.to(device),
|
||||
test_ds.to(device),
|
||||
test_rnd.to(device),
|
||||
),
|
||||
ExportedPath,
|
||||
dynamic_axes={
|
||||
"phone": [1],
|
||||
"pitch": [1],
|
||||
"pitchf": [1],
|
||||
"rnd": [2],
|
||||
},
|
||||
do_constant_folding=False,
|
||||
opset_version=16,
|
||||
verbose=False,
|
||||
input_names=input_names,
|
||||
output_names=output_names,
|
||||
)
|
||||
@@ -0,0 +1,199 @@
|
||||
"""
|
||||
|
||||
对源特征进行检索
|
||||
"""
|
||||
import torch, pdb, os, parselmouth
|
||||
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
|
||||
# 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 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))
|
||||
models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task(
|
||||
[model_path],
|
||||
suffix="",
|
||||
)
|
||||
model = models[0]
|
||||
model = model.to(device)
|
||||
model = model.half()
|
||||
model.eval()
|
||||
|
||||
# net_g = SynthesizerTrn256(1025,32,192,192,768,2,6,3,0.1,"1", [3,7,11],[[1,3,5], [1,3,5], [1,3,5]],[10,10,2,2],512,[16,16,4,4],183,256,is_half=True)#hifigan#512#256
|
||||
# net_g = SynthesizerTrn256(1025,32,192,192,768,2,6,3,0.1,"1", [3,7,11],[[1,3,5], [1,3,5], [1,3,5]],[10,10,2,2],512,[16,16,4,4],109,256,is_half=True)#hifigan#512#256
|
||||
net_g = SynthesizerTrn256(
|
||||
1025,
|
||||
32,
|
||||
192,
|
||||
192,
|
||||
768,
|
||||
2,
|
||||
6,
|
||||
3,
|
||||
0,
|
||||
"1",
|
||||
[3, 7, 11],
|
||||
[[1, 3, 5], [1, 3, 5], [1, 3, 5]],
|
||||
[10, 10, 2, 2],
|
||||
512,
|
||||
[16, 16, 4, 4],
|
||||
183,
|
||||
256,
|
||||
is_half=True,
|
||||
) # hifigan#512#256#no_dropout
|
||||
# net_g = SynthesizerTrn256(1025,32,192,192,768,2,3,3,0.1,"1", [3,7,11],[[1,3,5], [1,3,5], [1,3,5]],[10,10,2,2],512,[16,16,4,4],0)#ts3
|
||||
# net_g = SynthesizerTrn256(1025,32,192,192,768,2,6,3,0.1,"1", [3,7,11],[[1,3,5], [1,3,5], [1,3,5]],[10,10,2],512,[16,16,4],0)#hifigan-ps-sr
|
||||
#
|
||||
# net_g = SynthesizerTrn(1025, 32, 192, 192, 768, 2, 6, 3, 0.1, "1", [3, 7, 11], [[1, 3, 5], [1, 3, 5], [1, 3, 5]], [5,5], 512, [15,15], 0)#ms
|
||||
# net_g = SynthesizerTrn(1025, 32, 192, 192, 768, 2, 6, 3, 0.1, "1", [3, 7, 11], [[1, 3, 5], [1, 3, 5], [1, 3, 5]], [10,10], 512, [16,16], 0)#idwt2
|
||||
|
||||
# weights=torch.load("infer/ft-mi_1k-noD.pt")
|
||||
# weights=torch.load("infer/ft-mi-freeze-vocoder-flow-enc_q_1k.pt")
|
||||
# weights=torch.load("infer/ft-mi-freeze-vocoder_true_1k.pt")
|
||||
# weights=torch.load("infer/ft-mi-sim1k.pt")
|
||||
weights = torch.load("infer/ft-mi-no_opt-no_dropout.pt")
|
||||
print(net_g.load_state_dict(weights, strict=True))
|
||||
|
||||
net_g.eval().to(device)
|
||||
net_g.half()
|
||||
|
||||
|
||||
def get_f0(x, p_len, f0_up_key=0):
|
||||
time_step = 160 / 16000 * 1000
|
||||
f0_min = 50
|
||||
f0_max = 1100
|
||||
f0_mel_min = 1127 * np.log(1 + f0_min / 700)
|
||||
f0_mel_max = 1127 * np.log(1 + f0_max / 700)
|
||||
|
||||
f0 = (
|
||||
parselmouth.Sound(x, 16000)
|
||||
.to_pitch_ac(
|
||||
time_step=time_step / 1000,
|
||||
voicing_threshold=0.6,
|
||||
pitch_floor=f0_min,
|
||||
pitch_ceiling=f0_max,
|
||||
)
|
||||
.selected_array["frequency"]
|
||||
)
|
||||
|
||||
pad_size = (p_len - len(f0) + 1) // 2
|
||||
if pad_size > 0 or p_len - len(f0) - pad_size > 0:
|
||||
f0 = np.pad(f0, [[pad_size, p_len - len(f0) - pad_size]], mode="constant")
|
||||
f0 *= pow(2, f0_up_key / 12)
|
||||
f0bak = f0.copy()
|
||||
|
||||
f0_mel = 1127 * np.log(1 + f0 / 700)
|
||||
f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / (
|
||||
f0_mel_max - f0_mel_min
|
||||
) + 1
|
||||
f0_mel[f0_mel <= 1] = 1
|
||||
f0_mel[f0_mel > 255] = 255
|
||||
# f0_mel[f0_mel > 188] = 188
|
||||
f0_coarse = np.rint(f0_mel).astype(np.int32)
|
||||
return f0_coarse, f0bak
|
||||
|
||||
|
||||
import faiss
|
||||
|
||||
index = faiss.read_index("infer/added_IVF512_Flat_mi_baseline_src_feat.index")
|
||||
big_npy = np.load("infer/big_src_feature_mi.npy")
|
||||
ta0 = ta1 = ta2 = 0
|
||||
for idx, name in enumerate(
|
||||
[
|
||||
"冬之花clip1.wav",
|
||||
]
|
||||
): ##
|
||||
wav_path = "todo-songs/%s" % name #
|
||||
f0_up_key = -2 #
|
||||
audio, sampling_rate = sf.read(wav_path)
|
||||
if len(audio.shape) > 1:
|
||||
audio = librosa.to_mono(audio.transpose(1, 0))
|
||||
if sampling_rate != 16000:
|
||||
audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
|
||||
|
||||
feats = torch.from_numpy(audio).float()
|
||||
if feats.dim() == 2: # double channels
|
||||
feats = feats.mean(-1)
|
||||
assert feats.dim() == 1, feats.dim()
|
||||
feats = feats.view(1, -1)
|
||||
padding_mask = torch.BoolTensor(feats.shape).fill_(False)
|
||||
inputs = {
|
||||
"source": feats.half().to(device),
|
||||
"padding_mask": padding_mask.to(device),
|
||||
"output_layer": 9, # layer 9
|
||||
}
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.synchronize()
|
||||
t0 = ttime()
|
||||
with torch.no_grad():
|
||||
logits = model.extract_features(**inputs)
|
||||
feats = model.final_proj(logits[0])
|
||||
|
||||
####索引优化
|
||||
npy = feats[0].cpu().numpy().astype("float32")
|
||||
D, I = index.search(npy, 1)
|
||||
feats = (
|
||||
torch.from_numpy(big_npy[I.squeeze()].astype("float16")).unsqueeze(0).to(device)
|
||||
)
|
||||
|
||||
feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1)
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.synchronize()
|
||||
t1 = ttime()
|
||||
# p_len = min(feats.shape[1],10000,pitch.shape[0])#太大了爆显存
|
||||
p_len = min(feats.shape[1], 10000) #
|
||||
pitch, pitchf = get_f0(audio, p_len, f0_up_key)
|
||||
p_len = min(feats.shape[1], 10000, pitch.shape[0]) # 太大了爆显存
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.synchronize()
|
||||
t2 = ttime()
|
||||
feats = feats[:, :p_len, :]
|
||||
pitch = pitch[:p_len]
|
||||
pitchf = pitchf[:p_len]
|
||||
p_len = torch.LongTensor([p_len]).to(device)
|
||||
pitch = torch.LongTensor(pitch).unsqueeze(0).to(device)
|
||||
sid = torch.LongTensor([0]).to(device)
|
||||
pitchf = torch.FloatTensor(pitchf).unsqueeze(0).to(device)
|
||||
with torch.no_grad():
|
||||
audio = (
|
||||
net_g.infer(feats, p_len, pitch, pitchf, sid)[0][0, 0]
|
||||
.data.cpu()
|
||||
.float()
|
||||
.numpy()
|
||||
) # nsf
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.synchronize()
|
||||
t3 = ttime()
|
||||
ta0 += t1 - t0
|
||||
ta1 += t2 - t1
|
||||
ta2 += t3 - t2
|
||||
# wavfile.write("ft-mi_1k-index256-noD-%s.wav"%name, 40000, audio)##
|
||||
# wavfile.write("ft-mi-freeze-vocoder-flow-enc_q_1k-%s.wav"%name, 40000, audio)##
|
||||
# wavfile.write("ft-mi-sim1k-%s.wav"%name, 40000, audio)##
|
||||
wavfile.write("ft-mi-no_opt-no_dropout-%s.wav" % name, 40000, audio) ##
|
||||
|
||||
|
||||
print(ta0, ta1, ta2) #
|
||||
@@ -0,0 +1,72 @@
|
||||
"""
|
||||
格式:直接cid为自带的index位;aid放不下了,通过字典来查,反正就5w个
|
||||
"""
|
||||
import faiss, numpy as np, os
|
||||
from sklearn.cluster import MiniBatchKMeans
|
||||
import traceback
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
# ###########如果是原始特征要先写save
|
||||
n_cpu = 0
|
||||
if n_cpu == 0:
|
||||
n_cpu = cpu_count()
|
||||
inp_root = r"./logs/anz/3_feature768"
|
||||
npys = []
|
||||
listdir_res = list(os.listdir(inp_root))
|
||||
for name in sorted(listdir_res):
|
||||
phone = np.load("%s/%s" % (inp_root, name))
|
||||
npys.append(phone)
|
||||
big_npy = np.concatenate(npys, 0)
|
||||
big_npy_idx = np.arange(big_npy.shape[0])
|
||||
np.random.shuffle(big_npy_idx)
|
||||
big_npy = big_npy[big_npy_idx]
|
||||
print(big_npy.shape) # (6196072, 192)#fp32#4.43G
|
||||
if big_npy.shape[0] > 2e5:
|
||||
# if(1):
|
||||
info = "Trying doing kmeans %s shape to 10k centers." % big_npy.shape[0]
|
||||
print(info)
|
||||
try:
|
||||
big_npy = (
|
||||
MiniBatchKMeans(
|
||||
n_clusters=10000,
|
||||
verbose=True,
|
||||
batch_size=256 * n_cpu,
|
||||
compute_labels=False,
|
||||
init="random",
|
||||
)
|
||||
.fit(big_npy)
|
||||
.cluster_centers_
|
||||
)
|
||||
except:
|
||||
info = traceback.format_exc()
|
||||
print(info)
|
||||
|
||||
np.save("tools/infer/big_src_feature_mi.npy", big_npy)
|
||||
|
||||
##################train+add
|
||||
# big_npy=np.load("/bili-coeus/jupyter/jupyterhub-liujing04/vits_ch/inference_f0/big_src_feature_mi.npy")
|
||||
n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39)
|
||||
index = faiss.index_factory(768, "IVF%s,Flat" % n_ivf) # mi
|
||||
print("training")
|
||||
index_ivf = faiss.extract_index_ivf(index) #
|
||||
index_ivf.nprobe = 1
|
||||
index.train(big_npy)
|
||||
faiss.write_index(
|
||||
index, "tools/infer/trained_IVF%s_Flat_baseline_src_feat_v2.index" % (n_ivf)
|
||||
)
|
||||
print("adding")
|
||||
batch_size_add = 8192
|
||||
for i in range(0, big_npy.shape[0], batch_size_add):
|
||||
index.add(big_npy[i : i + batch_size_add])
|
||||
faiss.write_index(
|
||||
index, "tools/infer/added_IVF%s_Flat_mi_baseline_src_feat.index" % (n_ivf)
|
||||
)
|
||||
"""
|
||||
大小(都是FP32)
|
||||
big_src_feature 2.95G
|
||||
(3098036, 256)
|
||||
big_emb 4.43G
|
||||
(6196072, 192)
|
||||
big_emb双倍是因为求特征要repeat后再加pitch
|
||||
|
||||
"""
|
||||
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
格式:直接cid为自带的index位;aid放不下了,通过字典来查,反正就5w个
|
||||
"""
|
||||
import faiss, numpy as np, os
|
||||
|
||||
# ###########如果是原始特征要先写save
|
||||
inp_root = r"E:\codes\py39\dataset\mi\2-co256"
|
||||
npys = []
|
||||
for name in sorted(list(os.listdir(inp_root))):
|
||||
phone = np.load("%s/%s" % (inp_root, name))
|
||||
npys.append(phone)
|
||||
big_npy = np.concatenate(npys, 0)
|
||||
print(big_npy.shape) # (6196072, 192)#fp32#4.43G
|
||||
np.save("infer/big_src_feature_mi.npy", big_npy)
|
||||
|
||||
##################train+add
|
||||
# big_npy=np.load("/bili-coeus/jupyter/jupyterhub-liujing04/vits_ch/inference_f0/big_src_feature_mi.npy")
|
||||
print(big_npy.shape)
|
||||
index = faiss.index_factory(256, "IVF512,Flat") # mi
|
||||
print("training")
|
||||
index_ivf = faiss.extract_index_ivf(index) #
|
||||
index_ivf.nprobe = 9
|
||||
index.train(big_npy)
|
||||
faiss.write_index(index, "infer/trained_IVF512_Flat_mi_baseline_src_feat.index")
|
||||
print("adding")
|
||||
index.add(big_npy)
|
||||
faiss.write_index(index, "infer/added_IVF512_Flat_mi_baseline_src_feat.index")
|
||||
"""
|
||||
大小(都是FP32)
|
||||
big_src_feature 2.95G
|
||||
(3098036, 256)
|
||||
big_emb 4.43G
|
||||
(6196072, 192)
|
||||
big_emb双倍是因为求特征要repeat后再加pitch
|
||||
|
||||
"""
|
||||
@@ -0,0 +1,16 @@
|
||||
import torch, pdb
|
||||
|
||||
# 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#
|
||||
# a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-freeze-vocoder\G_1000.pth")["model"]#sim_nsf#
|
||||
# a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-test\G_1000.pth")["model"]#sim_nsf#
|
||||
a = torch.load(
|
||||
r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-no_opt-no_dropout\G_1000.pth"
|
||||
)[
|
||||
"model"
|
||||
] # sim_nsf#
|
||||
for key in a.keys():
|
||||
a[key] = a[key].half()
|
||||
# torch.save(a,"ft-mi-freeze-vocoder_true_1k.pt")#
|
||||
# torch.save(a,"ft-mi-sim1k.pt")#
|
||||
torch.save(a, "ft-mi-no_opt-no_dropout.pt") #
|
||||
@@ -0,0 +1,20 @@
|
||||
import soundfile
|
||||
from ..lib.infer_pack.onnx_inference import OnnxRVC
|
||||
|
||||
hop_size = 512
|
||||
sampling_rate = 40000 # 采样率
|
||||
f0_up_key = 0 # 升降调
|
||||
sid = 0 # 角色ID
|
||||
f0_method = "dio" # F0提取算法
|
||||
model_path = "ShirohaRVC.onnx" # 模型的完整路径
|
||||
vec_name = "vec-256-layer-9" # 内部自动补齐为 f"pretrained/{vec_name}.onnx" 需要onnx的vec模型
|
||||
wav_path = "123.wav" # 输入路径或ByteIO实例
|
||||
out_path = "out.wav" # 输出路径或ByteIO实例
|
||||
|
||||
model = OnnxRVC(
|
||||
model_path, vec_path=vec_name, sr=sampling_rate, hop_size=hop_size, device="cuda"
|
||||
)
|
||||
|
||||
audio = model.inference(wav_path, sid, f0_method=f0_method, f0_up_key=f0_up_key)
|
||||
|
||||
soundfile.write(out_path, audio, sampling_rate)
|
||||
Reference in New Issue
Block a user