{"record":{"id":"7f5a91edb551e70b","repo":"RVC-Boss/GPT-SoVITS","slug":"error-unknown-model-type-if-you-are-using-a-mode","errorCode":null,"errorMessage":"Error: Unknown model type. If you are using a model without a configuration file, Ensure that your model name includes 'bs_roformer', 'bsroformer', 'mel_band_roformer', or 'melbandroformer'. Otherwise, you can manually place the model configuration file into 'tools/uvr5/uvr5w_weights' and ensure that the configuration file is named as '<model_name>.yaml' then try it again.","messagePattern":"Error: Unknown model type\\. If you are using a model without a configuration file, Ensure that your model name includes 'bs_roformer', 'bsroformer', 'mel_band_roformer', or 'melbandroformer'\\. Otherwise, you can manually place the model configuration file into 'tools/uvr5/uvr5w_weights' and ensure that the configuration file is named as '<model_name>\\.yaml' then try it again\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/uvr5/bsroformer.py","lineNumber":277,"sourceCode":"            except:\n                pass\n\n    def __init__(self, model_path, config_path, device, is_half):\n        self.device = device\n        self.is_half = is_half\n        self.model_type = None\n        self.config = None\n\n        # get model_type, first try:\n        if \"bs_roformer\" in model_path.lower() or \"bsroformer\" in model_path.lower():\n            self.model_type = \"bs_roformer\"\n        elif \"mel_band_roformer\" in model_path.lower() or \"melbandroformer\" in model_path.lower():\n            self.model_type = \"mel_band_roformer\"\n\n        if not os.path.exists(config_path):\n            if self.model_type is None:\n                # if model_type is still None, raise an error\n                raise ValueError(\n                    \"Error: Unknown model type. If you are using a model without a configuration file, Ensure that your model name includes 'bs_roformer', 'bsroformer', 'mel_band_roformer', or 'melbandroformer'. Otherwise, you can manually place the model configuration file into 'tools/uvr5/uvr5w_weights' and ensure that the configuration file is named as '<model_name>.yaml' then try it again.\"\n                )\n            self.config = self.get_default_config()\n        else:\n            # if there is a configuration file\n            self.config = self.get_config(config_path)\n            if self.model_type is None:\n                # if model_type is still None, second try, get model_type from the configuration file\n                if \"freqs_per_bands\" in self.config[\"model\"]:\n                    # if freqs_per_bands in config, it's a bs_roformer model\n                    self.model_type = \"bs_roformer\"\n                else:\n                    # else it's a mel_band_roformer model\n                    self.model_type = \"mel_band_roformer\"\n\n        print(\"Detected model type: {}\".format(self.model_type))\n        model = self.get_model_from_config()\n        state_dict = torch.load(model_path, map_location=\"cpu\")","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/tools/uvr5/bsroformer.py#L259-L295","documentation":"This ValueError is raised by the BSRoformer wrapper's __init__ (tools/uvr5/bsroformer.py:277) when it cannot determine the architecture of a downloaded Roformer separation model. Model type is first inferred from substrings in the model filename ('bs_roformer'/'bsroformer' or 'mel_band_roformer'/'melbandroformer'); if none match and no YAML configuration file exists at the expected config_path, the wrapper has no way to build the model, so it aborts immediately. The error is purely about naming/config discovery, not about corrupted weights or CUDA issues.","triggerScenarios":"Constructing BSRoformer(model_path, config_path, device, is_half) (or selecting a Roformer model in the UVR5 web UI) where: (1) model_path's basename contains none of the four recognized substrings (case-insensitive), AND (2) os.path.exists(config_path) is False — i.e. there is no '<model_name>.yaml' sitting next to the weights in tools/uvr5/uvr5w_weights. Typical concrete cases: a checkpoint renamed to 'my_vocal_model.ckpt', a file downloaded as 'model_v2X.ckpt' with the architecture name stripped, or the companion YAML placed in the wrong directory / named differently from the .ckpt basename.","commonSituations":"Users of RVC/Retrieval-based-Voice-Conversion-WebUI (or the bundled tools/uvr5 package) dropping a manually downloaded UVR Roformer checkpoint into the weights folder. Many HuggingFace/UVR releases ship the .ckpt and its .yaml as separate downloads, and users grab only the .ckpt, rename it for tidiness, or let the browser dedupe/strip the name. Older repo versions also had different default weight directories, so models carried over from a previous install hit the missing-config branch.","solutions":["Rename the checkpoint file so its name contains a recognized architecture substring, e.g. 'model_bs_roformer_ep0173.ckpt' or 'vocals_mel_band_roformer.ckpt' — then no YAML is needed because get_default_config() supplies one.","Alternatively, keep the original filename and place the model's YAML config in tools/uvr5/uvr5w_weights named exactly '<model_name>.yaml' (same basename as the .ckpt); the config branch will infer the type from the presence of 'freqs_per_bands'.","Re-download the model from its official UVR/HuggingFace source without renaming, so the architecture substring and any companion YAML are preserved.","If you drive BSRoformer programmatically, verify the derived config_path exists before constructing, and point config_path at the correct YAML instead of relying on the default location."],"exampleFix":"// before (in tools/uvr5/uvr5w_weights)\n//   vocals_best.ckpt          <- no architecture substring, no YAML -> ValueError\n\n// after (option A: rename the file)\n//   vocals_best_bs_roformer.ckpt\n\n// after (option B: keep name, add matching YAML)\n//   vocals_best.ckpt\n//   vocals_best.yaml          <- copied from the model's official config","handlingStrategy":"validation","validationCode":"import os\n\nWEIGHTS_DIR = \"tools/uvr5/uvr5w_weights\"\nARCH_SUBSTRINGS = (\"bs_roformer\", \"bsroformer\", \"mel_band_roformer\", \"melbandroformer\")\n\ndef validate_roformer_model(model_path):\n    \"\"\"Return (ok, detail). Checks the exact conditions that trigger the ValueError.\"\"\"\n    name = os.path.basename(model_path).lower()\n    config_path = os.path.join(WEIGHTS_DIR, os.path.basename(model_path).rsplit(\".\", 1)[0] + \".yaml\")\n    has_arch_name = any(s in name for s in ARCH_SUBSTRINGS)\n    has_config = os.path.exists(config_path)\n    if not has_arch_name and not has_config:\n        return False, (\n            f\"'{os.path.basename(model_path)}' has no architecture substring \"\n            f\"and no config at '{config_path}'. Rename the file to include \"\n            f\"one of {ARCH_SUBSTRINGS} or place a '<model_name>.yaml' beside it.\"\n        )\n    return True, \"ok\"","typeGuard":"def is_recognized_roformer_checkpoint(model_path: str) -> bool:\n    \"\"\"Narrowing check mirroring BSRoformer.__init__ first-try logic.\"\"\"\n    name = model_path.lower()\n    return (\"bs_roformer\" in name or \"bsroformer\" in name\n            or \"mel_band_roformer\" in name or \"melbandroformer\" in name)","tryCatchPattern":"from tools.uvr5.bsroformer import BSRoformer\n\ntry:\n    roformer = BSRoformer(model_path, config_path, device, is_half)\nexcept ValueError as e:\n    if \"Unknown model type\" in str(e):\n        # Naming/config problem: fix the filename or ship the YAML, then retry.\n        raise RuntimeError(\n            f\"Cannot load '{model_path}': rename it to include \"\n            \"bs_roformer/bsroformer/mel_band_roformer/melbandroformer, \"\n            f\"or provide '{config_path}'.\"\n        ) from e\n    raise  # unrelated ValueError, do not swallow","preventionTips":["Never rename Roformer checkpoints: keep the architecture substring (e.g. 'bs_roformer', 'mel_band_roformer') that ships in the official filename.","When a model release includes a .yaml, download both files into tools/uvr5/uvr5w_weights with matching basenames.","Run validate_roformer_model() on user-supplied paths before constructing BSRoformer, and surface a clear message instead of the raw traceback.","In batch pipelines, pre-scan the weights directory and skip/quarantine files failing the naming check rather than aborting the whole run.","Pin where config_path comes from (explicit argument over derived default) so a moved weights directory cannot silently fall into the no-config branch."],"tags":["uvr5","audio-separation","model-loading","configuration","filename-convention"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}