{"record":{"id":"42cbb342c248376c","repo":"opendatalab/MinerU","slug":"architecture-file-name-is-not-in-arch-config-yam","errorCode":null,"errorMessage":"architecture {file_name} is not in arch_config.yaml","messagePattern":"architecture (.+?) is not in arch_config\\.yaml","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/utils/tools/infer/pytorchocr_utility.py","lineNumber":230,"sourceCode":"    return s_len - math.ceil(en_dg_count / 2)\n\n\ndef base64_to_cv2(b64str):\n    import base64\n    data = base64.b64decode(b64str.encode('utf8'))\n    data = np.fromstring(data, np.uint8)\n    data = cv2.imdecode(data, cv2.IMREAD_COLOR)\n    return data\n\n\ndef get_arch_config(model_path):\n    import yaml\n    with open(DEFAULT_CFG_PATH, encoding='utf-8') as f:\n        all_arch_config = yaml.safe_load(f)\n    path = Path(model_path)\n    file_name = path.stem\n    if file_name not in all_arch_config:\n        raise ValueError(f\"architecture {file_name} is not in arch_config.yaml\")\n\n    arch_config = all_arch_config[file_name]\n    return arch_config\n","sourceCodeStart":212,"sourceCodeEnd":234,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/utils/tools/infer/pytorchocr_utility.py#L212-L234","documentation":"Raised by get_arch_config when the stem (filename without extension) of the model path is not a key in arch_config.yaml (loaded from DEFAULT_CFG_PATH). This mapping is how the inference utility knows which network architecture corresponds to a given weights file.","triggerScenarios":"Renaming a weights file (e.g. my_model.pth) so it no longer matches known names like ch_PP-OCRv4_rec_infer; using custom/foreign weights whose name is absent from the bundled arch_config.yaml; passing a path with an unexpected extension so path.stem differs.","commonSituations":"Users renaming downloaded models; side-loading third-party OCR weights; version mismatch between the weights bundle and the arch_config.yaml shipped with the installed mineru version.","solutions":["Restore the original weights filename so its stem matches a known architecture name.","Pass yaml_path explicitly to AnalysisConfig so arch inference from the filename is skipped.","Update mineru so the bundled arch_config.yaml matches your models version."],"exampleFix":"# before\nget_arch_config(\"/models/my_renamed_rec.pth\")\n\n# after\n# keep the official filename, or bypass filename inference:\nAnalysisConfig(weights_path=\"/models/my_renamed_rec.pth\", yaml_path=\"/models/rec_config.yml\")","handlingStrategy":"fallback","validationCode":"import yaml\nfrom pathlib import Path\nwith open(DEFAULT_CFG_PATH, encoding=\"utf-8\") as f:\n    known = yaml.safe_load(f)\nif Path(model_path).stem not in known:\n    # fall back to explicit config instead of filename inference\n    return AnalysisConfig(model_path, yaml_path=explicit_yaml)","typeGuard":null,"tryCatchPattern":"try:\n    arch = get_arch_config(model_path)\nexcept ValueError:\n    arch = read_network_config_from_yaml(explicit_yaml_path)","preventionTips":["Never rename downloaded weights files","Pass yaml_path explicitly when using custom or renamed weights","Keep the mineru version in sync with the models bundle"],"tags":["ocr","model-loading","config-mapping","valueerror"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}