{"record":{"id":"2c2c6cc988812379","repo":"opendatalab/MinerU","slug":"is-not-existed","errorCode":null,"errorMessage":"{} is not existed.","messagePattern":"(.+?) is not existed\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"critical","filePath":"mineru/model/utils/pytorchocr/base_ocr_v20.py","lineNumber":85,"sourceCode":"        except TypeError:\n            return torch.load(weights_path, map_location=\"cpu\")\n\n    @staticmethod\n    def _normalize_ppocrv6_state_dict(weights, weights_path):\n        \"\"\"归一化 HF OCR safetensors 的外层 `model.` 前缀。\"\"\"\n        if not BaseOCRV20._is_safetensors_path(weights_path):\n            return weights\n        if not any(key.startswith(\"model.\") for key in weights.keys()):\n            return weights\n        return {\n            key.removeprefix(\"model.\"): value\n            for key, value in weights.items()\n        }\n\n    def read_pytorch_weights(self, weights_path):\n        \"\"\"读取 PyTorch OCR 权重，并兼容 PP-OCRv6 safetensors。\"\"\"\n        if not os.path.exists(weights_path):\n            raise FileNotFoundError('{} is not existed.'.format(weights_path))\n        weights = self._load_weight_file(weights_path)\n        return self._normalize_ppocrv6_state_dict(weights, weights_path)\n\n    def get_out_channels(self, weights):\n        \"\"\"从权重结构推断识别输出通道数。\"\"\"\n        if \"head.head.weight\" in weights:\n            # PP-OCRv6 safetensors 的识别分类层固定命名为 head.head。\n            return weights[\"head.head.weight\"].shape[0]\n        if list(weights.keys())[-1].endswith('.weight') and len(list(weights.values())[-1].shape) == 2:\n            out_channels = list(weights.values())[-1].numpy().shape[1]\n        else:\n            out_channels = list(weights.values())[-1].numpy().shape[0]\n        return out_channels\n\n    def load_state_dict(self, weights):\n        self.net.load_state_dict(weights)\n        # print('weights is loaded.')\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/utils/pytorchocr/base_ocr_v20.py#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nocr = TextDetector(model_path=\"/models/ocr_det_v6.safetensors\")  # file absent\n\n# after\nimport os\nassert os.path.exists(model_path), f\"missing OCR weights: {model_path}\"\nocr = TextDetector(model_path=model_path)","handlingStrategy":"validation","validationCode":"import os\nif not os.path.isfile(weights_path):\n    raise FileNotFoundError(f\"OCR weights missing: {weights_path}; run model download first\")","typeGuard":null,"tryCatchPattern":"try:\n    ocr_model = BaseOCRV20(...)\nexcept FileNotFoundError as e:\n    logger.error(\"weights not found: %s\", e)\n    raise SystemExit(\"Run mineru model download before inference\") from e","preventionTips":["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"],"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"}