mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-02-03 00:33:57 +03:00
WIP:improve model selector (so-vits-svc40v2)
This commit is contained in:
parent
0bb660ab2f
commit
069ebc22da
@ -32,22 +32,36 @@
|
|||||||
],
|
],
|
||||||
"modelSetting": [
|
"modelSetting": [
|
||||||
{
|
{
|
||||||
"name": "modelUploader",
|
"name": "modelUploaderv2",
|
||||||
|
"options": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "commonFileSelect",
|
||||||
"options": {
|
"options": {
|
||||||
"showConfig": true,
|
"title": "Config(.json)",
|
||||||
"showOnnx": false,
|
"acceptExtentions": ["json"],
|
||||||
"showPyTorch": true,
|
"fileKind": "soVitsSvc40v2Config"
|
||||||
"showCorrespondence": false,
|
|
||||||
"showPyTorchCluster": true,
|
|
||||||
"showPyTorchEnableCheckBox": true,
|
|
||||||
"defaultEnablePyTorch": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "framework",
|
"name": "commonFileSelect",
|
||||||
"options": {
|
"options": {
|
||||||
"showFramework": true
|
"title": "Model(.pth, .pt)",
|
||||||
|
"acceptExtentions": ["pth", "pt"],
|
||||||
|
"fileKind": "soVitsSvc40v2Model"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "commonFileSelect",
|
||||||
|
"options": {
|
||||||
|
"title": "Cluster(.pth, .pt)",
|
||||||
|
"acceptExtentions": ["pth", "pt"],
|
||||||
|
"fileKind": "soVitsSvc40v2Cluster"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "modelUploadButtonRow2",
|
||||||
|
"options": {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"lab": [],
|
"lab": [],
|
||||||
|
4
client/demo/dist/index.js
vendored
4
client/demo/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -32,22 +32,36 @@
|
|||||||
],
|
],
|
||||||
"modelSetting": [
|
"modelSetting": [
|
||||||
{
|
{
|
||||||
"name": "modelUploader",
|
"name": "modelUploaderv2",
|
||||||
|
"options": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "commonFileSelect",
|
||||||
"options": {
|
"options": {
|
||||||
"showConfig": true,
|
"title": "Config(.json)",
|
||||||
"showOnnx": false,
|
"acceptExtentions": ["json"],
|
||||||
"showPyTorch": true,
|
"fileKind": "soVitsSvc40v2Config"
|
||||||
"showCorrespondence": false,
|
|
||||||
"showPyTorchCluster": true,
|
|
||||||
"showPyTorchEnableCheckBox": true,
|
|
||||||
"defaultEnablePyTorch": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "framework",
|
"name": "commonFileSelect",
|
||||||
"options": {
|
"options": {
|
||||||
"showFramework": true
|
"title": "Model(.pth, .pt)",
|
||||||
|
"acceptExtentions": ["pth", "pt"],
|
||||||
|
"fileKind": "soVitsSvc40v2Model"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "commonFileSelect",
|
||||||
|
"options": {
|
||||||
|
"title": "Cluster(.pth, .pt)",
|
||||||
|
"acceptExtentions": ["pth", "pt"],
|
||||||
|
"fileKind": "soVitsSvc40v2Cluster"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "modelUploadButtonRow2",
|
||||||
|
"options": {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"lab": [],
|
"lab": [],
|
||||||
|
@ -18,6 +18,9 @@ export const Filekinds = {
|
|||||||
"soVitsSvc40Config": "soVitsSvc40Config",
|
"soVitsSvc40Config": "soVitsSvc40Config",
|
||||||
"soVitsSvc40Model": "soVitsSvc40Model",
|
"soVitsSvc40Model": "soVitsSvc40Model",
|
||||||
"soVitsSvc40Cluster": "soVitsSvc40Cluster",
|
"soVitsSvc40Cluster": "soVitsSvc40Cluster",
|
||||||
|
"soVitsSvc40v2Config": "soVitsSvc40v2Config",
|
||||||
|
"soVitsSvc40v2Model": "soVitsSvc40v2Model",
|
||||||
|
"soVitsSvc40v2Cluster": "soVitsSvc40v2Cluster",
|
||||||
|
|
||||||
"ddspSvcModel": "ddspSvcModel",
|
"ddspSvcModel": "ddspSvcModel",
|
||||||
"ddspSvcModelConfig": "ddspSvcModelConfig",
|
"ddspSvcModelConfig": "ddspSvcModelConfig",
|
||||||
|
@ -32,6 +32,10 @@ export type FileUploadSetting = {
|
|||||||
soVitsSvc40Config: ModelData | null
|
soVitsSvc40Config: ModelData | null
|
||||||
soVitsSvc40Model: ModelData | null
|
soVitsSvc40Model: ModelData | null
|
||||||
soVitsSvc40Cluster: ModelData | null
|
soVitsSvc40Cluster: ModelData | null
|
||||||
|
soVitsSvc40v2Config: ModelData | null
|
||||||
|
soVitsSvc40v2Model: ModelData | null
|
||||||
|
soVitsSvc40v2Cluster: ModelData | null
|
||||||
|
|
||||||
|
|
||||||
ddspSvcModel: ModelData | null
|
ddspSvcModel: ModelData | null
|
||||||
ddspSvcModelConfig: ModelData | null
|
ddspSvcModelConfig: ModelData | null
|
||||||
@ -62,6 +66,9 @@ const InitialFileUploadSetting: FileUploadSetting = {
|
|||||||
soVitsSvc40Config: null,
|
soVitsSvc40Config: null,
|
||||||
soVitsSvc40Model: null,
|
soVitsSvc40Model: null,
|
||||||
soVitsSvc40Cluster: null,
|
soVitsSvc40Cluster: null,
|
||||||
|
soVitsSvc40v2Config: null,
|
||||||
|
soVitsSvc40v2Model: null,
|
||||||
|
soVitsSvc40v2Cluster: null,
|
||||||
|
|
||||||
ddspSvcModel: null,
|
ddspSvcModel: null,
|
||||||
ddspSvcModelConfig: null,
|
ddspSvcModelConfig: null,
|
||||||
@ -257,6 +264,15 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
alert("モデルファイルを指定する必要があります。")
|
alert("モデルファイルを指定する必要があります。")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if (props.clientType == "so-vits-svc-40v2") {
|
||||||
|
if (!fileUploadSettings[slot].soVitsSvc40v2Config) {
|
||||||
|
alert("Configファイルを指定する必要があります。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!fileUploadSettings[slot].soVitsSvc40v2Model) {
|
||||||
|
alert("モデルファイルを指定する必要があります。")
|
||||||
|
return
|
||||||
|
}
|
||||||
} else if (props.clientType == "DDSP-SVC") {
|
} else if (props.clientType == "DDSP-SVC") {
|
||||||
if (!fileUploadSettings[slot].ddspSvcModel) {
|
if (!fileUploadSettings[slot].ddspSvcModel) {
|
||||||
alert("DDSPモデルを指定する必要があります。")
|
alert("DDSPモデルを指定する必要があります。")
|
||||||
@ -356,7 +372,10 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
fileUploadSetting.mmvcv15Model,
|
fileUploadSetting.mmvcv15Model,
|
||||||
fileUploadSetting.soVitsSvc40Config,
|
fileUploadSetting.soVitsSvc40Config,
|
||||||
fileUploadSetting.soVitsSvc40Model,
|
fileUploadSetting.soVitsSvc40Model,
|
||||||
fileUploadSetting.soVitsSvc40Cluster
|
fileUploadSetting.soVitsSvc40Cluster,
|
||||||
|
fileUploadSetting.soVitsSvc40v2Config,
|
||||||
|
fileUploadSetting.soVitsSvc40v2Model,
|
||||||
|
fileUploadSetting.soVitsSvc40v2Cluster
|
||||||
].filter(x => { return x != null }) as ModelData[]
|
].filter(x => { return x != null }) as ModelData[]
|
||||||
for (let i = 0; i < normalModels.length; i++) {
|
for (let i = 0; i < normalModels.length; i++) {
|
||||||
if (!normalModels[i].data) {
|
if (!normalModels[i].data) {
|
||||||
@ -400,6 +419,9 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
soVitsSvc40Config: fileUploadSetting.soVitsSvc40Config?.filename || "",
|
soVitsSvc40Config: fileUploadSetting.soVitsSvc40Config?.filename || "",
|
||||||
soVitsSvc40Model: fileUploadSetting.soVitsSvc40Model?.filename || "",
|
soVitsSvc40Model: fileUploadSetting.soVitsSvc40Model?.filename || "",
|
||||||
soVitsSvc40Cluster: fileUploadSetting.soVitsSvc40Cluster?.filename || "",
|
soVitsSvc40Cluster: fileUploadSetting.soVitsSvc40Cluster?.filename || "",
|
||||||
|
soVitsSvc40v2Config: fileUploadSetting.soVitsSvc40v2Config?.filename || "",
|
||||||
|
soVitsSvc40v2Model: fileUploadSetting.soVitsSvc40v2Model?.filename || "",
|
||||||
|
soVitsSvc40v2Cluster: fileUploadSetting.soVitsSvc40v2Cluster?.filename || "",
|
||||||
|
|
||||||
ddspSvcModel: fileUploadSetting.ddspSvcModel?.filename ? "ddsp_mod/" + fileUploadSetting.ddspSvcModel?.filename : "",
|
ddspSvcModel: fileUploadSetting.ddspSvcModel?.filename ? "ddsp_mod/" + fileUploadSetting.ddspSvcModel?.filename : "",
|
||||||
ddspSvcModelConfig: fileUploadSetting.ddspSvcModelConfig?.filename ? "ddsp_mod/" + fileUploadSetting.ddspSvcModelConfig?.filename : "",
|
ddspSvcModelConfig: fileUploadSetting.ddspSvcModelConfig?.filename ? "ddsp_mod/" + fileUploadSetting.ddspSvcModelConfig?.filename : "",
|
||||||
@ -480,6 +502,9 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
soVitsSvc40Config: fileUploadSetting.soVitsSvc40Config ? { data: fileUploadSetting.soVitsSvc40Config.data, filename: fileUploadSetting.soVitsSvc40Config.filename } : null,
|
soVitsSvc40Config: fileUploadSetting.soVitsSvc40Config ? { data: fileUploadSetting.soVitsSvc40Config.data, filename: fileUploadSetting.soVitsSvc40Config.filename } : null,
|
||||||
soVitsSvc40Model: fileUploadSetting.soVitsSvc40Model ? { data: fileUploadSetting.soVitsSvc40Model.data, filename: fileUploadSetting.soVitsSvc40Model.filename } : null,
|
soVitsSvc40Model: fileUploadSetting.soVitsSvc40Model ? { data: fileUploadSetting.soVitsSvc40Model.data, filename: fileUploadSetting.soVitsSvc40Model.filename } : null,
|
||||||
soVitsSvc40Cluster: fileUploadSetting.soVitsSvc40Cluster ? { data: fileUploadSetting.soVitsSvc40Cluster.data, filename: fileUploadSetting.soVitsSvc40Cluster.filename } : null,
|
soVitsSvc40Cluster: fileUploadSetting.soVitsSvc40Cluster ? { data: fileUploadSetting.soVitsSvc40Cluster.data, filename: fileUploadSetting.soVitsSvc40Cluster.filename } : null,
|
||||||
|
soVitsSvc40v2Config: fileUploadSetting.soVitsSvc40v2Config ? { data: fileUploadSetting.soVitsSvc40v2Config.data, filename: fileUploadSetting.soVitsSvc40v2Config.filename } : null,
|
||||||
|
soVitsSvc40v2Model: fileUploadSetting.soVitsSvc40v2Model ? { data: fileUploadSetting.soVitsSvc40v2Model.data, filename: fileUploadSetting.soVitsSvc40v2Model.filename } : null,
|
||||||
|
soVitsSvc40v2Cluster: fileUploadSetting.soVitsSvc40v2Cluster ? { data: fileUploadSetting.soVitsSvc40v2Cluster.data, filename: fileUploadSetting.soVitsSvc40v2Cluster.filename } : null,
|
||||||
|
|
||||||
ddspSvcModel: fileUploadSetting.ddspSvcModel ? { data: fileUploadSetting.ddspSvcModel.data, filename: fileUploadSetting.ddspSvcModel.filename } : null,
|
ddspSvcModel: fileUploadSetting.ddspSvcModel ? { data: fileUploadSetting.ddspSvcModel.data, filename: fileUploadSetting.ddspSvcModel.filename } : null,
|
||||||
ddspSvcModelConfig: fileUploadSetting.ddspSvcModelConfig ? { data: fileUploadSetting.ddspSvcModelConfig.data, filename: fileUploadSetting.ddspSvcModelConfig.filename } : null,
|
ddspSvcModelConfig: fileUploadSetting.ddspSvcModelConfig ? { data: fileUploadSetting.ddspSvcModelConfig.data, filename: fileUploadSetting.ddspSvcModelConfig.filename } : null,
|
||||||
|
@ -52,8 +52,8 @@ class SoVitsSvc40v2Settings:
|
|||||||
clusterInferRatio: float = 0.1
|
clusterInferRatio: float = 0.1
|
||||||
|
|
||||||
framework: str = "PyTorch" # PyTorch or ONNX
|
framework: str = "PyTorch" # PyTorch or ONNX
|
||||||
pyTorchModelFile: str = ""
|
pyTorchModelFile: str | None = ""
|
||||||
onnxModelFile: str = ""
|
onnxModelFile: str | None = ""
|
||||||
configFile: str = ""
|
configFile: str = ""
|
||||||
|
|
||||||
speakers: dict[str, int] = field(default_factory=lambda: {})
|
speakers: dict[str, int] = field(default_factory=lambda: {})
|
||||||
@ -79,13 +79,20 @@ class SoVitsSvc40v2:
|
|||||||
print("so-vits-svc 40v2 initialization:", params)
|
print("so-vits-svc 40v2 initialization:", params)
|
||||||
|
|
||||||
def loadModel(self, props: LoadModelParams):
|
def loadModel(self, props: LoadModelParams):
|
||||||
self.settings.configFile = props.files.configFilename
|
params = props.params
|
||||||
|
self.settings.configFile = params["files"]["soVitsSvc40v2Config"]
|
||||||
self.hps = utils.get_hparams_from_file(self.settings.configFile)
|
self.hps = utils.get_hparams_from_file(self.settings.configFile)
|
||||||
self.settings.speakers = self.hps.spk
|
self.settings.speakers = self.hps.spk
|
||||||
|
|
||||||
self.settings.pyTorchModelFile = props.files.pyTorchModelFilename
|
modelFile = params["files"]["soVitsSvc40v2Model"]
|
||||||
self.settings.onnxModelFile = props.files.onnxModelFilename
|
if modelFile.endswith(".onnx"):
|
||||||
clusterTorchModel = props.files.clusterTorchModelFilename
|
self.settings.pyTorchModelFile = None
|
||||||
|
self.settings.onnxModelFile = modelFile
|
||||||
|
else:
|
||||||
|
self.settings.pyTorchModelFile = modelFile
|
||||||
|
self.settings.onnxModelFile = None
|
||||||
|
|
||||||
|
clusterTorchModel = params["files"]["soVitsSvc40v2Cluster"]
|
||||||
|
|
||||||
content_vec_path = self.params.content_vec_500
|
content_vec_path = self.params.content_vec_500
|
||||||
hubert_base_path = self.params.hubert_base
|
hubert_base_path = self.params.hubert_base
|
||||||
@ -123,41 +130,45 @@ class SoVitsSvc40v2:
|
|||||||
|
|
||||||
# ONNXモデル生成
|
# ONNXモデル生成
|
||||||
if self.settings.onnxModelFile is not None:
|
if self.settings.onnxModelFile is not None:
|
||||||
ort_options = onnxruntime.SessionOptions()
|
providers, options = self.getOnnxExecutionProvider()
|
||||||
ort_options.intra_op_num_threads = 8
|
|
||||||
self.onnx_session = onnxruntime.InferenceSession(
|
self.onnx_session = onnxruntime.InferenceSession(
|
||||||
self.settings.onnxModelFile, providers=providers
|
self.settings.onnxModelFile,
|
||||||
|
providers=providers,
|
||||||
|
provider_options=options,
|
||||||
)
|
)
|
||||||
# input_info = self.onnx_session.get_inputs()
|
|
||||||
return self.get_info()
|
return self.get_info()
|
||||||
|
|
||||||
|
def getOnnxExecutionProvider(self):
|
||||||
|
if self.settings.gpu >= 0:
|
||||||
|
return ["CUDAExecutionProvider"], [{"device_id": self.settings.gpu}]
|
||||||
|
elif "DmlExecutionProvider" in onnxruntime.get_available_providers():
|
||||||
|
return ["DmlExecutionProvider"], []
|
||||||
|
else:
|
||||||
|
return ["CPUExecutionProvider"], [
|
||||||
|
{
|
||||||
|
"intra_op_num_threads": 8,
|
||||||
|
"execution_mode": onnxruntime.ExecutionMode.ORT_PARALLEL,
|
||||||
|
"inter_op_num_threads": 8,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
def isOnnx(self):
|
||||||
|
if self.settings.onnxModelFile is not None:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def update_settings(self, key: str, val: int | float | str):
|
def update_settings(self, key: str, val: int | float | str):
|
||||||
if key == "onnxExecutionProvider" and self.onnx_session is not None:
|
if key in self.settings.intData:
|
||||||
if val == "CUDAExecutionProvider":
|
|
||||||
if self.settings.gpu < 0 or self.settings.gpu >= self.gpu_num:
|
|
||||||
self.settings.gpu = 0
|
|
||||||
provider_options = [{"device_id": self.settings.gpu}]
|
|
||||||
self.onnx_session.set_providers(
|
|
||||||
providers=[val], provider_options=provider_options
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.onnx_session.set_providers(providers=[val])
|
|
||||||
elif key in self.settings.intData:
|
|
||||||
val = int(val)
|
val = int(val)
|
||||||
setattr(self.settings, key, val)
|
setattr(self.settings, key, val)
|
||||||
if (
|
|
||||||
key == "gpu"
|
if key == "gpu" and self.isOnnx():
|
||||||
and val >= 0
|
providers, options = self.getOnnxExecutionProvider()
|
||||||
and val < self.gpu_num
|
if self.onnx_session is not None:
|
||||||
and self.onnx_session is not None
|
|
||||||
):
|
|
||||||
providers = self.onnx_session.get_providers()
|
|
||||||
print("Providers:", providers)
|
|
||||||
if "CUDAExecutionProvider" in providers:
|
|
||||||
provider_options = [{"device_id": self.settings.gpu}]
|
|
||||||
self.onnx_session.set_providers(
|
self.onnx_session.set_providers(
|
||||||
providers=["CUDAExecutionProvider"],
|
providers=providers,
|
||||||
provider_options=provider_options,
|
provider_options=options,
|
||||||
)
|
)
|
||||||
elif key in self.settings.floatData:
|
elif key in self.settings.floatData:
|
||||||
setattr(self.settings, key, float(val))
|
setattr(self.settings, key, float(val))
|
||||||
@ -387,7 +398,7 @@ class SoVitsSvc40v2:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def inference(self, data):
|
def inference(self, data):
|
||||||
if self.settings.framework == "ONNX":
|
if self.isOnnx():
|
||||||
audio = self._onnx_inference(data)
|
audio = self._onnx_inference(data)
|
||||||
else:
|
else:
|
||||||
audio = self._pyTorch_inference(data)
|
audio = self._pyTorch_inference(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user