{"record":{"id":"6bf73196b7860af5","repo":"opendatalab/MinerU","slug":"model-path-is-not-a-file","errorCode":null,"errorMessage":"{model_path} is not a file.","messagePattern":"(.+?) is not a file\\.","errorType":"exception","errorClass":"FileExistsError","httpStatus":null,"severity":"error","filePath":"mineru/model/table/rec/slanet_plus/table_structure_utils.py","lineNumber":109,"sourceCode":"        return meta_dict[key].splitlines()\n\n    def have_key(self, key: str = \"character\") -> bool:\n        meta_dict = self.session.get_modelmeta().custom_metadata_map\n        if key in meta_dict.keys():\n            return True\n        return False\n\n    @staticmethod\n    def _verify_model(model_path: Union[str, Path, None]):\n        if model_path is None:\n            raise ValueError(\"model_path is None!\")\n\n        model_path = Path(model_path)\n        if not model_path.exists():\n            raise FileNotFoundError(f\"{model_path} does not exists.\")\n\n        if not model_path.is_file():\n            raise FileExistsError(f\"{model_path} is not a file.\")\n\n\nclass ONNXRuntimeError(Exception):\n    pass\n\n\nclass TableLabelDecode:\n    def __init__(self, dict_character, merge_no_span_structure=True, **kwargs):\n        if merge_no_span_structure:\n            if \"<td></td>\" not in dict_character:\n                dict_character.append(\"<td></td>\")\n            if \"<td>\" in dict_character:\n                dict_character.remove(\"<td>\")\n\n        dict_character = self.add_special_char(dict_character)\n        self.dict = {}\n        for i, char in enumerate(dict_character):\n            self.dict[char] = i","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/table/rec/slanet_plus/table_structure_utils.py#L91-L127","documentation":"The companion check in _verify_model: the path exists but is not a regular file, so it raises FileExistsError('<path> is not a file.'). Typical causes: the path is a directory (user pointed at the model folder instead of the .onnx file), a symlink whose target is gone, or a device/socket path.","triggerScenarios":"Passing model_path='/models/slanet_plus' (the extracted directory) instead of '/models/slanet_plus/model.onnx'; passing a broken symlink.","commonSituations":"Confusion between the model directory and the model file after manual download/extraction, or path-join bugs that omit the filename.","solutions":["Point model_path at the .onnx file itself, not its containing directory.","If using a symlink, make sure its target exists.","Standardize on Path(model_dir) / '<model>.onnx' when composing paths."],"exampleFix":"# before\nmodel_path = '/models/table_structure'  # directory\n\n# after\nmodel_path = '/models/table_structure/table_structure_slanetplus.onnx'","handlingStrategy":"validation","validationCode":"p = Path(model_path)\nif p.exists() and not p.is_file():\n    candidates = sorted(p.glob('*.onnx'))\n    model_path = candidates[0] if candidates else None","typeGuard":"def is_model_file_not_dir(p) -> bool:\n    return Path(p).is_file() and not Path(p).is_dir()","tryCatchPattern":"try:\n    eng = TableRecognition(model_path=p)\nexcept FileExistsError as e:\n    if 'is not a file' in str(e):\n        p = next(Path(p).glob('*.onnx'))  # resolve dir -> onnx file\n        eng = TableRecognition(model_path=p)\n    else:\n        raise","preventionTips":["Always compose model paths as dir / '<name>.onnx'.","Document expected file layout for manually installed models.","Add a startup assertion listing resolved model paths."],"tags":["model-loading","onnx","file-path","table-recognition"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}