immich-app/immich · error · ValueError

Unsupported model file type: {model_path.suffix}

Error message

Unsupported model file type: {model_path.suffix}

What it means

Raised by the default branch of the match/case in _make_session. Only the suffixes .armnn, .onnx and .rknn are mapped to a session class; any other suffix (including uppercase variants like .ONNX, or .tflite, .pt, .safetensors) is rejected. The suffix comes from model_path_for_format() which builds f"model.{model_format}", so it reflects the ModelFormat enum value.

Source

Thrown at machine-learning/immich_ml/models/base.py:119

                    f"for '{self.model_name}'. Removing file and replacing with a directory."
                ),
            )
            self.cache_dir.unlink()
        self.cache_dir.mkdir(parents=True, exist_ok=True)

    def _make_session(self, model_path: Path) -> ModelSession:
        if not model_path.is_file():
            raise FileNotFoundError(f"Model file not found: {model_path}")

        match model_path.suffix:
            case ".armnn":
                session: ModelSession = AnnSession(model_path)
            case ".onnx":
                session = OrtSession(model_path)
            case ".rknn":
                session = rknn.RknnSession(model_path)
            case _:
                raise ValueError(f"Unsupported model file type: {model_path.suffix}")
        return session

    def model_path_for_format(self, model_format: ModelFormat) -> Path:
        model_path_prefix = rknn.model_prefix if model_format == ModelFormat.RKNN else None
        if model_path_prefix:
            return self.model_dir / model_path_prefix / f"model.{model_format}"
        return self.model_dir / f"model.{model_format}"

    @property
    def model_dir(self) -> Path:
        return self.cache_dir / self.model_type.value

    @property
    def model_path(self) -> Path:
        return self.model_path_for_format(self.model_format)

    @property
    def model_task(self) -> ModelTask:

View on GitHub (pinned to 199723261c)

Solutions

  1. Check model_path.suffix in the error and confirm it is exactly '.armnn', '.onnx', or '.rknn' (lowercase).
  2. If you intended a new format, add a matching case in _make_session and a corresponding session class.
  3. Rename the cached file to the correct lowercase extension, or call clear_cache() and re-download.
  4. Verify the ModelFormat enum value used matches the suffix of the file snapshot_download actually produced.

Example fix

# before
class ModelFormat(str, Enum):
    ONNX = 'onnx'
    ARMNN = 'armnn'
    RKNN = 'rknn'
    TFLITE = 'tflite'   # new member, no case in _make_session -> ValueError

# after
match model_path.suffix:
    case '.armnn':
        session = AnnSession(model_path)
    case '.onnx':
        session = OrtSession(model_path)
    case '.rknn':
        session = rknn.RknnSession(model_path)
    case '.tflite':
        session = TfliteSession(model_path)
    case _:
        raise ValueError(f"Unsupported model file type: {model_path.suffix}")
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

SUPPORTED_SUFFIXES = {'.armnn', '.onnx', '.rknn'}

def validate_model_suffix(path: Path) -> None:
    if path.suffix not in SUPPORTED_SUFFIXES:
        raise ValueError(
            f"Model suffix {path.suffix!r} unsupported; expected one of {sorted(SUPPORTED_SUFFIXES)}"
        )

# call before constructing the session:
validate_model_suffix(model_path)

Type guard

from pathlib import Path

SUPPORTED_SUFFIXES = {'.armnn', '.onnx', '.rknn'}

def is_supported_model_suffix(path: Path) -> bool:
    return isinstance(path, Path) and path.suffix in SUPPORTED_SUFFIXES

Try / catch

try:
    session = model._make_session(model_path)
except ValueError as e:
    if 'Unsupported model file type' in str(e):
        raise ValueError(f"Refusing to load {model_path}: convert to .onnx/.armnn/.rknn first") from e
    raise

Prevention

When it happens

Trigger: Passing a model_format whose string value is not one of armnn/onnx/rknn (a custom/typo enum member), or pointing _make_session at a file whose extension is not in the handled set. Also hit if model_path_for_format is overridden or a path with an unexpected suffix is passed directly to _make_session.

Common situations: Extending ModelFormat with a new format (e.g. TFLITE, TORCH) without adding a matching case in _make_session; case-sensitivity issues where the file is named model.ONNX; corrupt or renamed model files in the cache; pointing the loader at a raw PyTorch checkpoint.

Related errors


AI-assisted analysis of immich-app/immich@199723261c (2026-08-12). Data as JSON: /api/errors/e9db1968a5b01a8c. Report an issue: GitHub.