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 structure_system hubserving module's predict method when the images/paths contract is broken. Exactly one non-empty list is accepted — `images` (list of numpy arrays) or `paths` (list of path strings) — and any other input combination raises this TypeError before inference.
Source
Thrown at deploy/hubserving/structure_system/module.py:114
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
starttime = time.time()
res, _ = self.table_sys(img)
elapse = time.time() - starttime
logger.info("Predict time: {}".format(elapse))
# parse result
res_final = []View on GitHub (pinned to 2661c7c0ef)
Solutions
- Ensure the request contains exactly one populated array field.
- Default the other field to an empty list in direct Python calls: predict(images=[...], paths=[]).
- Log the payload before sending to catch template-merge mistakes.
Example fix
# before
payload = {"images": imgs, "paths": paths} # both -> TypeError
# after
payload = {"images": imgs} if imgs else {"paths": paths} Defensive patterns
Strategy: validation
Validate before calling
def valid_struct_payload(data: dict) -> bool:
imgs, paths = data.get("images", []), data.get("paths", [])
return (imgs and not paths) or (paths and not imgs)
assert valid_struct_payload(payload), "send images XOR paths" Type guard
def payload_ok(images, paths) -> bool:
return bool(images) != bool(paths) Try / catch
try:
res = mod.predict(images=images, paths=paths)
except TypeError as e:
if "inconsistent" in str(e):
log.warning("bad payload: images=%r paths=%r", bool(images), bool(paths))
return [], 400
raise Prevention
- Log the payload keys (not contents) on every failed request for quick triage.
- Gateways should enforce exactly-one-of semantics per module docs.
- Keep e2e tests for both input modes (images and paths) to catch contract drift.
When it happens
Trigger: predict called with images and paths both non-empty, both empty, or either argument not a list.
Common situations: Document-analysis pipelines POSTing both keys for convenience; frontends that default missing fields to empty lists and accidentally send both; API gateways merging payload templates.
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/0cdea4cfd1e17a8b.
Report an issue: GitHub.