invoke-ai/InvokeAI · error · Exception
Error scanning model at {checkpoint} for malware. Aborting l
Error message
Error scanning model at {checkpoint} for malware. Aborting load. What it means
torch_load_file aborts loading when the picklescan tool itself errors while scanning the checkpoint (scan_result.scan_err true), e.g. the scanner cannot parse the pickle stream. If unsafe_disable_picklescan is false this becomes a hard Exception rather than a warning.
Source
Thrown at invokeai/app/services/model_load/model_load_default.py:135
def torch_load_file(checkpoint: Path) -> AnyModel:
scan_result = scan_file_path(checkpoint)
if scan_result.infected_files != 0:
if self._app_config.unsafe_disable_picklescan:
self._logger.warning(
f"Model at {checkpoint} is potentially infected by malware, but picklescan is disabled. "
"Proceeding with caution."
)
else:
raise Exception(f"The model at {checkpoint} is potentially infected by malware. Aborting load.")
if scan_result.scan_err:
if self._app_config.unsafe_disable_picklescan:
self._logger.warning(
f"Error scanning model at {checkpoint} for malware, but picklescan is disabled. "
"Proceeding with caution."
)
else:
raise Exception(f"Error scanning model at {checkpoint} for malware. Aborting load.")
result = torch_load(checkpoint, map_location="cpu")
return result
def diffusers_load_directory(directory: Path) -> AnyModel:
load_class = GenericDiffusersLoader(
app_config=self._app_config,
logger=self._logger,
ram_cache=ram_cache,
convert_cache=self.convert_cache,
).get_hf_load_class(directory)
return load_class.from_pretrained(model_path, torch_dtype=TorchDevice.choose_torch_dtype())
loader = loader or (
diffusers_load_directory
if model_path.is_dir()
else torch_load_file
if model_path.suffix.endswith((".ckpt", ".pt", ".pth", ".bin"))View on GitHub (pinned to 0b6a024f2f)
Solutions
- Re-download the model file and verify checksum/size.
- Open/convert the checkpoint in PyTorch directly (torch.load) in a sandbox, then re-save as safetensors.
- Update picklescan (pip install -U picklescan) and InvokeAI.
- As a last resort for trusted files, set unsafe_disable_picklescan=true.
Example fix
// before
# corrupt partial download triggers scan error
load({ path: 'partial_download.ckpt' });
// after
# verify integrity first, then load
// sha256sum model.ckpt # compare to published hash
load({ path: 'model.ckpt' }); Defensive patterns
Strategy: try-catch
Validate before calling
def is_loadable_checkpoint(path) -> bool:
if not path.is_file() or path.stat().st_size == 0:
return False
try:
from picklescan import scan_file_path
return scan_file_path(path).scan_err is False
except Exception:
return False Try / catch
try:
model = loader.load_model(path)
except Exception as e:
if 'Error scanning model' in str(e):
log.error('picklescan failed on %s; re-download or convert to safetensors', path)
raise
raise Prevention
- Verify file checksums after downloading
- Re-download truncated/corrupt files
- Convert trusted checkpoints to safetensors
- Keep picklescan and InvokeAI up to date
When it happens
Trigger: Passing a malformed, truncated, encrypted, or non-standard pickle/zip archive (corrupt .pt/.ckpt, partially downloaded file) to torch_load_file, or a file using pickle features picklescan cannot parse.
Common situations: Interrupted downloads yielding partial files; exotic checkpoint formats saved by non-PyTorch tools; picklescan version incompatibilities with new pickle opcodes; archived/zipped checkpoints with unusual structures.
Related errors
- The model at {checkpoint} is potentially infected by malware
- Error scanning the model at {path.stem} for malware. Abortin
- Video has no decodable frame
- Unable to decode image {image_path}: {e}
- Unable to validate video dimensions for {video_path}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/5aebeb80f5f0d24e.
Report an issue: GitHub.