{"record":{"id":"82c7f645621d3300","repo":"RVC-Boss/GPT-SoVITS","slug":"sovits-s-lora","errorCode":null,"errorMessage":"SoVITS %s 底模缺失，无法加载相应 LoRA 权重","messagePattern":"SoVITS (.+?) 底模缺失，无法加载相应 LoRA 权重","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"GPT_SoVITS/TTS_infer_pack/TTS.py","lineNumber":502,"sourceCode":"    def init_bert_weights(self, base_path: str):\n        print(f\"Loading BERT weights from {base_path}\")\n        self.bert_tokenizer = AutoTokenizer.from_pretrained(base_path)\n        self.bert_model = AutoModelForMaskedLM.from_pretrained(base_path)\n        self.bert_model = self.bert_model.eval()\n        self.bert_model = self.bert_model.to(self.configs.device)\n        if self.configs.is_half and str(self.configs.device) != \"cpu\":\n            self.bert_model = self.bert_model.half()\n\n    def init_vits_weights(self, weights_path: str):\n        self.configs.vits_weights_path = weights_path\n        version, model_version, if_lora_v3 = get_sovits_version_from_path_fast(weights_path)\n        if \"Pro\" in model_version:\n            self.init_sv_model()\n        path_sovits = self.configs.default_configs[model_version][\"vits_weights_path\"]\n\n        if if_lora_v3 == True and os.path.exists(path_sovits) == False:\n            info = path_sovits + i18n(\"SoVITS %s 底模缺失，无法加载相应 LoRA 权重\" % model_version)\n            raise FileNotFoundError(info)\n\n        # dict_s2 = torch.load(weights_path, map_location=self.configs.device,weights_only=False)\n        dict_s2 = load_sovits_new(weights_path)\n        hps = dict_s2[\"config\"]\n        hps[\"model\"][\"semantic_frame_rate\"] = \"25hz\"\n        if \"enc_p.text_embedding.weight\" not in dict_s2[\"weight\"]:\n            hps[\"model\"][\"version\"] = \"v2\"  # v3model,v2sybomls\n        elif dict_s2[\"weight\"][\"enc_p.text_embedding.weight\"].shape[0] == 322:\n            hps[\"model\"][\"version\"] = \"v1\"\n        else:\n            hps[\"model\"][\"version\"] = \"v2\"\n        version = hps[\"model\"][\"version\"]\n        v3v4set = {\"v3\", \"v4\"}\n        if model_version not in v3v4set:\n            if \"Pro\" not in model_version:\n                model_version = version\n            else:\n                hps[\"model\"][\"version\"] = model_version","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/GPT_SoVITS/TTS_infer_pack/TTS.py#L484-L520","documentation":"Raised by init_vits_weights() when loading a SoVITS LoRA checkpoint whose detected model version is v3/v4 but the corresponding base (底模) checkpoint file does not exist at the path stored in configs.default_configs[model_version]['vits_weights_path']. LoRA weights only contain adapter deltas, so the full base model must be present to merge into. The message concatenates the expected base-model path with the missing-model notice so the user knows exactly which file to download.","triggerScenarios":"Calling TTS.init_vits_weights(weights_path) (or any wrapper like infer_batch / TTS init with a LoRA path) where get_sovits_version_from_path_fast() returns if_lora_v3=True and os.path.exists(configs.default_configs[model_version]['vits_weights_path']) is False — i.e. a 'SoVITS_v3'/'SoVITS_v4' lora file with no pre-trained base model in GPT_SoVITS/pretrained_models.","commonSituations":"User downloads only a v3/v4 LoRA finetune from a model-sharing site and drops it into a fresh install without the s2Gv3/s2Dv3 (or v4) pretrained base files; renamed or moved pretrained_models directory; configs pointing to a custom base path that was deleted; partial downloads interrupted so the base .pth is missing.","solutions":["Download the matching SoVITS v3 or v4 pretrained base models and place them under GPT_SoVITS/pretrained_models/ (check the exact expected path shown at the start of the error message).","Verify the path in configs.default_configs[model_version]['vits_weights_path'] actually points to the directory where you keep base models; update it if you relocated pretrained_models.","If you do not need v3/v4 features, convert or export the LoRA to a merged full checkpoint, or switch to a v1/v2 full sovits .pth which does not require a base model.","If you maintain the runtime, pre-validate before init: if if_lora_v3 and not os.path.exists(path_sovits), surface a download instruction instead of letting FileNotFoundError propagate."],"exampleFix":"# before\nhandler = TTS(config)  # crashes: FileNotFoundError ... SoVITS v3 底模缺失\nhandler.init_vits_weights(\"some_lora_v3.pth\")\n\n# after\n# put s2Gv3/s2Dv3 base pth files in GPT_SoVITS/pretrained_models/s2Gv3.pth etc., then\nhandler = TTS(config)\nhandler.init_vits_weights(\"some_lora_v3.pth\")  # loads and merges LoRA over base","handlingStrategy":"validation","validationCode":"import os\nfrom GPT_SoVITS.TTS_infer_pack.TTS import get_sovits_version_from_path_fast\n\nversion, model_version, if_lora = get_sovits_version_from_path_fast(sovits_path)\nbase_path = configs.default_configs[model_version][\"vits_weights_path\"]\nif if_lora and not os.path.exists(base_path):\n    raise SystemExit(f\"missing base model {base_path} — download pretrained {model_version} weights first\")","typeGuard":"def is_loadable_sovits(path: str, configs) -> bool:\n    \"\"\"True when path is a full checkpoint, or a lora with its base model present.\"\"\"\n    _, model_version, if_lora = get_sovits_version_from_path_fast(path)\n    if not if_lora:\n        return os.path.exists(path)\n    return os.path.exists(configs.default_configs[model_version][\"vits_weights_path\"])","tryCatchPattern":"try:\n    handler.init_vits_weights(sovits_path)\nexcept FileNotFoundError as e:\n    # message contains the expected base-model path; surface it with download instructions\n    log.error(\"LoRA base model missing: %s — download pretrained sovits weights\", e)","preventionTips":["Always install the full pretrained_models bundle before adding community LoRA checkpoints.","Keep pretrained_models at the documented path; update configs if you relocate it.","Wrap model switching in a pre-check of if_lora_v3 and base-model existence."],"tags":["model-weights","lora","sovits","missing-file","initialization"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}