deezer/spleeter · error · ValueError

No model function {model_type} found

Error message

No model function {model_type} found

What it means

_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.

Source

Thrown at spleeter/model/__init__.py:179

        """
        Created a batch_sizexTxFxn_channels input tensor containing
        mix magnitude spectrogram, then an output dict from it
        according to the selected model in internal parameters.

        Raises:
            ValueError:
                If required model_type is not supported.
        """
        input_tensor = self.spectrogram_feature
        model = self._params.get("model", None)
        if model is not None:
            model_type = model.get("type", self.DEFAULT_MODEL)
        else:
            model_type = self.DEFAULT_MODEL
        try:
            apply_model = get_model_function(model_type)
        except ModuleNotFoundError:
            raise ValueError(f"No model function {model_type} found")
        self._model_outputs = apply_model(
            input_tensor, self._instruments, self._params["model"]["params"]
        )

    def _build_loss(self, labels: Dict) -> Tuple[tf.Tensor, Dict]:
        """
        Construct tensorflow loss and metrics

        Parameters:
            labels (Dict):
                Dictionary of target outputs (key: instrument name,
                value: ground truth spectrogram of the instrument)

        Returns:
            Tuple[tf.Tensor, Dict]:
                Tensorflow (loss, metrics) tuple.
        """
        output_dict = self.model_outputs

View on GitHub (pinned to c8854001ac)

Solutions

  1. Correct the model 'type' value in your configuration to a supported one (e.g. 'unet')
  2. Remove the 'type' key entirely to fall back to DEFAULT_MODEL
  3. If using a custom model, ensure the corresponding model function module is installed/importable in the environment
  4. Check for stray whitespace or case errors in the type string

Example fix

// before (config)
{"model": {"type": "unet2", ...}}
// after
{"model": {"type": "unet", ...}}
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_MODEL_TYPES = {'unet'}  # check spleeter.model.get_model_function for actual registry
model_type = config['model'].get('type', 'unet')
if model_type not in SUPPORTED_MODEL_TYPES:
    raise ValueError(f"Unsupported model type {model_type!r}; supported: {SUPPORTED_MODEL_TYPES}")

Type guard

def is_known_model_type(cfg: dict) -> bool:
    t = cfg.get('model', {}).get('type', 'unet')
    try:
        from spleeter.model import get_model_function
        get_model_function(t)
        return True
    except (ModuleNotFoundError, ValueError):
        return False

Try / catch

try:
    outputs = builder.model_outputs(input_tensor)
except ValueError as e:
    if 'No model function' in str(e):
        raise ConfigError(f"Bad model type in config: {e}") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of deezer/spleeter@c8854001ac (2026-08-28). Data as JSON: /api/errors/c13aed0d9a4ac74f. Report an issue: GitHub.