deepfakes/faceswap · error · FaceswapError
Penalized Mask Loss has been selected but you have not chose
Error message
Penalized Mask Loss has been selected but you have not chosen a Mask to use. Please select a mask or disable Penalized Mask Loss.
What it means
Constructor-time validation in the training ModelBase: the config has penalized_mask_loss enabled but mask_type is 'none'. Penalized mask loss applies a penalty outside a mask, so it is meaningless without one; Faceswap refuses to start training rather than silently training without the penalty.
Source
Thrown at plugins/train/model/_base/model.py:67
logger.debug(parse_class_init(locals()))
# Input shape must be set within the plugin after initializing
self.input_shape: tuple[int, ...] = ()
"""A `tuple` of `ints` defining the shape of the faces that the model takes as input. This
should be overridden by model plugins in their :func:`__init__` function. If the input size
is the same for both sides of the model, then this can be a single 3 dimensional `tuple`.
If the inputs have different sizes for `"A"` and `"B"` this should be a `list` of 2 3
dimensional shape `tuples`, 1 for each side respectively."""
self.color_order: T.Literal["bgr", "rgb"] = "bgr" # Override for image color channel order
self._args = arguments
self._is_predict = predict
self._model: keras.Model | None = None
cfg.load_config(config_file=arguments.config_file)
if cfg.Loss.penalized_mask_loss() and cfg.Loss.mask_type() == "none":
raise FaceswapError("Penalized Mask Loss has been selected but you have not chosen a "
"Mask to use. Please select a mask or disable Penalized Mask "
"Loss.")
if cfg.Loss.learn_mask() and cfg.Loss.mask_type() == "none":
raise FaceswapError("'Learn Mask' has been selected but you have not chosen a Mask to "
"use. Please select a mask or disable 'Learn Mask'.")
self._mixed_precision = cfg.mixed_precision()
self._io = IO(self, model_dir,
self._is_predict,
T.cast(T.Literal["never", "always", "exit"], cfg.Optimizer.save_optimizer()))
self._check_multiple_models()
self._state = State(model_dir,
self.name,
False if self._is_predict else self._args.no_logs)
self._settings = Settings(self._args,
self._mixed_precision,View on GitHub (pinned to f530cb7508)
Solutions
- Set Mask > mask_type in the training config to an actual mask that exists for your faces (see also error 40).
- Or disable Loss > penalized_mask_loss if you want to train without masks.
- Use the GUI config editor, which makes the incompatible combination visible when reviewing settings.
Example fix
# before (training config) mask_type = none penalized_mask_loss = True # after mask_type = vgg-clear penalized_mask_loss = True # or: penalized_mask_loss = False with mask_type = none
Defensive patterns
Strategy: validation
Validate before calling
from lib.config import cfg
cfg.load_config(config_file=arguments.config_file)
assert not (cfg.Loss.penalized_mask_loss() and cfg.Loss.mask_type() == "none"), \
"penalized_mask_loss requires a mask_type" Type guard
def mask_loss_config_valid(penalized: bool, mask_type: str) -> bool:
return not (penalized and mask_type == "none") Prevention
- Whenever you set mask_type to 'none', sweep the loss section for mask-dependent options (penalized_mask_loss, learn_mask) and disable them.
- Review the whole loss/mask block together in the GUI config editor instead of toggling single options.
When it happens
Trigger: Creating/initiating a training session where cfg.Loss.penalized_mask_loss() is True and cfg.Loss.mask_type() == 'none' in the model's training configuration.
Common situations: User disables the mask (to save VRAM or simplify) but forgets they earlier enabled penalized mask loss; hand-editing the loss section of the config; toggling settings independently in the GUI.
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
- 'Learn Mask' has been selected but you have not chosen a Mas
- Landmark based masks cannot be created for {self._landmark_t
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/7c55f77a76eb07a7.
Report an issue: GitHub.