opendatalab/MinerU · critical · FileNotFoundError
{} is not existed.
Error message
{} is not existed. What it means
Raised by BaseOCRV20.read_pytorch_weights when the OCR weights file path does not exist on disk, before any safetensors/torch load is attempted. The message ('{} is not existed.') is inherited from PaddleOCR-style code.
Source
Thrown at mineru/model/utils/pytorchocr/base_ocr_v20.py:85
except TypeError:
return torch.load(weights_path, map_location="cpu")
@staticmethod
def _normalize_ppocrv6_state_dict(weights, weights_path):
"""归一化 HF OCR safetensors 的外层 `model.` 前缀。"""
if not BaseOCRV20._is_safetensors_path(weights_path):
return weights
if not any(key.startswith("model.") for key in weights.keys()):
return weights
return {
key.removeprefix("model."): value
for key, value in weights.items()
}
def read_pytorch_weights(self, weights_path):
"""读取 PyTorch OCR 权重,并兼容 PP-OCRv6 safetensors。"""
if not os.path.exists(weights_path):
raise FileNotFoundError('{} is not existed.'.format(weights_path))
weights = self._load_weight_file(weights_path)
return self._normalize_ppocrv6_state_dict(weights, weights_path)
def get_out_channels(self, weights):
"""从权重结构推断识别输出通道数。"""
if "head.head.weight" in weights:
# PP-OCRv6 safetensors 的识别分类层固定命名为 head.head。
return weights["head.head.weight"].shape[0]
if list(weights.keys())[-1].endswith('.weight') and len(list(weights.values())[-1].shape) == 2:
out_channels = list(weights.values())[-1].numpy().shape[1]
else:
out_channels = list(weights.values())[-1].numpy().shape[0]
return out_channels
def load_state_dict(self, weights):
self.net.load_state_dict(weights)
# print('weights is loaded.')
View on GitHub (pinned to 4fe4bde114)
Solutions
- Verify the path exists: ls -l <weights_path>; fix typos or absolute-vs-relative mistakes.
- Run mineru's model download command (e.g. `mineru-models-download` or pipeline auto-download) so OCR weights are fetched to the models root.
- If offline, download weights on a connected machine and copy them to the exact expected path.
- Check the models_path configuration/env used to construct weights_path.
Example fix
# before
ocr = TextDetector(model_path="/models/ocr_det_v6.safetensors") # file absent
# after
import os
assert os.path.exists(model_path), f"missing OCR weights: {model_path}"
ocr = TextDetector(model_path=model_path) Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.path.isfile(weights_path):
raise FileNotFoundError(f"OCR weights missing: {weights_path}; run model download first") Try / catch
try:
ocr_model = BaseOCRV20(...)
except FileNotFoundError as e:
logger.error("weights not found: %s", e)
raise SystemExit("Run mineru model download before inference") from e Prevention
- Run model download as a provisioning step before serving
- Use absolute model paths from a single configured models root
- Fail fast on missing weights in health checks
When it happens
Trigger: Initializing the OCR model with a weights_path pointing to a missing .pth/.safetensors file; path built by joining a model root with a wrong filename; models directory never downloaded.
Common situations: Model auto-download skipped or failed (offline environment, blocked download endpoint); manually specified model dir with typo; running in a container where the models volume is not mounted at the expected path.
Related errors
- {} is not found.
- {} is not existed.
- architecture {file_name} is not in arch_config.yaml
- Language {lang} not supported. Allowed values: {allowed_valu
- Missing middle json file: {middle_json_path}
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/2c2c6cc988812379.
Report an issue: GitHub.