coqui-ai / TTS

🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
http://coqui.ai
Mozilla Public License 2.0
35.85k stars 4.39k forks source link

[Bug] error when loading xtts model #2976

Closed taalua closed 1 year ago

taalua commented 1 year ago

Describe the bug

Error when model.load_state_dict(checkpoint['model']):


RuntimeError: Error(s) in loading state_dict for Xtts:
    Unexpected key(s) in state_dict: "gpt.gpt_inference.transformer.h.0.ln_1.weight", "gpt.gpt_inference.transformer.h.0.ln_1.bias", "gpt.gpt_inference.transformer.h.0.attn.c_attn.weight", "gpt.gpt_inference.transformer.h.0.attn.c_attn.bias", "gpt.gpt_inference.transformer.h.0.attn.c_proj.weight", "gpt.gpt_inference.transformer.h.0.attn.c_proj.bias",

To Reproduce

git clone https://github.com/coqui-ai/TTS pip install -e . all

Expected behavior

No response

Logs

No response

Environment

{
    "CUDA": {
        "GPU": [
            "NVIDIA A40"
        ],
        "available": true,
        "version": "11.7"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.0.1+cu117",
        "TTS": "0.17.4",
        "numpy": "1.22.0"
    },
    "System": {
        "OS": "Linux",
        "architecture": [
            "64bit",
            "ELF"
        ],
        "processor": "x86_64",
        "python": "3.10.12",
        "version": "#1 SMP Wed Aug 09 15:22:17 UTC 2022"
    }
}

Additional context

No response

WeberJulian commented 1 year ago

Hello, run pip install transformers==4.33.1 and try again.

gorkemgoknar commented 1 year ago

If anyone experiencing issue even after transformers update, check if model files exists on xtts_v1 folder

This should print path check inside and if there is no file in it delete the folder xtts_v1

import os 
from TTS.utils.generic_utils import get_user_data_dir
model_path = os.path.join(get_user_data_dir("tts"), "tts_models--multilingual--multi-dataset--xtts_v1")
print(model_path)

Then after deleting xtts_v1 folder (if its contents are empty!) you can download model within code with this

import os 
os.environ["COQUI_TOS_AGREED"] = "1"
from TTS.api import TTS
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1") 

https://huggingface.co/coqui/XTTS-v1/discussions/8#651dc7be3cc79d62e6a9b864

erogol commented 1 year ago

I close this due to inactivity.

BrasD99 commented 1 year ago

For those who still face this problem: update TTS to the latest version. In my case, I just forgot about the fact that I have an old version installed locally ;)