PaddlePaddle/PaddleOCR · error · ValueError

Invalid engine: {engine}. Supported values are: {SUPPORTED_I

Error message

Invalid engine: {engine}. Supported values are: {SUPPORTED_INFERENCE_ENGINE_LIST}.

What it means

ValueError raised by parse_common_args when engine is not None and not one of SUPPORTED_INFERENCE_ENGINE_LIST: 'paddle', 'paddle_static', 'paddle_dynamic', 'transformers', 'onnxruntime'. This validates the inference backend selection before any model loads.

Source

Thrown at paddleocr/_common_args.py:62

        "use_tensorrt": DEFAULT_USE_TENSORRT,
        "precision": DEFAULT_PRECISION,
        "enable_mkldnn": DEFAULT_ENABLE_MKLDNN,
        "mkldnn_cache_capacity": DEFAULT_MKLDNN_CACHE_CAPACITY,
        "cpu_threads": DEFAULT_CPU_THREADS,
        "enable_cinn": DEFAULT_USE_CINN,
    }

    unknown_names = kwargs.keys() - default_vals.keys()
    for name in unknown_names:
        raise ValueError(f"Unknown argument: {name}")

    kwargs = {**default_vals, **kwargs}

    if (
        kwargs["engine"] is not None
        and kwargs["engine"] not in SUPPORTED_INFERENCE_ENGINE_LIST
    ):
        raise ValueError(
            f"Invalid engine: {kwargs['engine']}. Supported values are: {SUPPORTED_INFERENCE_ENGINE_LIST}."
        )

    if kwargs["precision"] not in SUPPORTED_PRECISION_LIST:
        raise ValueError(
            f"Invalid precision: {kwargs['precision']}. Supported values are: {SUPPORTED_PRECISION_LIST}."
        )

    kwargs["use_pptrt"] = kwargs.pop("use_tensorrt")
    kwargs["pptrt_precision"] = kwargs.pop("precision")

    return kwargs


def _build_paddle_static_engine_config(common_args, device_type):
    cfg = {}
    if device_type == "gpu":
        if common_args["use_pptrt"]:

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Use one of: paddle, paddle_static, paddle_dynamic, transformers, onnxruntime
  2. Import and assert against the constant: from paddleocr._common_args import SUPPORTED_INFERENCE_ENGINE_LIST
  3. Leave engine=None to use the default backend

Example fix

# before
ocr = PaddleOCR(engine='onnx')
# after
ocr = PaddleOCR(engine='onnxruntime')
Defensive patterns

Strategy: validation

Validate before calling

from paddleocr._common_args import SUPPORTED_INFERENCE_ENGINE_LIST

if engine is not None and engine not in SUPPORTED_INFERENCE_ENGINE_LIST:
    raise ValueError(f'pick engine from {SUPPORTED_INFERENCE_ENGINE_LIST}')

Type guard

from typing import Literal

Engine = Literal['paddle','paddle_static','paddle_dynamic','transformers','onnxruntime']

def is_engine(v: str) -> 'TypeGuard[Engine]':
    return v in ('paddle','paddle_static','paddle_dynamic','transformers','onnxruntime')

Prevention

When it happens

Trigger: PaddleOCR(engine='onnx') instead of 'onnxruntime'; engine='paddle_inference'; passing an engine string from a different library's vocabulary.

Common situations: Assuming short names work; version drift if the supported engine list changed; configuring engines without checking the constant.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/ab742d715e5e24d0. Report an issue: GitHub.