PaddlePaddle/PaddleOCR · error · InvalidRequestError

min_pixels cannot be greater than max_pixels.

Error message

min_pixels cannot be greater than max_pixels.

What it means

InvalidRequestError raised by _validate_vl_options when both min_pixels and max_pixels are set and min_pixels > max_pixels. The range would be empty, so the request is rejected client-side.

Source

Thrown at paddleocr/_api_client/models.py:202

def _validate_vl_options(options: PaddleOCRVLOptions) -> None:
    if options.top_p is not None and not (0 < options.top_p <= 1):
        raise InvalidRequestError(
            "top_p must be greater than 0 and less than or equal to 1."
        )
    if options.temperature is not None and options.temperature < 0:
        raise InvalidRequestError("temperature must be greater than or equal to 0.")
    if options.repetition_penalty is not None and options.repetition_penalty <= 0:
        raise InvalidRequestError("repetition_penalty must be greater than 0.")
    if options.min_pixels is not None and options.min_pixels <= 0:
        raise InvalidRequestError("min_pixels must be greater than 0.")
    if options.max_pixels is not None and options.max_pixels <= 0:
        raise InvalidRequestError("max_pixels must be greater than 0.")
    if (
        options.min_pixels is not None
        and options.max_pixels is not None
        and options.min_pixels > options.max_pixels
    ):
        raise InvalidRequestError("min_pixels cannot be greater than max_pixels.")

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Swap or adjust the values so min_pixels <= max_pixels
  2. Derive one from the other: max_pixels = max(min_pixels, max_pixels) before constructing options

Example fix

# before
options = PaddleOCRVLOptions(min_pixels=200704, max_pixels=100352)
# after
options = PaddleOCRVLOptions(min_pixels=100352, max_pixels=200704)
Defensive patterns

Strategy: validation

Validate before calling

if options.min_pixels is not None and options.max_pixels is not None:
    assert options.min_pixels <= options.max_pixels, 'empty pixel range'

Prevention

When it happens

Trigger: PaddleOCRVLOptions(min_pixels=1000000, max_pixels=500000); swapping the two arguments; independently tuning each until they cross.

Common situations: Config drift where min is raised above an old max; parameter order mix-ups because both are plain ints.

Related errors


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