{"record":{"id":"44e4c2c75699dae1","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-44e4c2","errorCode":null,"errorMessage":"The input data is inconsistent with expectations.","messagePattern":"The input data is inconsistent with expectations\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"deploy/hubserving/ocr_cls/module.py","lineNumber":112,"sourceCode":"            images.append(img)\n        return images\n\n    def predict(self, images=[], paths=[]):\n        \"\"\"\n        Get the text angle in the predicted images.\n        Args:\n            images (list(numpy.ndarray)): images data, shape of each is [H, W, C]. If images not paths\n            paths (list[str]): The paths of images. If paths not images\n        Returns:\n            res (list): The result of text detection box and save path of images.\n        \"\"\"\n\n        if images != [] and isinstance(images, list) and paths == []:\n            predicted_data = images\n        elif images == [] and isinstance(paths, list) and paths != []:\n            predicted_data = self.read_images(paths)\n        else:\n            raise TypeError(\"The input data is inconsistent with expectations.\")\n\n        assert (\n            predicted_data != []\n        ), \"There is not any image to be predicted. Please check the input data.\"\n\n        img_list = []\n        for img in predicted_data:\n            if img is None:\n                continue\n            img_list.append(img)\n\n        rec_res_final = []\n        try:\n            img_list, cls_res, predict_time = self.text_classifier(img_list)\n            for dno in range(len(cls_res)):\n                angle, score = cls_res[dno]\n                rec_res_final.append(\n                    {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/ocr_cls/module.py#L94-L130","documentation":"Raised by the ocr_cls hubserving module's predict method when the input does not match the expected shape. The module takes either `images` (list of HxWxC numpy arrays) or `paths` (list of image file path strings) — exactly one non-empty list. Any other combination or type falls through to this TypeError.","triggerScenarios":"Calling predict with both `images` and `paths` non-empty, both empty, `paths` as a bare string instead of a list, or `images` as a single ndarray instead of a list of arrays.","commonSituations":"POSTing {\"paths\": \"single.jpg\"} (string, not array) to the served endpoint; sending both keys in one request; adapting a script from PaddleOCR's command-line tools where a single image object is passed directly.","solutions":["Send exactly one non-empty JSON array: {\"images\": [...]} or {\"paths\": [\"img1.jpg\", \"img2.jpg\"]}.","Wrap single items in a list (paths=[\"single.jpg\"], not paths=\"single.jpg\").","When calling the class in Python, use predict(images=[arr], paths=[]) or predict(images=[], paths=[...])."],"exampleFix":"# before\nres = mod.predict(images=[], paths=\"doc.png\")  # string, not list -> TypeError\n\n# after\nres = mod.predict(images=[], paths=[\"doc.png\"])","handlingStrategy":"validation","validationCode":"def valid_cls_payload(data: dict) -> bool:\n    images, paths = data.get(\"images\", []), data.get(\"paths\", [])\n    one = lambda v: isinstance(v, list) and len(v) > 0\n    return (one(images) and not one(paths)) or (one(paths) and not one(images))","typeGuard":"def is_images_arg(v) -> bool:\n    return isinstance(v, list) and len(v) > 0 and all(im is not None for im in v)\n\ndef is_paths_arg(v) -> bool:\n    return isinstance(v, list) and len(v) > 0 and all(isinstance(p, str) for p in v)","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        return {\"error\": \"invalid payload\", \"detail\": str(e)}, 400\n    raise","preventionTips":["Always wrap single inputs in a list before calling predict.","Never include both images and paths keys in one request.","Validate payloads in the HTTP handler before they reach the module."],"tags":["paddleocr","hubserving","input-validation","ocr-cls"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}