PaddlePaddle/PaddleOCR · error · Exception

{} does not exist!

Error message

{} does not exist!

What it means

The main detection/recognition SimpleDataset parses each label line, treats the first field as either an http(s) URL (used as-is) or a path joined with data_dir, and raises Exception('{path} does not exist!') when the file cannot be found (local path) before reading image bytes. The outer except logs the line and skips it (outs = None).

Source

Thrown at ppocr/data/simple_dataset.py:417

            file_idx = self._index_map[idx]
            data_line = self._all_lines[file_idx]
        else:
            file_idx = self.data_idx_order_list[idx]
            data_line = self.data_lines[file_idx]
        try:
            data_line = data_line.decode("utf-8")
            substr = data_line.strip("\n").split(self.delimiter)
            file_name = substr[0]
            file_name = self._try_parse_filename_list(file_name)
            label = substr[1]
            img_path = (
                file_name
                if file_name.startswith("http://") or file_name.startswith("https://")
                else os.path.join(self.data_dir, file_name)
            )
            data = {"img_path": img_path, "label": label}
            if not _img_path_exists(img_path):
                raise Exception("{} does not exist!".format(img_path))
            data["image"] = _load_image_bytes(img_path)
            data["ext_data"] = self.get_ext_data()
            data["filename"] = data["img_path"]
            data["epoch"] = self._shared_epoch.value
            outs = transform(data, self.ops)
        except:
            self.logger.error(
                "When parsing line {}, error happened with msg: {}".format(
                    data_line, traceback.format_exc()
                )
            )
            outs = None
        if outs is None:
            # during evaluation, we should fix the idx to get same results for many times of evaluation.
            rnd_idx = (
                np.random.randint(self.__len__())
                if self.mode == "train"
                else (idx + 1) % self.__len__()

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Run the one-liner check for the first label line: python -c 'import os; p=open(label).readline().strip().split("\t")[0]; print(os.path.exists(os.path.join(data_dir, p)))'
  2. Fix data_dir / label_file_list in the yml so the join resolves
  3. Download the dataset images (e.g. icdar2015, lsvt) per docs and keep the documented directory layout
  4. Clean label files: strip \r (dos2unix), normalize backslashes, and drop lines for removed images to avoid skipped-sample logs

Example fix

# before (config)
data_dir: ./train_data
label_file_list: ./train_data/ic15.txt
# after
data_dir: ./train_data/icdar2015/text_localization
label_file_list: ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
Defensive patterns

Strategy: validation

Validate before calling

import os
missing = []
for path in label_file_list:
    for line in open(path, encoding='utf-8'):
        name = line.strip('\r\n').split(delimiter)[0]
        p = name if name.startswith(('http://', 'https://')) else os.path.join(data_dir, name)
        if not p.startswith('http') and not os.path.exists(p):
            missing.append(p)
assert not missing, f'{len(missing)} missing images, first: {missing[:3]}'

Try / catch

try:
    out = dataset[idx]
except Exception:
    out = None  # upstream logs 'does not exist' and skips; track skip counts in logs

Prevention

When it happens

Trigger: Any label line whose image path does not exist on disk: wrong data_dir, images not yet downloaded, a relative path that assumes another working directory, or an http URL that only fails if the URL check is bypassed (note _img_path_exists also probes remote URLs).

Common situations: First run after cloning configs without downloading train_data; mixing label files written on Windows (backslashes); trailing whitespace or \r from CRLF label files; symlinked dataset roots not present in containers; a few genuinely deleted images in a big dataset (these get skipped with log noise).

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/ef43fc5ceb39428e. Report an issue: GitHub.