opendatalab/MinerU · error · LoadImageError

{file_path} does not exist.

Error message

{file_path} does not exist.

What it means

verify_exist is called before opening str/Path inputs in LoadImage; a path that does not exist on disk raises LoadImageError('<path> does not exist.'). This is a pre-flight check so you get a clear message instead of a FileNotFoundError from PIL.

Source

Thrown at mineru/model/table/rec/unet_table/utils.py:167

    @staticmethod
    def cvt_two_to_three(img: np.ndarray) -> np.ndarray:
        """gray + alpha → BGR"""
        img_gray = img[..., 0]
        img_bgr = cv2.cvtColor(img_gray, cv2.COLOR_GRAY2BGR)

        img_alpha = img[..., 1]
        not_a = cv2.bitwise_not(img_alpha)
        not_a = cv2.cvtColor(not_a, cv2.COLOR_GRAY2BGR)

        new_img = cv2.bitwise_and(img_bgr, img_bgr, mask=img_alpha)
        new_img = cv2.add(new_img, not_a)
        return new_img

    @staticmethod
    def verify_exist(file_path: Union[str, Path]):
        if not Path(file_path).exists():
            raise LoadImageError(f"{file_path} does not exist.")


class LoadImageError(Exception):
    pass


# Pillow >=v9.1.0 use a slightly different naming scheme for filters.
# Set pillow_interp_codes according to the naming scheme used.
if Image is not None:
    if hasattr(Image, "Resampling"):
        pillow_interp_codes = {
            "nearest": Image.Resampling.NEAREST,
            "bilinear": Image.Resampling.BILINEAR,
            "bicubic": Image.Resampling.BICUBIC,
            "box": Image.Resampling.BOX,
            "lanczos": Image.Resampling.LANCZOS,
            "hamming": Image.Resampling.HAMMING,
        }

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Log/inspect the exact path string and fix the source of the path.
  2. Use absolute paths built from a single configured root.
  3. If the file should have been produced upstream, check that stage's output before this call.

Example fix

# before
img = load_image(f'{out_dir}/table_{i}.png')  # out_dir wrong

# after
p = Path(out_dir).resolve() / f'table_{i}.png'
assert p.exists(), f'missing crop, upstream stage failed: {p}'
img = load_image(p)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(path).resolve()
if not p.exists():
    raise FileNotFoundError(f'{p} missing; upstream stage may have failed')

Try / catch

try:
    img = load_image(p)
except LoadImageError as e:
    if 'does not exist' in str(e):
        return skip_page(p)  # or re-generate the file
    raise

Prevention

When it happens

Trigger: Passing a wrong/moved file path, a path built from a wrong models_root or output dir, or a relative path resolved against a different cwd.

Common situations: Running the pipeline from a different working directory, temp files already cleaned up, path templates with unfilled placeholders.

Related errors


AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14). Data as JSON: /api/errors/711d783add58a3f8. Report an issue: GitHub.