1
0
mirror of synced 2024-11-24 07:30:16 +01:00

fix v2 onnx export

This commit is contained in:
RVC-Boss 2023-06-15 15:29:05 +00:00 committed by GitHub
parent 147d3c83b7
commit a071f1e089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1122,7 +1122,7 @@ from infer_pack.models_onnx import SynthesizerTrnMsNSFsidM
def export_onnx(ModelPath, ExportedPath, MoeVS=True):
cpt = torch.load(ModelPath, map_location="cpu")
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
hidden_channels = cpt["config"][-2] # hidden_channels为768Vec做准备
hidden_channels = 256 if cpt.get("version","v1")=="v1"else 768#cpt["config"][-2] # hidden_channels为768Vec做准备
test_phone = torch.rand(1, 200, hidden_channels) # hidden unit
test_phone_lengths = torch.tensor([200]).long() # hidden unit 长度(貌似没啥用)
@ -1134,7 +1134,7 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
device = "cpu" # 导出时设备(不影响使用模型)
net_g = SynthesizerTrnMsNSFsidM(
*cpt["config"], is_half=False
*cpt["config"], is_half=False,version=cpt.get("version","v1")
) # fp32导出C++要支持fp16必须手动将内存重新排列所以暂时不用fp16
net_g.load_state_dict(cpt["weight"], strict=False)
input_names = ["phone", "phone_lengths", "pitch", "pitchf", "ds", "rnd"]