{"record":{"id":"244d4eaef3bf6327","repo":"PaddlePaddle/PaddleOCR","slug":"not-found-any-img-file-in","errorCode":null,"errorMessage":"not found any img file in {}","messagePattern":"not found any img file in (.+?)","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ppocr/utils/utility.py","lineNumber":80,"sourceCode":"def _check_image_file(path):\n    img_end = {\"jpg\", \"bmp\", \"png\", \"jpeg\", \"rgb\", \"tif\", \"tiff\", \"gif\", \"pdf\"}\n    return any([path.lower().endswith(e) for e in img_end])\n\n\ndef get_image_file_list(img_file, infer_list=None):\n    imgs_lists = []\n    if infer_list and not os.path.exists(infer_list):\n        raise Exception(\"not found infer list {}\".format(infer_list))\n    if infer_list:\n        with open(infer_list, \"r\") as f:\n            lines = f.readlines()\n        for line in lines:\n            image_path = line.strip().split(\"\\t\")[0]\n            image_path = os.path.join(img_file, image_path)\n            imgs_lists.append(image_path)\n    else:\n        if img_file is None or not os.path.exists(img_file):\n            raise Exception(\"not found any img file in {}\".format(img_file))\n\n        img_end = {\"jpg\", \"bmp\", \"png\", \"jpeg\", \"rgb\", \"tif\", \"tiff\", \"gif\", \"pdf\"}\n        if os.path.isfile(img_file) and _check_image_file(img_file):\n            imgs_lists.append(img_file)\n        elif os.path.isdir(img_file):\n            for single_file in os.listdir(img_file):\n                file_path = os.path.join(img_file, single_file)\n                if os.path.isfile(file_path) and _check_image_file(file_path):\n                    imgs_lists.append(file_path)\n\n    if len(imgs_lists) == 0:\n        raise Exception(\"not found any img file in {}\".format(img_file))\n    imgs_lists = sorted(imgs_lists)\n    return imgs_lists\n\n\ndef binarize_img(img):\n    if len(img.shape) == 3 and img.shape[2] == 3:","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/utils/utility.py#L62-L98","documentation":"Exception from get_image_file_list when no infer_list is given and the img_file argument itself is None or does not exist. This is the input sanity check before any directory scanning happens — the path must be an existing file or directory for image collection to proceed.","triggerScenarios":"Calling predict/eval utilities with image_dir set to None, a typo'd path, a not-yet-mounted dataset directory, or a path from config that was never created.","commonSituations":"Config image_dir pointing to an unmounted NFS/docker volume; relative paths run from the wrong cwd; passing a config variable that was never populated (None) when chaining scripts.","solutions":["Check the path exists before running: ensure image_dir in the config or CLI arg is correct and mounted.","Use absolute paths for image_dir to avoid cwd-dependent failures.","If chaining scripts, assert the variable is not None before calling."],"exampleFix":"# before\nget_image_file_list(None)\nget_image_file_list('datasets/imgs')  # typo, does not exist\n\n# after\nget_image_file_list('/data/datasets/imgs')","handlingStrategy":"validation","validationCode":"import os\n\ndef valid_image_input(p) -> bool:\n    return p is not None and os.path.exists(p)\n\nassert valid_image_input(img_file), f\"image_dir does not exist or is None: {img_file!r}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve image_dir to an absolute path at startup (os.path.abspath).","Fail fast on None config values with a clear message in wrapper scripts."],"tags":["inference","dataset","validation","file-io"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}