deepfakes/faceswap · error · FaceswapError

'{arch}' is not a valid choice for encoder architecture. Cho

Error message

'{arch}' is not a valid choice for encoder architecture. Choose one of {list(_MODEL_MAPPING.keys())}.

What it means

FaceswapError raised by Phaze-A._validate_encoder_architecture() when cfg.enc_architecture() is not a key in _MODEL_MAPPING. The mapping is the authoritative list of encoder architectures compiled into your Faceswap version; unknown names are rejected before the model is built. The error lists all valid keys.

Source

Thrown at plugins/train/model/phaze_a.py:330

                           "Adjusting input size from %spx to %spx",
                           arch, default_size, size, default_size)
            retval = (default_size, default_size, 3)
        else:
            retval = (size, size, 3)

        logger.debug("Encoder input set to: %s", retval)
        return retval

    def _validate_encoder_architecture(self) -> None:
        """ Validate that the requested architecture is a valid choice for the running system
        configuration.

        If the selection is not valid, an error is logged and system exits.
        """
        arch = cfg.enc_architecture()
        model = _MODEL_MAPPING.get(arch)
        if not model:
            raise FaceswapError(f"'{arch}' is not a valid choice for encoder architecture. Choose "
                                f"one of {list(_MODEL_MAPPING.keys())}.")

        keras_ver = get_keras_version()
        keras_min = model.keras_min
        if keras_ver < keras_min:
            raise FaceswapError(f"{arch}' is not compatible with your version of Keras. The "
                                f"minimum version required is {keras_min} whilst you have version "
                                f"{keras_ver} installed.")

    def build_model(self, inputs: list[KerasTensor]) -> keras.models.Model:
        """ Create the model's structure.

        Parameters
        ----------
        inputs: list[:class:`keras.KerasTensor`]
            A list of input tensors for the model. This will be a list of 2 tensors of
            shape :attr:`input_shape`, the first for side "a", the second for side "b".

View on GitHub (pinned to f530cb7508)

Solutions

  1. Read the valid keys from the error message (list(_MODEL_MAPPING.keys())) and pick one
  2. Fix typos/spelling of enc_architecture in phaze_a config to exactly match a listed key
  3. Update Faceswap if the architecture you want exists in a newer release

Example fix

# before (phaze_a_config.json)
"enc_architecture": "effnet_v2_l"

# after
"enc_architecture": "efficientnet_v2_l"
Defensive patterns

Strategy: validation

Validate before calling

from plugins.train.model.phaze_a import _MODEL_MAPPING
arch = "efficientnet_v2_l"  # from your config
if arch not in _MODEL_MAPPING:
    raise SystemExit(f"Unknown enc_architecture {arch!r}; valid: {sorted(_MODEL_MAPPING)}")

Type guard

def is_valid_phaze_architecture(arch: str) -> bool:
    """True if arch exists in this Faceswap build's Phaze-A mapping."""
    from plugins.train.model.phaze_a import _MODEL_MAPPING
    return arch in _MODEL_MAPPING

Prevention

When it happens

Trigger: Training Phaze-A with enc_architecture misspelled or from a different Faceswap version (e.g. 'effnet_v2_l' vs 'efficientnet_v2_l', or an arch removed/added in another release). _MODEL_MAPPING.get(arch) returns None.

Common situations: Hand-editing the config file, following an outdated tutorial, or moving a config between Faceswap versions whose architecture lists differ.

Related errors


AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15). Data as JSON: /api/errors/65980c8d6b6c7080. Report an issue: GitHub.