WIP: support rvc v2

This commit is contained in:
wataru 2023-05-21 11:50:28 +09:00
parent 25bb1ee078
commit 1405a276a9
6 changed files with 48 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -35,7 +35,18 @@ export const ModelSwitchRow = (_props: ModelSwitchRowProps) => {
const f0str = x.f0 == true ? "f0" : "nof0" const f0str = x.f0 == true ? "f0" : "nof0"
const srstr = Math.floor(x.samplingRate / 1000) + "K" const srstr = Math.floor(x.samplingRate / 1000) + "K"
const embedstr = x.embChannels const embedstr = x.embChannels
const typestr = x.modelType == 0 ? "org" : "webui" const typestr = (() => {
if (x.modelType == "pyTorchRVC" || x.modelType == "pyTorchRVCNono") {
return "org"
} else if (x.modelType == "pyTorchRVCv2" || x.modelType == "pyTorchRVCv2Nono") {
return "orv_v2"
} else if (x.modelType == "pyTorchWebUI" || x.modelType == "pyTorchWebUINono") {
return "webui"
} else {
return "unknown"
}
})()
const metadata = x.deprecated ? `[${index}] [deprecated version]` : `[${index}] [${f0str},${srstr},${embedstr},${typestr}]` const metadata = x.deprecated ? `[${index}] [deprecated version]` : `[${index}] [${f0str},${srstr},${embedstr},${typestr}]`
const tuning = `t:${x.defaultTune}` const tuning = `t:${x.defaultTune}`
const useIndex = x.indexFile != null && x.featureFile != null ? `i:true` : `i:false` const useIndex = x.indexFile != null && x.featureFile != null ? `i:true` : `i:false`

View File

@ -83,6 +83,9 @@ export const MergeLabRow = (_props: MergeLabRowProps) => {
srcSample.modelType != tgtSample.modelType srcSample.modelType != tgtSample.modelType
) { ) {
alert("current selected model is not same as the other selected.") alert("current selected model is not same as the other selected.")
console.log("current selected model is not same as the other selected.", srcSample.samplingRate, tgtSample.samplingRate,
srcSample.embChannels, tgtSample.embChannels,
srcSample.modelType, tgtSample.modelType)
return return
} }
@ -114,7 +117,18 @@ export const MergeLabRow = (_props: MergeLabRowProps) => {
const f0str = modelInfo.f0 == true ? "f0" : "nof0" const f0str = modelInfo.f0 == true ? "f0" : "nof0"
const srstr = Math.floor(modelInfo.samplingRate / 1000) + "K" const srstr = Math.floor(modelInfo.samplingRate / 1000) + "K"
const embedstr = modelInfo.embChannels const embedstr = modelInfo.embChannels
const typestr = modelInfo.modelType == 0 ? "org" : "webui" const typestr = (() => {
if (modelInfo.modelType == "pyTorchRVC" || modelInfo.modelType == "pyTorchRVCNono") {
return "org"
} else if (modelInfo.modelType == "pyTorchRVCv2" || modelInfo.modelType == "pyTorchRVCv2Nono") {
return "orv_v2"
} else if (modelInfo.modelType == "pyTorchWebUI" || modelInfo.modelType == "pyTorchWebUINono") {
return "webui"
} else {
return "unknown"
}
})()
const metadata = `[${f0str},${srstr},${embedstr},${typestr}]` const metadata = `[${f0str},${srstr},${embedstr},${typestr}]`

View File

@ -70,6 +70,17 @@ export const DiffMethod = {
} as const } as const
export type DiffMethod = typeof DiffMethod[keyof typeof DiffMethod] export type DiffMethod = typeof DiffMethod[keyof typeof DiffMethod]
export const ModelType = {
"pyTorchRVC": "pyTorchRVC",
"pyTorchRVCNono": "pyTorchRVCNono",
"pyTorchRVCv2": "pyTorchRVCv2",
"pyTorchRVCv2Nono": "pyTorchRVCv2Nono",
"pyTorchWebUI": "pyTorchWebUI",
"pyTorchWebUINono": "pyTorchWebUINono",
"onnxRVC": "onnxRVC",
"onnxRVCNono": "onnxRVCNono",
} as const
export type ModelType = typeof ModelType[keyof typeof ModelType]
export const ServerSettingKey = { export const ServerSettingKey = {
"srcId": "srcId", "srcId": "srcId",
@ -188,7 +199,7 @@ type ModelSlot = {
defaultTune: number, defaultTune: number,
defaultIndexRatio: number, defaultIndexRatio: number,
modelType: number, modelType: ModelType,
embChannels: number, embChannels: number,
f0: boolean, f0: boolean,
samplingRate: number samplingRate: number

View File

@ -57,7 +57,8 @@ def _setInfoByPytorch(slot: ModelSlot):
if config_len == 18: if config_len == 18:
slot.f0 = True if cpt["f0"] == 1 else False slot.f0 = True if cpt["f0"] == 1 else False
version = cpt.get("version", "v1") version = cpt.get("version", "v1")
if version == "v1": print("version..............", version)
if version is None or version == "v1":
slot.modelType = ( slot.modelType = (
EnumInferenceTypes.pyTorchRVC EnumInferenceTypes.pyTorchRVC
if slot.f0 if slot.f0
@ -74,6 +75,7 @@ def _setInfoByPytorch(slot: ModelSlot):
slot.embChannels = 768 slot.embChannels = 768
slot.embedder = EnumEmbedderTypes.hubert slot.embedder = EnumEmbedderTypes.hubert
print("model slot ORG", slot)
else: else:
slot.f0 = True if cpt["f0"] == 1 else False slot.f0 = True if cpt["f0"] == 1 else False
slot.modelType = ( slot.modelType = (
@ -95,6 +97,8 @@ def _setInfoByPytorch(slot: ModelSlot):
else: else:
raise RuntimeError("[Voice Changer][setInfoByONNX] unknown embedder") raise RuntimeError("[Voice Changer][setInfoByONNX] unknown embedder")
print("model slot DADAPAN", slot)
slot.samplingRate = cpt["config"][-1] slot.samplingRate = cpt["config"][-1]
del cpt del cpt

View File

@ -57,6 +57,7 @@ def merge_model(request: MergeModelRequest):
merged["config"] = state_dict["config"] merged["config"] = state_dict["config"]
merged["params"] = state_dict["params"] if "params" in state_dict else None merged["params"] = state_dict["params"] if "params" in state_dict else None
merged["version"] = state_dict["version"] if "version" in state_dict else None
merged["sr"] = state_dict["sr"] merged["sr"] = state_dict["sr"]
merged["f0"] = state_dict["f0"] merged["f0"] = state_dict["f0"]
merged["info"] = state_dict["info"] merged["info"] = state_dict["info"]