PaddlePaddle/PaddleOCR · error · TypeError
The input data is inconsistent with expectations.
Error message
The input data is inconsistent with expectations.
What it means
Raised by the kie_ser_re hubserving module's predict method when the request payload does not match the expected shape. The module accepts input either as raw image arrays (`images`) or as file paths (`paths`) — exactly one of the two, and it must be a non-empty Python list. Any other combination (both set, both empty, wrong types) falls through to this TypeError.
Source
Thrown at deploy/hubserving/kie_ser_re/module.py:115
continue
images.append(img)
return images
def predict(self, images=[], paths=[]):
"""
Get the chinese texts in the predicted images.
Args:
images (list(numpy.ndarray)): images data, shape of each is [H, W, C]. If images not paths
paths (list[str]): The paths of images. If paths not images
Returns:
res (list): The result of chinese texts and save path of images.
"""
if images != [] and isinstance(images, list) and paths == []:
predicted_data = images
elif images == [] and isinstance(paths, list) and paths != []:
predicted_data = self.read_images(paths)
else:
raise TypeError("The input data is inconsistent with expectations.")
assert (
predicted_data != []
), "There is not any image to be predicted. Please check the input data."
all_results = []
for img in predicted_data:
if img is None:
logger.info("error in loading image")
all_results.append([])
continue
print(img.shape)
starttime = time.time()
re_res, _ = self.ser_re_predictor(img)
print(re_res)
elapse = time.time() - starttime
logger.info("Predict time: {}".format(elapse))
all_results.append(re_res)View on GitHub (pinned to 2661c7c0ef)
Solutions
- Send exactly one field: either {"images": [<numpy arrays>} or {"paths": ["a.jpg"]}, never both, never neither.
- Ensure the chosen field is a Python list (JSON array) with at least one element.
- If calling the class directly, call predict(images=[img], paths=[]) or predict(images=[], paths=[...]).
Example fix
# before res = module.predict(images=[img], paths=["a.jpg"]) # both set -> TypeError # after res = module.predict(images=[img], paths=[]) # or res = module.predict(images=[], paths=["a.jpg"])
Defensive patterns
Strategy: validation
Validate before calling
def valid_kie_payload(images, paths) -> bool:
return (
isinstance(images, list) and images and not paths
) or (
isinstance(paths, list) and paths and not images
)
assert valid_kie_payload(images, paths), "send exactly one non-empty list: images XOR paths" Type guard
from typing import Any, List
def is_valid_images_list(v: Any) -> bool:
return isinstance(v, list) and len(v) > 0 and all(
hasattr(im, "shape") for im in v
)
def is_valid_paths_list(v: Any) -> bool:
return isinstance(v, list) and len(v) > 0 and all(
isinstance(p, str) for p in v
) Try / catch
try:
res = module.predict(images=images, paths=paths)
except TypeError as e:
if "inconsistent with expectations" in str(e):
raise ValueError("payload must be exactly one non-empty list: images XOR paths") from e
raise Prevention
- Build request payloads with a helper that sets exactly one of images/paths.
- Keep client-side schemas in sync with the hubserving module contract.
- Add an integration test that posts a minimal valid payload after every client change.
When it happens
Trigger: Calling predict with both `images` and `paths` non-empty, with both empty, with `images`/`paths` as a non-list (e.g. a single numpy array or string instead of a list), or passing keyword arguments the if/elif chain does not accept.
Common situations: POSTing a hubserving JSON body like {"images": [...], "paths": [...]} (both keys), sending a bare string path instead of a one-element list, or reusing a client written for a different PaddleOCR serving module that has a different payload contract.
Related errors
- The input data is inconsistent with expectations.
- The input data is inconsistent with expectations.
- The input data is inconsistent with expectations.
- The input data is inconsistent with expectations.
- The input data is inconsistent with expectations.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/9177d83066827117.
Report an issue: GitHub.