Artrajz / vits-simple-api

A simple VITS HTTP API, developed by extending Moegoe with additional features.
GNU Affero General Public License v3.0
807 stars 119 forks source link

vits_chinese 配置运行错误 #84

Closed blackight closed 1 year ago

blackight commented 1 year ago

我注意到:

MODEL_LIST = [
    # VITS
    # [ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/1374_epochs.pth", ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/config.json"],
    # [ABS_PATH + "/Model/Zero_no_tsukaima/1158_epochs.pth", ABS_PATH + "/Model/Zero_no_tsukaima/config.json"],
    # [ABS_PATH + "/Model/g/G_953000.pth", ABS_PATH + "/Model/g/config.json"],
    [ABS_PATH + "/Model/vits_chinese/vits_bert_model.pth", ABS_PATH + "/Model/vits_chinese/bert_vits.json"],

但是 vits_chinese 的配置文件bert_vits.json image 因为没有symbols而被分类到ModelType.HUBERT_VITS,加载模型中出现错误

Traceback (most recent call last):
  File "/home/yunxing/vits-simple-api/app.py", line 30, in <module>
    tts = load_model(app.config["MODEL_LIST"])
  File "/home/yunxing/vits-simple-api/utils/load_model.py", line 149, in load_model
    hubert_vits_objs, hubert_vits_speakers = merge_models(categorized_models[ModelType.HUBERT_VITS], VITS, ModelType.HUBERT_VITS,
  File "/home/yunxing/vits-simple-api/utils/load_model.py", line 120, in merge_models
    obj = model_class(**obj_args)
  File "/home/yunxing/vits-simple-api/vits/vits.py", line 46, in __init__
    self.load_model(model, additional_model)
  File "/home/yunxing/vits-simple-api/vits/vits.py", line 49, in load_model
    utils.load_checkpoint(model, self.net_g_ms)
  File "/home/yunxing/vits-simple-api/utils/data_utils.py", line 56, in load_checkpoint
    model.load_state_dict(new_state_dict)
  File "/home/yunxing/miniconda3/envs/vitsapi/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1604, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for SynthesizerTrn:
    size mismatch for dp.proj.weight: copying a param with shape torch.Size([1, 256, 1]) from checkpoint, the shape in current model is torch.Size([192, 192, 1]).
    size mismatch for dp.proj.bias: copying a param with shape torch.Size([1]) from checkpoint, the shape in current model is torch.Size([192]).
Artrajz commented 1 year ago

官方项目中symbols是写在代码里的,在本项目中是从config.json中读取,所以需要手动添加symbols,这是一份完整的适用于该模型的config.json,此文件在也被上传在了hugging face上bert_vits.json

{
  "train": {
    "log_interval": 100,
    "eval_interval": 10000,
    "seed": 1234,
    "epochs": 20000,
    "learning_rate": 1e-4,
    "betas": [0.8, 0.99],
    "eps": 1e-9,
    "batch_size": 8,
    "fp16_run": false,
    "lr_decay": 0.999875,
    "segment_size": 12800,
    "init_lr_ratio": 1,
    "warmup_epochs": 0,
    "c_mel": 45,
    "c_kl": 1.0
  },
  "data": {
    "training_files":"filelists/train.txt",
    "validation_files":"filelists/valid.txt",
    "text_cleaners":["bert_chinese_cleaners"],
    "max_wav_value": 32768.0,
    "sampling_rate": 16000,
    "filter_length": 1024,
    "hop_length": 256,
    "win_length": 1024,
    "n_mel_channels": 80,
    "mel_fmin": 0.0,
    "mel_fmax": null,
    "add_blank": false,
    "n_speakers": 0
  },
  "model": {
    "inter_channels": 192,
    "hidden_channels": 192,
    "filter_channels": 768,
    "n_heads": 2,
    "n_layers": 6,
    "kernel_size": 3,
    "p_dropout": 0.1,
    "resblock": "1",
    "resblock_kernel_sizes": [3,7,11],
    "resblock_dilation_sizes": [[1,3,5], [1,3,5], [1,3,5]],
    "upsample_rates": [8,8,2,2],
    "upsample_initial_channel": 512,
    "upsample_kernel_sizes": [16,16,4,4],
    "n_layers_q": 3,
    "use_spectral_norm": false,
    "use_sdp": false,
    "bert_embedding": true
  },
  "speakers": ["bert"],
  "symbols": ["sil", "eos", "sp", "#0", "#1", "#2", "#3", "^", "b", "c", "ch", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "sh", "t", "x", "z", "zh", "a1", "a2", "a3", "a4", "a5", "ai1", "ai2", "ai3", "ai4", "ai5", "an1", "an2", "an3", "an4", "an5", "ang1", "ang2", "ang3", "ang4", "ang5", "ao1", "ao2", "ao3", "ao4", "ao5", "e1", "e2", "e3", "e4", "e5", "ei1", "ei2", "ei3", "ei4", "ei5", "en1", "en2", "en3", "en4", "en5", "eng1", "eng2", "eng3", "eng4", "eng5", "er1", "er2", "er3", "er4", "er5", "i1", "i2", "i3", "i4", "i5", "ia1", "ia2", "ia3", "ia4", "ia5", "ian1", "ian2", "ian3", "ian4", "ian5", "iang1", "iang2", "iang3", "iang4", "iang5", "iao1", "iao2", "iao3", "iao4", "iao5", "ie1", "ie2", "ie3", "ie4", "ie5", "ii1", "ii2", "ii3", "ii4", "ii5", "iii1", "iii2", "iii3", "iii4", "iii5", "in1", "in2", "in3", "in4", "in5", "ing1", "ing2", "ing3", "ing4", "ing5", "iong1", "iong2", "iong3", "iong4", "iong5", "iou1", "iou2", "iou3", "iou4", "iou5", "o1", "o2", "o3", "o4", "o5", "ong1", "ong2", "ong3", "ong4", "ong5", "ou1", "ou2", "ou3", "ou4", "ou5", "u1", "u2", "u3", "u4", "u5", "ua1", "ua2", "ua3", "ua4", "ua5", "uai1", "uai2", "uai3", "uai4", "uai5", "uan1", "uan2", "uan3", "uan4", "uan5", "uang1", "uang2", "uang3", "uang4", "uang5", "uei1", "uei2", "uei3", "uei4", "uei5", "uen1", "uen2", "uen3", "uen4", "uen5", "ueng1", "ueng2", "ueng3", "ueng4", "ueng5", "uo1", "uo2", "uo3", "uo4", "uo5", "v1", "v2", "v3", "v4", "v5", "van1", "van2", "van3", "van4", "van5", "ve1", "ve2", "ve3", "ve4", "ve5", "vn1", "vn2", "vn3", "vn4", "vn5"]
}
blackight commented 1 year ago

谢谢!我成功跑通了!