opendatalab/MinerU · critical · FileNotFoundError
{} is not found.
Error message
{} is not found. What it means
Raised by AnalysisConfig when the OCR weights path (made absolute first) does not exist. It is the top-level guard before either reading the YAML config or inferring the architecture from the weights filename.
Source
Thrown at mineru/model/utils/tools/infer/pytorchocr_utility.py:173
def read_network_config_from_yaml(yaml_path, char_num=None):
if not os.path.exists(yaml_path):
raise FileNotFoundError('{} is not existed.'.format(yaml_path))
import yaml
with open(yaml_path, encoding='utf-8') as f:
res = yaml.safe_load(f)
if res.get('Architecture') is None:
raise ValueError('{} has no Architecture'.format(yaml_path))
if res['Architecture']['Head']['name'] == 'MultiHead' and char_num is not None:
res['Architecture']['Head']['out_channels_list'] = {
'CTCLabelDecode': char_num,
'SARLabelDecode': char_num + 2,
'NRTRLabelDecode': char_num + 3
}
return res['Architecture']
def AnalysisConfig(weights_path, yaml_path=None, char_num=None):
if not os.path.exists(os.path.abspath(weights_path)):
raise FileNotFoundError('{} is not found.'.format(weights_path))
if yaml_path is not None:
return read_network_config_from_yaml(yaml_path, char_num=char_num)
def resize_img(img, input_size=600):
"""
resize img and limit the longest side of the image to input_size
"""
img = np.array(img)
im_shape = img.shape
im_size_max = np.max(im_shape[0:2])
im_scale = float(input_size) / float(im_size_max)
img = cv2.resize(img, None, None, fx=im_scale, fy=im_scale)
return img
def str_count(s):View on GitHub (pinned to 4fe4bde114)
Solutions
- Verify with ls; correct the path or make it absolute.
- Download the models first using mineru's model download commands.
- Check MINERU_MODEL_SOURCE/model-dir env vars that determine where weights are looked up.
Example fix
# before
AnalysisConfig(weights_path="models/ocr_rec.pth") # run from wrong cwd
# after
import os
AnalysisConfig(weights_path=os.path.abspath("models/ocr_rec.pth")) Defensive patterns
Strategy: validation
Validate before calling
import os
weights_path = os.path.abspath(weights_path)
if not os.path.isfile(weights_path):
raise FileNotFoundError(f"weights not found: {weights_path}") Try / catch
try:
config = AnalysisConfig(weights_path, yaml_path)
except FileNotFoundError as e:
raise SystemExit(f"model files missing, run download step: {e}") from e Prevention
- Make model download a prerequisite step in deployment scripts
- Use one configured models root and absolute paths
When it happens
Trigger: Running the pytorchocr inference utility with a --weights path (or derived model path) that is wrong: typo, not-yet-downloaded model, relative path resolved against an unexpected cwd.
Common situations: Fresh environments where models were never downloaded; container images missing the models volume; scripts run from another directory making relative paths fail.
Related errors
- {} is not existed.
- {} 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/37582a64ebf103fc.
Report an issue: GitHub.