sample update

This commit is contained in:
wataru 2023-05-24 20:49:24 +09:00
parent 55ea032a86
commit 3233377abd
16 changed files with 219 additions and 69 deletions

File diff suppressed because one or more lines are too long

View File

@ -70,7 +70,7 @@ export const StartButtonRow = (_props: StartButtonRowProps) => {
</div>
</div>
)
}, [guiState.isConverting, appState.clientSetting.start, appState.clientSetting.stop, appState.serverSetting.serverSetting, , appState.serverSetting.updateServerSettings])
}, [guiState.isConverting, appState.clientSetting.start, appState.clientSetting.stop, appState.serverSetting.serverSetting, appState.serverSetting.updateServerSettings])
return startButtonRow
}

View File

@ -39,7 +39,7 @@ export const ModelSwitchRow = (_props: ModelSwitchRowProps) => {
if (x.modelType == "pyTorchRVC" || x.modelType == "pyTorchRVCNono") {
return "org"
} else if (x.modelType == "pyTorchRVCv2" || x.modelType == "pyTorchRVCv2Nono") {
return "orv_v2"
return "org_v2"
} else if (x.modelType == "pyTorchWebUI" || x.modelType == "pyTorchWebUINono") {
return "webui"
} else {

View File

@ -15,6 +15,7 @@ export const ServerOpertationRow = (props: ServerOpertationRowProps) => {
const guiState = useGuiState()
const serverOpertationRow = useMemo(() => {
console.log("UPDATE OPERATION ROW:::::::::::::::::::::::")
const onnxExportButtonAction = async () => {
@ -78,7 +79,7 @@ export const ServerOpertationRow = (props: ServerOpertationRowProps) => {
</div>
</>
)
}, [appState.getInfo, appState.serverSetting.serverSetting])
}, [appState.getInfo, appState.serverSetting.serverSetting, guiState.isConverting])
return serverOpertationRow
}

View File

@ -121,7 +121,7 @@ export const MergeLabRow = (_props: MergeLabRowProps) => {
if (modelInfo.modelType == "pyTorchRVC" || modelInfo.modelType == "pyTorchRVCNono") {
return "org"
} else if (modelInfo.modelType == "pyTorchRVCv2" || modelInfo.modelType == "pyTorchRVCv2Nono") {
return "orv_v2"
return "g_v2"
} else if (modelInfo.modelType == "pyTorchWebUI" || modelInfo.modelType == "pyTorchWebUINono") {
return "webui"
} else {

View File

@ -12,7 +12,6 @@ class RVCModelSample:
name: str = ""
modelUrl: str = ""
indexUrl: str = ""
featureUrl: str = ""
termsOfUseUrl: str = ""
credit: str = ""
description: str = ""

View File

@ -101,8 +101,8 @@ class ServerAudioDeviceTypes(Enum):
SAMPLES_JSONS = [
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0001.json",
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0002.json",
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_t.json",
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_o.json",
]
RVC_MODEL_DIRNAME = "rvc"
RVC_MAX_SLOT_NUM = 5

View File

@ -0,0 +1,74 @@
{
"RVC": [
{
"id": "KikotoKurage_o",
"lang": "ja-JP",
"tag": ["v2", "onnx"],
"name": "黄琴海月",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_kurage/kikoto_kurage_v2_40k_e100_simple.onnx",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_kurage/added_IVF5181_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/raw/main/rvc_v2_alpha/kikoto_kurage/terms_of_use.txt",
"credit": "黄琴海月",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "KikotoMahiro_o",
"lang": "ja-JP",
"tag": ["v2", "onnx"],
"name": "黄琴まひろ",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_mahiro/kikoto_mahiro_v2_40k_simple.onnx",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_mahiro/added_IVF6881_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "",
"credit": "黄琴まひろ",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "TokinaShigure_o",
"lang": "ja-JP",
"tag": ["v2", "onnx"],
"name": "刻鳴時雨",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tokina_shigure/tokina_shigure_v2_40k_e100_simple.onnx",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tokina_shigure/added_IVF2736_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/raw/main/rvc_v2_alpha/tokina_shigure/terms_of_use.txt",
"credit": "刻鳴時雨",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "Amitaro_o",
"lang": "ja-JP",
"tag": ["v2", "onnx"],
"name": "あみたろ",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/amitaro/amitaro_v2_40k_e100_simple.onnx",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/amitaro/added_IVF3139_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/raw/main/rvc_v2_alpha/amitaro/terms_of_use.txt",
"credit": "あみたろ",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "Tsukuyomi-chan_o",
"lang": "ja-JP",
"tag": ["v2", "onnx"],
"name": "つくよみちゃん",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tsukuyomi-chan/tsukuyomi_v2_40k_e100_simple.onnx",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tsukuyomi-chan/added_IVF7852_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/blob/main/rvc_v2_alpha/tsukuyomi-chan/terms_of_use.txt",
"credit": "つくよみちゃん",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
}
]
}

View File

@ -0,0 +1,74 @@
{
"RVC": [
{
"id": "KikotoKurage_t",
"lang": "ja-JP",
"tag": ["v2", "torch"],
"name": "黄琴海月",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_kurage/kikoto_kurage_v2_40k_e100.pth",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_kurage/added_IVF5181_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/raw/main/rvc_v2_alpha/kikoto_kurage/terms_of_use.txt",
"credit": "黄琴海月",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "KikotoMahiro_t",
"lang": "ja-JP",
"tag": ["v2", "torch"],
"name": "黄琴まひろ",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_mahiro/kikoto_mahiro_v2_40k.pth",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/kikoto_mahiro/added_IVF6881_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "",
"credit": "黄琴まひろ",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "TokinaShigure_t",
"lang": "ja-JP",
"tag": ["v2", "torch"],
"name": "刻鳴時雨",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tokina_shigure/tokina_shigure_v2_40k_e100.pth",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tokina_shigure/added_IVF2736_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/raw/main/rvc_v2_alpha/tokina_shigure/terms_of_use.txt",
"credit": "刻鳴時雨",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "Amitaro_t",
"lang": "ja-JP",
"tag": ["v2", "torch"],
"name": "あみたろ",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/amitaro/amitaro_v2_40k_e100.pth",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/amitaro/added_IVF3139_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/raw/main/rvc_v2_alpha/amitaro/terms_of_use.txt",
"credit": "あみたろ",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
},
{
"id": "Tsukuyomi-chan_t",
"lang": "ja-JP",
"tag": ["v2", "torch"],
"name": "つくよみちゃん",
"modelUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tsukuyomi-chan/tsukuyomi_v2_40k_e100.pth",
"indexUrl": "https://huggingface.co/wok000/vcclient_model/resolve/main/rvc_v2_alpha/tsukuyomi-chan/added_IVF7852_Flat_nprobe_1_v2.index.bin",
"termsOfUseUrl": "https://huggingface.co/wok000/vcclient_model/blob/main/rvc_v2_alpha/tsukuyomi-chan/terms_of_use.txt",
"credit": "つくよみちゃん",
"description": "",
"sampleRate": 40000,
"modelType": "rvc_v2",
"f0": true
}
]
}

View File

@ -17,7 +17,7 @@ class ModelSlot:
samplingRate: int = -1
f0: bool = True
embChannels: int = 256
embOutputLayter: int = 9
embOutputLayer: int = 9
useFinalProj: bool = True
deprecated: bool = False
embedder: EnumEmbedderTypes = EnumEmbedderTypes.hubert

View File

@ -66,7 +66,7 @@ def _setInfoByPytorch(slot: ModelSlot):
else EnumInferenceTypes.pyTorchRVCNono
)
slot.embChannels = 256
slot.embOutputLayter = 9
slot.embOutputLayer = 9
slot.useFinalProj = True
slot.embedder = EnumEmbedderTypes.hubert
else:
@ -76,7 +76,7 @@ def _setInfoByPytorch(slot: ModelSlot):
else EnumInferenceTypes.pyTorchRVCv2Nono
)
slot.embChannels = 768
slot.embOutputLayter = 12
slot.embOutputLayer = 12
slot.useFinalProj = False
slot.embedder = EnumEmbedderTypes.hubert
@ -89,7 +89,7 @@ def _setInfoByPytorch(slot: ModelSlot):
else EnumInferenceTypes.pyTorchWebUINono
)
slot.embChannels = cpt["config"][17]
slot.embOutputLayter = (
slot.embOutputLayer = (
cpt["embedder_output_layer"] if "embedder_output_layer" in cpt else 9
)
if slot.embChannels == 256:
@ -100,19 +100,19 @@ def _setInfoByPytorch(slot: ModelSlot):
# DDPNモデルの情報を表示
if (
slot.embChannels == 256
and slot.embOutputLayter == 9
and slot.embOutputLayer == 9
and slot.useFinalProj is True
):
print("[Voice Changer] DDPN Model: Original v1 like")
elif (
slot.embChannels == 768
and slot.embOutputLayter == 12
and slot.embOutputLayer == 12
and slot.useFinalProj is False
):
print("[Voice Changer] DDPN Model: Original v2 like")
else:
print(
f"[Voice Changer] DDPN Model: ch:{slot.embChannels}, L:{slot.embOutputLayter}, FP:{slot.useFinalProj}"
f"[Voice Changer] DDPN Model: ch:{slot.embChannels}, L:{slot.embOutputLayer}, FP:{slot.useFinalProj}"
)
slot.embedder = cpt["embedder_name"]
@ -144,10 +144,15 @@ def _setInfoByONNX(slot: ModelSlot):
# slot.modelType = metadata["modelType"]
slot.embChannels = metadata["embChannels"]
slot.embOutputLayter = (
metadata["embedder_output_layer"]
if "embedder_output_layer" in metadata
else 9
slot.embOutputLayer = (
metadata["embOutputLayer"] if "embOutputLayer" in metadata else 9
)
slot.useFinalProj = (
metadata["useFinalProj"]
if "useFinalProj" in metadata
else True
if slot.embChannels == 256
else False
)
if slot.embChannels == 256:
@ -155,7 +160,23 @@ def _setInfoByONNX(slot: ModelSlot):
else:
slot.useFinalProj = False
print("ONNX", slot)
# ONNXモデルの情報を表示
if (
slot.embChannels == 256
and slot.embOutputLayer == 9
and slot.useFinalProj is True
):
print("[Voice Changer] ONNX Model: Original v1 like")
elif (
slot.embChannels == 768
and slot.embOutputLayer == 12
and slot.useFinalProj is False
):
print("[Voice Changer] ONNX Model: Original v2 like")
else:
print(
f"[Voice Changer] ONNX Model: ch:{slot.embChannels}, L:{slot.embOutputLayer}, FP:{slot.useFinalProj}"
)
if "embedder" not in metadata:
slot.embedder = EnumEmbedderTypes.hubert

View File

@ -86,7 +86,7 @@ class RVC:
if len(slot.modelFile) > 0:
self.prepareModel(i)
self.settings.modelSlotIndex = i
self.switchModel()
self.switchModel(self.settings.modelSlotIndex)
self.initialLoad = False
break
@ -115,12 +115,10 @@ class RVC:
if sampleInfo is None:
print("[Voice Changer] sampleInfo is None")
return
modelPath, indexPath, featurePath = downloadModelFiles(sampleInfo)
modelPath, indexPath = downloadModelFiles(sampleInfo)
params["files"]["rvcModel"] = modelPath
if indexPath is not None:
params["files"]["rvcIndex"] = indexPath
if featurePath is not None:
params["files"]["rvcFeature"] = featurePath
params["credit"] = sampleInfo.credit
params["description"] = sampleInfo.description
params["name"] = sampleInfo.name
@ -152,7 +150,7 @@ class RVC:
if self.initialLoad:
self.prepareModel(target_slot_idx)
self.settings.modelSlotIndex = target_slot_idx
self.switchModel()
self.switchModel(self.settings.modelSlotIndex)
self.initialLoad = False
elif target_slot_idx == self.currentSlot:
self.prepareModel(target_slot_idx)
@ -242,11 +240,12 @@ class RVC:
self.next_index_ratio = modelSlot.defaultIndexRatio
self.next_samplingRate = modelSlot.samplingRate
self.next_framework = "ONNX" if modelSlot.isONNX else "PyTorch"
self.needSwitch = True
# self.needSwitch = True
print("[Voice Changer] Prepare done.")
self.switchModel(slot)
return self.get_info()
def switchModel(self):
def switchModel(self, slot: int):
print("[Voice Changer] Switching model..")
self.pipeline = self.next_pipeline
self.settings.tran = self.next_trans
@ -254,6 +253,8 @@ class RVC:
self.settings.modelSamplingRate = self.next_samplingRate
self.settings.framework = self.next_framework
# self.currentSlot = self.settings.modelSlotIndex # prepareModelから呼ばれるということはupdate_settingsの中で呼ばれるということなので、まだmodelSlotIndexは更新されていない
self.currentSlot = slot
print(
"[Voice Changer] Switching model..done",
)
@ -308,13 +309,12 @@ class RVC:
self.currentSlot,
)
raise NoModeLoadedException("model_common")
if self.needSwitch:
print(
f"[Voice Changer] Switch model {self.currentSlot} -> {self.settings.modelSlotIndex}"
)
self.currentSlot = self.settings.modelSlotIndex
self.switchModel()
self.needSwitch = False
# if self.needSwitch:
# print(
# f"[Voice Changer] Switch model {self.currentSlot} -> {self.settings.modelSlotIndex}"
# )
# self.switchModel()
# self.needSwitch = False
half = self.deviceManager.halfPrecisionAvailable(self.settings.gpu)
@ -333,7 +333,7 @@ class RVC:
f0_up_key = self.settings.tran
index_rate = self.settings.indexRatio
if_f0 = 1 if self.settings.modelSlots[self.currentSlot].f0 else 0
embOutputLayer = self.settings.modelSlots[self.currentSlot].embOutputLayter
embOutputLayer = self.settings.modelSlots[self.currentSlot].embOutputLayer
useFinalProj = self.settings.modelSlots[self.currentSlot].useFinalProj
audio_out = self.pipeline.exec(

View File

@ -16,10 +16,10 @@ def checkRvcModelExist(model_dir: str):
def downloadInitialSampleModels(sampleJsons: list[str], model_dir: str):
sampleModelIds = [
"KikotoMahiro",
"TokinaShigure",
"Amitaro",
"Tsukuyomi-chan",
"KikotoMahiro_o",
"TokinaShigure_o",
"Amitaro_o",
"Tsukuyomi-chan_o",
]
sampleModels = getModelSamples(sampleJsons, "RVC")
if sampleModels is None:
@ -60,23 +60,7 @@ def downloadInitialSampleModels(sampleJsons: list[str], model_dir: str):
"position": line_num,
}
)
sampleParams["files"]["rvcIndex"] = modelFilePath
line_num += 1
featurePath = None
if hasattr(sample, "featureUrl") or sample.featureUrl != "":
featurePath = os.path.join(
slotDir,
os.path.basename(sample.featureUrl),
)
downloadParams.append(
{
"url": sample.featureUrl,
"saveTo": featurePath,
"position": line_num,
}
)
sampleParams["files"]["rvcFeatur"] = modelFilePath
sampleParams["files"]["rvcIndex"] = indexPath
line_num += 1
sampleParams["sampleId"] = sample.id
@ -123,19 +107,8 @@ def downloadModelFiles(sampleInfo: RVCModelSample):
}
)
featurePath = None
if hasattr(sampleInfo, "featureUrl") or sampleInfo.featureUrl != "":
featurePath = os.path.join(TMP_DIR, os.path.basename(sampleInfo.featureUrl))
downloadParams.append(
{
"url": sampleInfo.featureUrl,
"saveTo": featurePath,
"position": 2,
}
)
print("[Voice Changer] Downloading model files...", end="")
with ThreadPoolExecutor() as pool:
pool.map(download_no_tqdm, downloadParams)
print("")
return modelPath, indexPath, featurePath
return modelPath, indexPath

View File

@ -64,5 +64,10 @@ def merge_model(request: MergeModelRequest):
merged["embedder_name"] = (
state_dict["embedder_name"] if "embedder_name" in state_dict else None
)
merged["embedder_output_layer"] = (
state_dict["embedder_output_layer"]
if "embedder_output_layer" in state_dict
else None
)
print("write metadata done.")
return merged

View File

@ -45,6 +45,8 @@ def export2onnx(gpu: int, modelSlot: ModelSlot):
"embChannels": modelSlot.embChannels,
# ↓EnumEmbedderTypesのままだとシリアライズできないのでテキスト化
"embedder": modelSlot.embedder.value,
"embOutputLayer": modelSlot.embOutputLayer,
"useFinalProj": modelSlot.useFinalProj,
}
gpuMomory = DeviceManager.get_instance().getDeviceMemory(gpu)
print(f"[Voice Changer] exporting onnx... gpu_id:{gpu} gpu_mem:{gpuMomory}")

View File

@ -74,6 +74,7 @@ def _loadIndex(modelSlot: ModelSlot):
return None
try:
print("Try loading...", modelSlot.indexFile)
index = faiss.read_index(modelSlot.indexFile)
except:
print("[Voice Changer] load index failed. Use no index.")