RVC-Boss / GPT-SoVITS

1 min voice data can also be used to train a good TTS model! (few shot voice cloning)
MIT License
36.17k stars 4.13k forks source link

在运行api_v2.py时报错,我看了有之前有人提bug说修复了,但这个api_v2没有修复吗?如何处理?谢谢 #1659

Open JosenJin opened 1 month ago

JosenJin commented 1 month ago

在运行api_v2.py时这个问题依然存在?请问怎么解决呀?

Traceback (most recent call last): File "D:\ai\josencomfyui\GPT-SoVITS\api_v2.py", line 144, in tts_pipeline = TTS(tts_config) ^^^^^^^^^^^^^^^ File "D:\ai\josencomfyui\GPT-SoVITS\GPT_SoVITS\TTS_infer_pack\TTS.py", line 252, in init self._init_models() File "D:\ai\josencomfyui\GPT-SoVITS\GPT_SoVITS\TTS_infer_pack\TTS.py", line 278, in _init_models self.init_vits_weights(self.configs.vits_weights_path) File "D:\ai\josencomfyui\GPT-SoVITS\GPT_SoVITS\TTS_infer_pack\TTS.py", line 337, in init_vits_weights vits_model.load_state_dict(dict_s2["weight"], strict=False) File "D:\ai\anaconda3\envs\comfyui\Lib\site-packages\torch\nn\modules\module.py", line 2215, 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 enc_p.text_embedding.weight: copying a param with shape torch.Size([732, 192]) from checkpoint, the shape in current model is torch.Size([322, 192]). size mismatch for ref_enc.spectral.0.fc.weight: copying a param with shape torch.Size([128, 704]) from checkpoint, the shape in current model is torch.Size([128, 1025]).

zhangjk1207 commented 1 month ago

想问下你这个模型是在哪里下载的啊,我遇到的问题刚好与你相反 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for SynthesizerTrn: size mismatch for enc_p.text_embedding.weight: copying a param with shape torch.Size([322, 192]) from checkpoint, the shape in current model is torch.Size([732, 192]). size mismatch for ref_enc.spectral.0.fc.weight: copying a param with shape torch.Size([128, 1025]) from checkpoint, the shape in current model is torch.Size([128, 704]).

XXXXRT666 commented 1 month ago

使用V2代码

LazyShower commented 1 month ago

想问下你这个模型是在哪里下载的啊,我遇到的问题刚好与你相反

我遇到跟樓主一樣的問題:

---------------------------------------------TTS Config---------------------------------------------
device              : cuda
is_half               : True
version             : v2
t2s_weights_path    : GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt
vits_weights_path   : GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth
bert_base_path      : GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large
cnhuhbert_base_path : GPT_SoVITS/pretrained_models/chinese-hubert-base
----------------------------------------------------------------------------------------------------

Loading Text2Semantic weights from GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt
Loading VITS weights from GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth

D:\anaconda3\envs\GPTSoVITS\lib\site-packages\torch\nn\utils\weight_norm.py:30:
UserWarning: torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.
warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.")

Traceback (most recent call last):
  File "D:\TTS_model\GPT-SoVITS\api_v2.py", line 143, in <module>
    tts_pipeline = TTS(tts_config)
  File "D:\TTS_model\GPT-SoVITS\GPT_SoVITS\TTS_infer_pack\TTS.py", line 252, in __init__
    self._init_models()
  File "D:\TTS_model\GPT-SoVITS\GPT_SoVITS\TTS_infer_pack\TTS.py", line 278, in _init_models
    self.init_vits_weights(self.configs.vits_weights_path)
  File "D:\TTS_model\GPT-SoVITS\GPT_SoVITS\TTS_infer_pack\TTS.py", line 336, in init_vits_weights
    vits_model.load_state_dict(dict_s2["weight"], strict=False)
  File "D:\anaconda3\envs\GPTSoVITS\lib\site-packages\torch\nn\modules\module.py", line 2152, 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 enc_p.text_embedding.weight: copying a param with shape torch.Size([732, 192]) from checkpoint, the shape in current model is torch.Size([322, 192]).
    size mismatch for ref_enc.spectral.0.fc.weight: copying a param with shape torch.Size([128, 704]) from checkpoint, the shape in current model is torch.Size([128, 1025]).

模型是來自官方md所提供 (托放在Huggung Face的檔案)

Pretrained Models

  1. Download pretrained models from GPT-SoVITS Models and place them in GPT_SoVITS/pretrained_models.

想請問 @XXXXRT666 大佬能否提供更多資訊嗎 我是在GPT-SoVITS根目錄,運行以下指令 python api_v2.py -a 127.0.0.1 -p 9880 -c GPT_SoVITS/configs/tts_infer.yaml 報錯。 十分感謝

XXXXRT666 commented 1 month ago

使用main的最新代码

anyiz commented 1 week ago

解决了吗,我也遇到这个问题了,和你一样

LazyShower commented 1 week ago

解決了我在windows系統可正常運行,你直接載首頁右手邊的20240821v2 (latest)載點,把壓縮包解壓後,一樣用api_v2.py代碼推理即可。