deepfakes/faceswap · error · FaceswapError

{arch}' is not compatible with your version of Keras. The mi

Error message

{arch}' is not compatible with your version of Keras. The minimum version required is {keras_min} whilst you have version {keras_ver} installed.

What it means

FaceswapError raised by Phaze-A._validate_encoder_architecture() when the chosen encoder architecture exists but your installed Keras version is below its keras_min requirement. Each entry in _MODEL_MAPPING declares a minimum Keras version; newer architectures often need newer Keras APIs. The error reports both the required minimum and your installed version.

Source

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

        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".

        Returns
        -------
        :class:`keras.models.Model`
            The generated model
        """
        # Create sub-Models

View on GitHub (pinned to f530cb7508)

Solutions

  1. Upgrade Keras in the Faceswap environment to at least the version named in the message (pip install -U keras)
  2. Or switch enc_architecture to an older encoder whose keras_min fits your installed version
  3. Preferably let Faceswap's own requirements/installer manage the dependency set to avoid mismatches

Example fix

# before
pip show keras   # e.g. 2.15, arch requires 3.0

# after
pip install -U "keras>=3.0"
# or choose an older arch in phaze_a_config.json:
"enc_architecture": "efficientnet_b0"
Defensive patterns

Strategy: validation

Validate before calling

from lib.utils import get_keras_version  # faceswap helper
from plugins.train.model.phaze_a import _MODEL_MAPPING
arch = _MODEL_MAPPING[cfg.enc_architecture()]
if get_keras_version() < arch.keras_min:
    raise SystemExit(f"Keras {arch.keras_min}+ required for {cfg.enc_architecture()}")

Prevention

When it happens

Trigger: Selecting a modern encoder (e.g. a ViT or newer EfficientNet variant) while running an older Keras than its keras_min. get_keras_version() < model.keras_min at validation time.

Common situations: Pinned/downgraded Keras for another project, stale conda/venv environment, or Faceswap updated without refreshing its dependencies.

Related errors


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