{"record":{"id":"0ade7761d8b81424","repo":"deepfakes/faceswap","slug":"you-have-requested-to-train-with-the-self-name","errorCode":null,"errorMessage":"You have requested to train with the '{self.name}' plugin, but a model file for the '{multiple_models[0]}' plugin already exists in the folder '{self.io.model_dir}'.\\nPlease select a different model folder.","messagePattern":"You have requested to train with the '(.+?)' plugin, but a model file for the '(.+?)' plugin already exists in the folder '(.+?)'\\.\\\\nPlease select a different model folder\\.","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"plugins/train/model/_base/model.py","lineNumber":188,"sourceCode":"        FaceswapError\n            If multiple model files, or models for a different plugin from that requested exists\n            within the model folder\n        \"\"\"\n        multiple_models = self._io.multiple_models_in_folder\n        if multiple_models is None:\n            logger.debug(\"Contents of model folder are valid\")\n            return\n\n        if len(multiple_models) == 1:\n            msg = (f\"You have requested to train with the '{self.name}' plugin, but a model file \"\n                   f\"for the '{multiple_models[0]}' plugin already exists in the folder \"\n                   f\"'{self.io.model_dir}'.\\nPlease select a different model folder.\")\n        else:\n            p_types = \"', '\".join(multiple_models)\n            msg = (f\"There are multiple plugin types ('{p_types}') stored in the model folder '\"\n                   f\"{self.io.model_dir}'. This is not supported.\\nPlease split the model files \"\n                   \"into their own folders before proceeding\")\n        raise FaceswapError(msg)\n\n    def build(self) -> None:\n        \"\"\"Build the model and assign to :attr:`model`.\n\n        Within the defined strategy scope, either builds the model from scratch or loads an\n        existing model if one exists.\n\n        If running inference, then the model is built only for the required side to perform the\n        swap function, otherwise  the model is then compiled with the optimizer and chosen\n        loss function(s).\n\n        Finally, a model summary is outputted to the logger at verbose level.\n        \"\"\"\n        is_summary = hasattr(self._args, \"summary\") and self._args.summary\n        if self._io.model_exists:\n            model = self.io.load()\n            if self._is_predict:\n                inference = Inference(model, self._args.swap_model)","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/plugins/train/model/_base/model.py#L170-L206","documentation":"FaceswapError raised by ModelBase._check_multiple_models() when training is requested with one plugin (e.g. 'original') but the model folder already contains a state/model file belonging to a different single plugin. Faceswap state files are plugin-specific and incompatible across model architectures, so it refuses to mix them. This is a guard against silently corrupting an existing model.","triggerScenarios":"Passing -m/--model-dir pointing at a folder that holds e.g. dlight_state.h5 while launching train.py with -t original (or any mismatched trainer plugin). Triggered on every training start that performs the model-folder consistency check.","commonSituations":"Reusing the same folder for a new experiment with a different model plugin, downloading someone else's model and training with the wrong plugin name, or a typo in the -t trainer argument.","solutions":["Create a new, empty model folder and pass it with -m so the new plugin starts fresh","Or set -t to the plugin named in the error message (multiple_models[0]) to continue training the existing model","Or move the existing model files out of the folder if the folder is meant to be reused"],"exampleFix":"# before\npython faceswap.py train -t original -m /models/shared\n# error: folder holds 'dlight' model\n\n# after\npython faceswap.py train -t original -m /models/original_new\n# or continue the existing model:\npython faceswap.py train -t dlight -m /models/shared","handlingStrategy":"validation","validationCode":"import os, glob\nplugin = \"original\"  # the trainer you will launch\nfiles = glob.glob(os.path.join(model_dir, \"*_state.*\")) + glob.glob(os.path.join(model_dir, \"*.h5\"))\nforeign = [f for f in files if os.path.basename(f).split(\"_\")[0] not in (plugin,)]\nif foreign:\n    raise SystemExit(f\"Model folder holds foreign plugin files: {foreign}\")","typeGuard":null,"tryCatchPattern":"from lib.exceptions import FaceswapError\ntry:\n    trainer = Trainer(model_dir, args)\nexcept FaceswapError as err:\n    if \"plugin already exists\" in str(err):\n        print(\"Pick a fresh model folder or the matching -t plugin\")\n    raise","preventionTips":["Use one model folder per plugin/experiment and name folders after the plugin","Check folder contents (ls) before switching trainers"],"tags":["faceswap","training","model-folder","config"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}