{"record":{"id":"a2a623b515118c3d","repo":"invoke-ai/InvokeAI","slug":"model-not-found-model-path","errorCode":null,"errorMessage":"Model not found: {model_path}","messagePattern":"Model not found: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"invokeai/backend/onnx/onnx_runtime.py","lineNumber":220,"sourceCode":"        file_name: Optional[str] = None,\n        provider: Optional[str] = None,\n        sess_options: Optional[\"SessionOptions\"] = None,\n        **kwargs: Any,\n    ) -> Any:  # fixme\n        file_name = file_name or ONNX_WEIGHTS_NAME\n\n        if os.path.isdir(model_id):\n            model_path = model_id\n            if subfolder is not None:\n                model_path = os.path.join(model_path, subfolder)\n            model_path = os.path.join(model_path, file_name)\n\n        else:\n            model_path = model_id\n\n        # load model from local directory\n        if not os.path.isfile(model_path):\n            raise Exception(f\"Model not found: {model_path}\")\n\n        # TODO: session options\n        return cls(str(model_path), provider=provider)\n","sourceCodeStart":202,"sourceCodeEnd":224,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/onnx/onnx_runtime.py#L202-L224","documentation":"OnnxRuntimeModel.from_pretrained() accepts a model_id that is either a Hub repo id (downloaded first) or a local path. If the resolved model_path is not an existing file (os.path.isfile fails), it raises this Exception — the ONNX model file itself is missing.","triggerScenarios":"Passing a directory that contains no ONNX model file, a path to a non-existent location, or a repo id whose download did not produce the expected .onnx file, so `not os.path.isfile(model_path)` triggers.","commonSituations":"Pointing model_id at the model folder instead of the .onnx file inside it; incomplete/cancelled downloads leaving empty dirs; renamed or moved model directories; expecting from_pretrained to fetch from the Hub while offline with no cached copy.","solutions":["Point model_id at the actual .onnx file (e.g. /path/to/model/model.onnx), not the containing directory.","Verify the file exists: ls the directory and confirm the ONNX artifact downloaded completely.","If using a Hub id, ensure network access/cache (HF_HOME) so the download succeeds before load.","Re-export or re-download the ONNX model if the artifact is missing."],"exampleFix":"// before\npipe = OnnxStableDiffusionPipeline.from_pretrained('/models/sdxl-onnx/')\n// after (point at the onnx file expected by the loader, or the repo root containing it)\npipe = OnnxStableDiffusionPipeline.from_pretrained('/models/sdxl-onnx', variant='fp16')","handlingStrategy":"validation","validationCode":"import os\nmodel_path = resolve(model_id)\nif not os.path.isfile(model_path):\n    raise FileNotFoundError(f'Provide the path to the .onnx file; {model_path} is missing')","typeGuard":"from pathlib import Path\ndef onnx_file_ready(p) -> bool:\n    path = Path(p)\n    return path.is_file() and path.suffix.lower() == '.onnx'","tryCatchPattern":"try:\n    model = OnnxRuntimeModel.from_pretrained(model_id, provider=provider)\nexcept Exception as e:\n    if str(e).startswith('Model not found:'):\n        missing = str(e).split(': ', 1)[1]\n        print(f'{missing} does not exist — check the path or re-download the ONNX model')\n    else:\n        raise","preventionTips":["Confirm the .onnx artifact exists on disk before from_pretrained.","Check download completeness (file size, no partial dirs) after fetching ONNX repos.","Use stable local model directories; avoid moving/renaming mid-pipeline."],"tags":["onnx","file-not-found","path"],"backgroundTag":"model-file-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}