PaddlePaddle/PaddleOCR · error · Exception
not found any img file in {}
Error message
not found any img file in {} What it means
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.
Source
Thrown at ppocr/utils/utility.py:80
def _check_image_file(path):
img_end = {"jpg", "bmp", "png", "jpeg", "rgb", "tif", "tiff", "gif", "pdf"}
return any([path.lower().endswith(e) for e in img_end])
def get_image_file_list(img_file, infer_list=None):
imgs_lists = []
if infer_list and not os.path.exists(infer_list):
raise Exception("not found infer list {}".format(infer_list))
if infer_list:
with open(infer_list, "r") as f:
lines = f.readlines()
for line in lines:
image_path = line.strip().split("\t")[0]
image_path = os.path.join(img_file, image_path)
imgs_lists.append(image_path)
else:
if img_file is None or not os.path.exists(img_file):
raise Exception("not found any img file in {}".format(img_file))
img_end = {"jpg", "bmp", "png", "jpeg", "rgb", "tif", "tiff", "gif", "pdf"}
if os.path.isfile(img_file) and _check_image_file(img_file):
imgs_lists.append(img_file)
elif os.path.isdir(img_file):
for single_file in os.listdir(img_file):
file_path = os.path.join(img_file, single_file)
if os.path.isfile(file_path) and _check_image_file(file_path):
imgs_lists.append(file_path)
if len(imgs_lists) == 0:
raise Exception("not found any img file in {}".format(img_file))
imgs_lists = sorted(imgs_lists)
return imgs_lists
def binarize_img(img):
if len(img.shape) == 3 and img.shape[2] == 3:View on GitHub (pinned to 2661c7c0ef)
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.
Example fix
# before
get_image_file_list(None)
get_image_file_list('datasets/imgs') # typo, does not exist
# after
get_image_file_list('/data/datasets/imgs') Defensive patterns
Strategy: validation
Validate before calling
import os
def valid_image_input(p) -> bool:
return p is not None and os.path.exists(p)
assert valid_image_input(img_file), f"image_dir does not exist or is None: {img_file!r}" Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- not found infer list {}
- fileUrl and filePath are mutually exclusive.
- File not found: ${path}
- Bad request: ${text}
- OCR pipeline config text must decode to an object.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/244d4eaef3bf6327.
Report an issue: GitHub.