{"record":{"id":"c13aed0d9a4ac74f","repo":"deezer/spleeter","slug":"no-model-function-model-type-found","errorCode":null,"errorMessage":"No model function {model_type} found","messagePattern":"No model function (.+?) found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"spleeter/model/__init__.py","lineNumber":179,"sourceCode":"        \"\"\"\n        Created a batch_sizexTxFxn_channels input tensor containing\n        mix magnitude spectrogram, then an output dict from it\n        according to the selected model in internal parameters.\n\n        Raises:\n            ValueError:\n                If required model_type is not supported.\n        \"\"\"\n        input_tensor = self.spectrogram_feature\n        model = self._params.get(\"model\", None)\n        if model is not None:\n            model_type = model.get(\"type\", self.DEFAULT_MODEL)\n        else:\n            model_type = self.DEFAULT_MODEL\n        try:\n            apply_model = get_model_function(model_type)\n        except ModuleNotFoundError:\n            raise ValueError(f\"No model function {model_type} found\")\n        self._model_outputs = apply_model(\n            input_tensor, self._instruments, self._params[\"model\"][\"params\"]\n        )\n\n    def _build_loss(self, labels: Dict) -> Tuple[tf.Tensor, Dict]:\n        \"\"\"\n        Construct tensorflow loss and metrics\n\n        Parameters:\n            labels (Dict):\n                Dictionary of target outputs (key: instrument name,\n                value: ground truth spectrogram of the instrument)\n\n        Returns:\n            Tuple[tf.Tensor, Dict]:\n                Tensorflow (loss, metrics) tuple.\n        \"\"\"\n        output_dict = self.model_outputs","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/deezer/spleeter/blob/c8854001ac8acad34a9bc2bd15f28475541828b1/spleeter/model/__init__.py#L161-L197","documentation":"_build_model_outputs resolves a model builder function via get_model_function(model_type) based on the 'type' key in the model config (defaulting to unet). get_model_function raises ModuleNotFoundError when no such model module exists, which is converted to ValueError. This means the configured model type has no registered builder in this spleeter installation.","triggerScenarios":"A model configuration JSON/YAML whose model.type is misspelled or refers to a custom/removed model (e.g. type: 'unet2' or a typo like 'unet '), or calling model_outputs on a builder whose params come from an unsupported config.","commonSituations":"Using a config file written for a forked or newer spleeter version; typos in model type; custom model plugins not installed in the Python environment so their module cannot be imported.","solutions":["Correct the model 'type' value in your configuration to a supported one (e.g. 'unet')","Remove the 'type' key entirely to fall back to DEFAULT_MODEL","If using a custom model, ensure the corresponding model function module is installed/importable in the environment","Check for stray whitespace or case errors in the type string"],"exampleFix":"// before (config)\n{\"model\": {\"type\": \"unet2\", ...}}\n// after\n{\"model\": {\"type\": \"unet\", ...}}","handlingStrategy":"validation","validationCode":"SUPPORTED_MODEL_TYPES = {'unet'}  # check spleeter.model.get_model_function for actual registry\nmodel_type = config['model'].get('type', 'unet')\nif model_type not in SUPPORTED_MODEL_TYPES:\n    raise ValueError(f\"Unsupported model type {model_type!r}; supported: {SUPPORTED_MODEL_TYPES}\")","typeGuard":"def is_known_model_type(cfg: dict) -> bool:\n    t = cfg.get('model', {}).get('type', 'unet')\n    try:\n        from spleeter.model import get_model_function\n        get_model_function(t)\n        return True\n    except (ModuleNotFoundError, ValueError):\n        return False","tryCatchPattern":"try:\n    outputs = builder.model_outputs(input_tensor)\nexcept ValueError as e:\n    if 'No model function' in str(e):\n        raise ConfigError(f\"Bad model type in config: {e}\") from e\n    raise","preventionTips":["Keep model configs copied from official spleeter examples only","Strip whitespace and validate model.type at config load time","If using a fork with custom models, confirm the plugin module is installed in the active env","Pin spleeter version so config vocabulary matches the library version"],"tags":["python","valueerror","configuration","model-type","spleeter"],"backgroundTag":"unknown-model-type","analyzedSha":"c8854001ac8acad34a9bc2bd15f28475541828b1","analyzedAt":"2026-08-28T21:38:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}