{"record":{"id":"37582a64ebf103fc","repo":"opendatalab/MinerU","slug":"is-not-found","errorCode":null,"errorMessage":"{} is not found.","messagePattern":"(.+?) is not found\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"critical","filePath":"mineru/model/utils/tools/infer/pytorchocr_utility.py","lineNumber":173,"sourceCode":"def read_network_config_from_yaml(yaml_path, char_num=None):\n    if not os.path.exists(yaml_path):\n        raise FileNotFoundError('{} is not existed.'.format(yaml_path))\n    import yaml\n    with open(yaml_path, encoding='utf-8') as f:\n        res = yaml.safe_load(f)\n    if res.get('Architecture') is None:\n        raise ValueError('{} has no Architecture'.format(yaml_path))\n    if res['Architecture']['Head']['name'] == 'MultiHead' and char_num is not None:\n        res['Architecture']['Head']['out_channels_list'] = {\n            'CTCLabelDecode': char_num,\n            'SARLabelDecode': char_num + 2,\n            'NRTRLabelDecode': char_num + 3\n        }\n    return res['Architecture']\n\ndef AnalysisConfig(weights_path, yaml_path=None, char_num=None):\n    if not os.path.exists(os.path.abspath(weights_path)):\n        raise FileNotFoundError('{} is not found.'.format(weights_path))\n\n    if yaml_path is not None:\n        return read_network_config_from_yaml(yaml_path, char_num=char_num)\n\n\ndef resize_img(img, input_size=600):\n    \"\"\"\n    resize img and limit the longest side of the image to input_size\n    \"\"\"\n    img = np.array(img)\n    im_shape = img.shape\n    im_size_max = np.max(im_shape[0:2])\n    im_scale = float(input_size) / float(im_size_max)\n    img = cv2.resize(img, None, None, fx=im_scale, fy=im_scale)\n    return img\n\n\ndef str_count(s):","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/utils/tools/infer/pytorchocr_utility.py#L155-L191","documentation":"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.","triggerScenarios":"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.","commonSituations":"Fresh environments where models were never downloaded; container images missing the models volume; scripts run from another directory making relative paths fail.","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."],"exampleFix":"# before\nAnalysisConfig(weights_path=\"models/ocr_rec.pth\")  # run from wrong cwd\n\n# after\nimport os\nAnalysisConfig(weights_path=os.path.abspath(\"models/ocr_rec.pth\"))","handlingStrategy":"validation","validationCode":"import os\nweights_path = os.path.abspath(weights_path)\nif not os.path.isfile(weights_path):\n    raise FileNotFoundError(f\"weights not found: {weights_path}\")","typeGuard":null,"tryCatchPattern":"try:\n    config = AnalysisConfig(weights_path, yaml_path)\nexcept FileNotFoundError as e:\n    raise SystemExit(f\"model files missing, run download step: {e}\") from e","preventionTips":["Make model download a prerequisite step in deployment scripts","Use one configured models root and absolute paths"],"tags":["ocr","weights","file-not-found","model-loading"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}