deepfakes/faceswap · error · FaceswapError

No weights were successfully loaded from your weights file:

Error message

No weights were successfully loaded from your weights file: '{self._weights_file}'. Please check and try again.

What it means

Raised after the weight-transfer pass when loaded_ops == 0: the .keras weights file opened successfully, but not a single layer of the current model matched/successfully received weights from it. Faceswap treats total transfer failure as an error (partial mismatches only produce a warning with skipped_ops).

Source

Thrown at plugins/train/model/_base/io.py:494

                msg = f"Skipping layer {model_name} as not in "
                msg += "current_model." if not sub_model else f"weights '{self._weights_file}.'"
                logger.warning(msg)
                continue

            logger.info("Loading weights for layer '%s'", model_name)
            skipped_ops = 0
            loaded_ops = 0
            for layer in sub_model.layers:
                success = self._load_layer_weights(layer, sub_weights, model_name)
                if success == 0:
                    skipped_ops += 1
                elif success == 1:
                    loaded_ops += 1

        del weights_models

        if loaded_ops == 0:
            raise FaceswapError(f"No weights were successfully loaded from your weights file: "
                                f"'{self._weights_file}'. Please check and try again.")
        if skipped_ops > 0:
            logger.warning("%s weight(s) were unable to be loaded for your model. This is most "
                           "likely because the weights you are trying to load were trained with "
                           "different settings than you have set for your current model.",
                           skipped_ops)

    def _get_weights_model(self) -> list[k_models.Model]:
        """Obtain a list of all sub-models contained within the weights model.

        Returns
        -------
        List of all models contained within the .keras file

        Raises
        ------
        FaceswapError
            In the event of a failure to load the weights, or the weights belonging to a different

View on GitHub (pinned to f530cb7508)

Solutions

  1. Confirm the weights file was saved from the same model plugin and settings you are training now.
  2. If you changed input size or other architecture-affecting settings, revert them to match the weights, or drop the weights file.
  3. Check the log for the skipped-layers warning to see which layers failed and why (shape mismatch vs name mismatch).
  4. If intentional (training from scratch), remove the load-weights option.

Example fix

# before: weights from a different model plugin
faceswap train ... -m mymodel -wm other_model_weights.keras

# after: either use matching weights
faceswap train ... -m mymodel -m same_arch_weights.keras
# or train fresh without -wm
Defensive patterns

Strategy: validation

Validate before calling

# Before training, sanity-check that the weights model shares layer names with your model:
import keras.models as km
w = km.load_model(weights_file, compile=False)
my = km.load_model(state_file, compile=False)
shared = {l.name for l in w.layers} & {l.name for l in my.layers}
assert shared, "weights share no layers with this model; transfer will fail"

Prevention

When it happens

Trigger: Loading a weights file whose architecture shares no layers with the current model — e.g. warm-starting from a different model plugin or a model trained with incompatible input size/settings, so every _load_layer_weights call returns 0.

Common situations: Trying to transfer weights between different model types; input dimensions or plugin settings changed so layer names/shapes never match; using a weights file saved by a much older version.

Related errors


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