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_table hubserving module's predict method when the input does not satisfy its contract: exactly one non-empty list of either `images` (numpy arrays) or `paths` (file path strings). All other inputs fall to the else branch and raise TypeError.
Source
Thrown at deploy/hubserving/structure_table/module.py:113
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))
all_results.append({"html": res["html"]})
return all_resultsView on GitHub (pinned to 2661c7c0ef)
Solutions
- Send exactly one non-empty array field: {"images": [...]} or {"paths": [...]}.
- Wrap single inputs in a one-element list.
- Validate the payload shape client-side before POSTing.
Example fix
# before res = mod.predict(images=[], paths="invoice.png") # string -> TypeError # after res = mod.predict(images=[], paths=["invoice.png"])
Defensive patterns
Strategy: validation
Validate before calling
def valid_table_payload(data: dict) -> bool:
imgs, paths = data.get("images", []), data.get("paths", [])
return (isinstance(imgs, list) and imgs and not paths) or (
isinstance(paths, list) and paths and not imgs
) Type guard
def is_nonempty_list(v) -> bool:
return isinstance(v, list) and len(v) > 0 Try / catch
try:
res = mod.predict(images=images, paths=paths)
except TypeError as e:
if "inconsistent" in str(e):
raise ValueError("exactly one non-empty list required: images or paths") from e
raise Prevention
- Wrap single paths in lists at the client boundary.
- Reject empty batches before they reach the module.
- Share payload validation helpers across all table/structure clients.
When it happens
Trigger: predict called with both fields populated, both empty, or a non-list value (bare string, single ndarray) for either argument.
Common situations: Table-recognition clients sending {"paths": "table.png"}; batch jobs that pass images plus their paths together; empty payloads from upstream document splitters.
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/1aab68320125614e.
Report an issue: GitHub.