deepfakes/faceswap · error · FaceswapError
Load weights selected, but the path '{weights_file}' does no
Error message
Load weights selected, but the path '{weights_file}' does not exist. Please check and try again. What it means
Raised while validating the 'load weights' input in the training model IO: the user selected a weights file, but its path does not exist (the subsequent branch rejects paths that are not .keras files). It is a pre-flight check that runs before any weights are actually read.
Source
Thrown at plugins/train/model/_base/io.py:424
Returns
-------
The full path to a weights file
"""
if not weights_file:
logger.debug("[Weights] No weights file selected.")
return None
msg = ""
if not os.path.exists(weights_file):
msg = f"Load weights selected, but the path '{weights_file}' does not exist."
elif not os.path.splitext(weights_file)[-1].lower() == ".keras":
msg = (f"Load weights selected, but the path '{weights_file}' is not a valid Keras "
f"model (.keras) file.")
if msg:
msg += " Please check and try again."
raise FaceswapError(msg)
logger.verbose("Using weights file: %s", weights_file) # type:ignore
return weights_file
def freeze(self) -> None:
"""If freeze has been selected in the cli arguments, then freeze those models indicated
in the plugin's configuration. """
# Blanket unfreeze layers, as checking the value of :attr:`layer.trainable` appears to
# return ``True`` even when the weights have been frozen
for layer in get_all_sub_models(self._model):
layer.trainable = True
if not self._do_freeze:
logger.debug("[Weights] Freeze weights deselected. Not freezing")
return
for layer in get_all_sub_models(self._model):
if layer.name in self._freeze_layers:View on GitHub (pinned to f530cb7508)
Solutions
- Correct the path so it points at the existing .keras weights file (use an absolute path).
- Confirm the extension is '.keras' — a valid file with the wrong extension fails the next check in the same function.
- If you no longer want to warm-start, clear the load-weights setting.
Example fix
# before faceswap train ... -wm weights/model.h5 # after faceswap train ... -wm /home/user/weights/model.keras
Defensive patterns
Strategy: validation
Validate before calling
import os
assert not weights_path or (os.path.exists(weights_path)
and os.path.splitext(weights_path)[-1].lower() == ".keras"), \
"weights path must exist and end in .keras" Type guard
def is_valid_weights_file(path: str | None) -> bool:
return path is None or (os.path.isfile(path) and path.lower().endswith(".keras")) Prevention
- Use absolute paths for the -wm/--load-weights argument.
- Keep weights files alongside the model dir and reference them consistently in launch scripts.
When it happens
Trigger: Launching training with the load-weights option pointing at a non-existent path — typo, file moved/deleted, or relative path resolved from the wrong working directory.
Common situations: Passing --load-weights / -wm paths by hand after moving files; scripts running with a different cwd; placeholder paths left in launch commands.
Related errors
- You have selected the mask type '{mask_type}' but at least o
- '{method}' is not a valid clipping method. Select from {list
- '{name}' is not a valid optimizer. Select from {list(_OPTIMI
- No weights were successfully loaded from your weights file:
- Penalized Mask Loss has been selected but you have not chose
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/13f917ee381889b8.
Report an issue: GitHub.