deepfakes/faceswap · error · FaceswapError
'Learn Mask' has been selected but you have not chosen a Mas
Error message
'Learn Mask' has been selected but you have not chosen a Mask to use. Please select a mask or disable 'Learn Mask'.
What it means
FaceswapError raised in the training ModelBase constructor when the loss configuration enables 'Learn Mask' (cfg.Loss.learn_mask()) but the mask type is still 'none'. The mask loss helper needs an actual mask channel to learn, so the configuration is contradictory. It fails fast at model initialization, before any training begins.
Source
Thrown at plugins/train/model/_base/model.py:72
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,
self._is_predict)
logger.debug("Initialized ModelBase (%s)", self.__class__.__name__)
@property
def model(self) -> keras.Model:View on GitHub (pinned to f530cb7508)
Solutions
- Set a mask_type in the model's config (e.g. components, extended, dfl_full, dfl_x_hybrid) via the GUI config editor or by editing <model_dir>/<plugin>_config.json
- Or set loss.learn_mask = False in the same config file if you do not want the mask included in the loss
- Re-run training; the error is raised in __init__ so no restart cleanup is needed
Example fix
# before (in <model>_config.json)
"loss": {"learn_mask": true, "mask_type": "none", ...}
# after - option 1: pick a mask
"loss": {"learn_mask": true, "mask_type": "components", ...}
# after - option 2: disable learn mask
"loss": {"learn_mask": false, "mask_type": "none", ...} Defensive patterns
Strategy: validation
Validate before calling
from lib.config import Config as FSConfig # or however cfg is loaded
cfg.load_config(config_file=path)
if cfg.Loss.learn_mask() and cfg.Loss.mask_type() == "none":
raise SystemExit("Set loss.mask_type or disable loss.learn_mask before training") Try / catch
try:
model = MyModel(model_dir, args)
except FaceswapError as err:
if "Learn Mask" in str(err):
# fix config programmatically and retry once
patch_config(mask_type="components")
model = MyModel(model_dir, args)
else:
raise Prevention
- When toggling mask options in the GUI, always re-check that mask_type is set whenever learn_mask or penalized_mask_loss is enabled
- Keep per-experiment config files so mask settings never leak between runs
When it happens
Trigger: Initializing any train model plugin (e.g. Original, Dlight, Phaze-A) with a config file where loss.learn_mask = True and loss.mask_type = none. Also triggered when penalized_mask_loss validation passes but learn_mask was left enabled from a previous experiment while mask_type was reset.
Common situations: User copies an old config file, disables the mask in the GUI, or upgrades Faceswap where config defaults changed; the 'Learn Mask' toggle stays on from a prior training run that used a mask.
Related errors
- Penalized Mask Loss has been selected but you have not chose
- Landmark based masks cannot be created for {self._landmark_t
- No display detected. GUI mode has been disabled.
- Config file does not exist at: {ini_path}
- [{self._name}] List values should be set as a Str or List. G
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/e5fe8766cbbf45bb.
Report an issue: GitHub.