{"record":{"id":"5c80755cbe042ede","repo":"invoke-ai/InvokeAI","slug":"no-model-files-or-config-files-found-in-directory","errorCode":null,"errorMessage":"No model files or config files found in directory {path}. Expected to find model files with extensions: {extensions} or config files: {config_files}","messagePattern":"No model files or config files found in directory (.+?)\\. Expected to find model files with extensions: (.+?) or config files: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/factory.py","lineNumber":622,"sourceCode":"                            \"Please provide a path to a specific model file or model directory.\"\n                        )\n\n            # Otherwise, search for model files within depth limit\n            def find_model_files(current_path: Path, depth: int) -> bool:\n                if depth > _MAX_SEARCH_DEPTH:\n                    return False\n                try:\n                    for item in current_path.iterdir():\n                        if item.is_file() and item.suffix.lower() in _MODEL_EXTENSIONS:\n                            return True\n                        elif item.is_dir() and find_model_files(item, depth + 1):\n                            return True\n                except PermissionError:\n                    pass\n                return False\n\n            if not find_model_files(path, 0):\n                raise ValueError(\n                    f\"No model files or config files found in directory {path}. \"\n                    f\"Expected to find model files with extensions: {', '.join(sorted(_MODEL_EXTENSIONS))} \"\n                    f\"or config files: {', '.join(sorted(_CONFIG_FILES))}\"\n                )\n\n    @staticmethod\n    def matches_sort_key(m: AnyModelConfig) -> int:\n        \"\"\"Sort key function to prioritize model config matches in case of multiple matches.\"\"\"\n\n        # It is possible that we have multiple matches. We need to prioritize them.\n\n        # Known cases where multiple matches can occur:\n        # - SD main models can look like a LoRA when they have merged in LoRA weights. Prefer the main model.\n        # - SD main models in diffusers format can look like a CLIP Embed; they have a text_encoder folder with\n        #   a config.json file. Prefer the main model.\n\n        # Given the above cases, we can prioritize the matches by type. If we find more cases, we may need a more\n        # sophisticated approach.","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/factory.py#L604-L640","documentation":"After extension and file-count checks pass, the validator searches the directory (within a depth limit) for any file with a recognized model extension or a known config file. Finding neither, it raises this ValueError: the directory exists and is small enough, but contains no recognizable model artifacts.","triggerScenarios":"from_model_on_disk given an empty directory, a directory holding only unrelated files (images, logs, docs), or a directory whose model weights use unrecognized extensions; also after a failed download that removed all weight files but left the folder.","commonSituations":"Cancelled/partial download leaving an empty model folder; extracting an archive into the wrong structure; pointing at a LoRA metadata folder with no weights; permissions masking files (PermissionError is swallowed in the search).","solutions":["Verify the directory actually contains weights files (ls the directory; check extensions like .safetensors/.bin/.ckpt or config files)","Re-run the download/extraction — the folder is likely an artifact of a failed install","Fix filesystem permissions if files exist but are unreadable (PermissionError is silently ignored during search)","Point at the correct subdirectory containing the model files"],"exampleFix":"// before\ninstall_model(\"/models/sdxl/venv_empty\")  # no weights inside\n// after\nassert any(f.suffix in {\".safetensors\", \".bin\", \".ckpt\"} for f in pathlib.Path(\"/models/sdxl\").rglob(\"*\"))\ninstall_model(\"/models/sdxl\")","handlingStrategy":"validation","validationCode":"import pathlib\n\n_MODEL_EXTS = {\".safetensors\", \".ckpt\", \".pt\", \".bin\", \".pth\", \".gguf\"}\n_CONFIGS = {\"config.json\", \"model_index.json\"}\n\ndef dir_has_model_artifacts(path: str) -> bool:\n    for f in pathlib.Path(path).rglob(\"*\"):\n        if f.suffix.lower() in _MODEL_EXTS or f.name in _CONFIGS:\n            return True\n    return False","typeGuard":null,"tryCatchPattern":"try:\n    install_model(path)\nexcept ValueError as e:\n    if \"No model files or config files found\" in str(e):\n        logger.error(\"Directory has no recognizable weights/config; re-download the model\")\n    else:\n        raise","preventionTips":["Confirm downloads completed (weights present) before importing","Check directory contents with ls before install","Fix read permissions if files exist but are unreadable","Point at the model subdirectory, not an empty parent"],"tags":["python","directory","model-probing","validation"],"backgroundTag":"invalid-model-path","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}