opendatalab/MinerU · error · FileExistsError
{model_path} is not a file.
Error message
{model_path} is not a file. What it means
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.
Source
Thrown at mineru/model/table/rec/slanet_plus/table_structure_utils.py:109
return meta_dict[key].splitlines()
def have_key(self, key: str = "character") -> bool:
meta_dict = self.session.get_modelmeta().custom_metadata_map
if key in meta_dict.keys():
return True
return False
@staticmethod
def _verify_model(model_path: Union[str, Path, None]):
if model_path is None:
raise ValueError("model_path is None!")
model_path = Path(model_path)
if not model_path.exists():
raise FileNotFoundError(f"{model_path} does not exists.")
if not model_path.is_file():
raise FileExistsError(f"{model_path} is not a file.")
class ONNXRuntimeError(Exception):
pass
class TableLabelDecode:
def __init__(self, dict_character, merge_no_span_structure=True, **kwargs):
if merge_no_span_structure:
if "<td></td>" not in dict_character:
dict_character.append("<td></td>")
if "<td>" in dict_character:
dict_character.remove("<td>")
dict_character = self.add_special_char(dict_character)
self.dict = {}
for i, char in enumerate(dict_character):
self.dict[char] = iView on GitHub (pinned to 4fe4bde114)
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.
Example fix
# before model_path = '/models/table_structure' # directory # after model_path = '/models/table_structure/table_structure_slanetplus.onnx'
Defensive patterns
Strategy: validation
Validate before calling
p = Path(model_path)
if p.exists() and not p.is_file():
candidates = sorted(p.glob('*.onnx'))
model_path = candidates[0] if candidates else None Type guard
def is_model_file_not_dir(p) -> bool:
return Path(p).is_file() and not Path(p).is_dir() Try / catch
try:
eng = TableRecognition(model_path=p)
except FileExistsError as e:
if 'is not a file' in str(e):
p = next(Path(p).glob('*.onnx')) # resolve dir -> onnx file
eng = TableRecognition(model_path=p)
else:
raise Prevention
- Always compose model paths as dir / '<name>.onnx'.
- Document expected file layout for manually installed models.
- Add a startup assertion listing resolved model paths.
When it happens
Trigger: Passing model_path='/models/slanet_plus' (the extracted directory) instead of '/models/slanet_plus/model.onnx'; passing a broken symlink.
Common situations: Confusion between the model directory and the model file after manual download/extraction, or path-join bugs that omit the filename.
Related errors
- {model_path} does not exists.
- {file_path} does not exist.
- Found a {token.__class__} in the saved `added_tokens_decoder
- config._name_or_path is required by UnimernetModel.
- Input image ({w}, {h}) smaller than the target size ({cw}, {
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/6bf73196b7860af5.
Report an issue: GitHub.