{"record":{"id":"ca21c14e6684dbfa","repo":"deepfakes/faceswap","slug":"you-are-attempting-to-load-weights-from-a-retval","errorCode":null,"errorMessage":"You are attempting to load weights from a '{retval[0].name}' model into a '{self._name}' model. This is not supported.","messagePattern":"You are attempting to load weights from a '(.+?)' model into a '(.+?)' model\\. This is not supported\\.","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"plugins/train/model/_base/io.py","lineNumber":522,"sourceCode":"\n        Returns\n        -------\n        List of all models contained within the .keras file\n\n        Raises\n        ------\n        FaceswapError\n            In the event of a failure to load the weights, or the weights belonging to a different\n            model\n        \"\"\"\n        retval = get_all_sub_models(k_models.load_model(    # pyright:ignore[reportArgumentType]\n            self._weights_file,\n            compile=False))\n        if not retval:\n            raise FaceswapError(f\"Error loading weights file {self._weights_file}.\")\n\n        if retval[0].name != self._name:\n            raise FaceswapError(f\"You are attempting to load weights from a '{retval[0].name}' \"\n                                f\"model into a '{self._name}' model. This is not supported.\")\n        return retval\n\n    def _load_layer_weights(self,\n                            layer: layers.Layer,\n                            sub_weights: layers.Layer,\n                            model_name: str) -> T.Literal[-1, 0, 1]:\n        \"\"\"Load the weights for a single layer.\n\n        Parameters\n        ----------\n        layer\n            The layer to set the weights for\n        sub_weights\n            The list of layers in the weights model to load weights from\n        model_name\n            The name of the current sub-model that is having it's weights loaded\n","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/plugins/train/model/_base/io.py#L504-L540","documentation":"Raised in _get_weights_model when the weights file's first sub-model name does not equal the current model plugin's name (self._name). Faceswap only supports warm-starting within the same architecture, and uses the sub-model name as the identity check, so cross-model weight loading is refused before any layers are touched.","triggerScenarios":"Selecting load-weights with a file saved from a different model plugin (e.g. 'original' weights into a 'dfl-sae'/'realface' session) — retval[0].name differs from self._name.","commonSituations":"Copying a weights command from a tutorial built around another model; renaming the model plugin folder while keeping old weights; experimenting with cross-architecture transfer, which Faceswap does not support.","solutions":["Use weights saved from the same model plugin as the one being trained.","If the architecture changed deliberately, start fresh without load-weights.","Verify which model plugin the weights came from (the error prints both names) and align your -m model selection with it."],"exampleFix":"# before\nfaceswap train -m original_model -wm dfl_sae_weights.keras\n\n# after\nfaceswap train -m original_model -wm original_weights.keras  # same plugin","handlingStrategy":"validation","validationCode":"import keras.models as km\nsubs = get_all_sub_models(km.load_model(weights_file, compile=False))\nassert subs[0].name == my_model_name, f\"{subs[0].name} weights cannot load into {my_model_name}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Warm-start only within the same model plugin; cross-architecture transfer is unsupported by design.","Name/organize weights files by the plugin that produced them."],"tags":["faceswap","weights","model-mismatch","transfer-learning"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}