invoke-ai/InvokeAI · error · ValueError
Directory contains more than {_MAX_FILES_IN_MODEL_DIR} files
Error message
Directory contains more than {_MAX_FILES_IN_MODEL_DIR} files. This looks like a general-purpose directory rather than a model. Please provide a path to a specific model file or model directory. What it means
To avoid misreading large application directories as models, _validate_path_looks_like_model counts non-hidden files; if the directory contains more than _MAX_FILES_IN_MODEL_DIR files it refuses with this ValueError. Model dirs (diffusers etc.) contain a handful of files, so a huge directory is treated as a general-purpose directory, not a model.
Source
Thrown at invokeai/backend/model_manager/configs/factory.py:601
recognized_root_config = _is_known_model_marker(config_name, config)
if recognized_root_config:
break
if recognized_root_config:
return
# For directories, do a quick file count check with early exit
total_files = 0
# Ignore hidden files and directories
paths_to_check = (
p
for p in path.rglob("*")
if not p.name.startswith(".") and not any(part.startswith(".") for part in p.parts)
)
for item in paths_to_check:
if item.is_file():
total_files += 1
if total_files > _MAX_FILES_IN_MODEL_DIR:
raise ValueError(
f"Directory contains more than {_MAX_FILES_IN_MODEL_DIR} files. "
"This looks like a general-purpose directory rather than a model. "
"Please provide a path to a specific model file or model directory."
)
# Otherwise, search for model files within depth limit
def find_model_files(current_path: Path, depth: int) -> bool:
if depth > _MAX_SEARCH_DEPTH:
return False
try:
for item in current_path.iterdir():
if item.is_file() and item.suffix.lower() in _MODEL_EXTENSIONS:
return True
elif item.is_dir() and find_model_files(item, depth + 1):
return True
except PermissionError:
pass
return FalseView on GitHub (pinned to 0b6a024f2f)
Solutions
- Pass the specific model file or its dedicated directory instead of the broad parent directory
- Move the model into its own folder and point there
- For huge multi-file models, reference the single top-level weights file directly
- Check for accidental inclusion of hidden-metadata-heavy trees; hidden files are ignored, visible clutter is not
Example fix
// before
install_model("/home/user/projects/myapp") # thousands of files
// after
install_model("/home/user/projects/myapp/models/sdxl-unet") # dedicated model dir Defensive patterns
Strategy: validation
Validate before calling
import pathlib
def looks_like_model_dir(path: str, max_files: int = 50) -> bool:
p = pathlib.Path(path)
visible = [f for f in p.rglob("*") if not f.name.startswith(".") and not any(part.startswith(".") for part in f.parts)]
return len(visible) <= max_files Try / catch
try:
install_model(path)
except ValueError as e:
if "more than" in str(e) and "files" in str(e):
logger.error("Pass the specific model file or a dedicated model directory")
else:
raise Prevention
- Never pass application/home directories to model install
- Give each model its own folder
- Reference the top-level weights file for very large models
- Sanitize user-supplied paths before invoking the installer
When it happens
Trigger: Invoking model probe/install with a path like a project folder, home directory, or site-packages that contains hundreds/thousands of non-hidden files; pointing at the repo root of an application instead of a specific model.
Common situations: Accidentally passing CWD, an uploads folder, or a dataset directory; installing a model from a monorepo root; a directory that legitimately has many shard files exceeding the cap.
Related errors
- No model files or config files found in directory {path}. Ex
- File extension {path.suffix} is not a recognized model forma
- The Anima ControlNet-LLLite model '{lllite_field.control_mod
- This Anima ControlNet-LLLite adapter is an inpainting adapte
- Unsupported Anima ControlNet-LLLite adapter: expected 3 or 4
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/2d2d0ec086ce050b.
Report an issue: GitHub.