{"record":{"id":"13f917ee381889b8","repo":"deepfakes/faceswap","slug":"load-weights-selected-but-the-path-weights-file","errorCode":null,"errorMessage":"Load weights selected, but the path '{weights_file}' does not exist. Please check and try again.","messagePattern":"Load weights selected, but the path '(.+?)' does not exist\\. Please check and try again\\.","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"plugins/train/model/_base/io.py","lineNumber":424,"sourceCode":"\n        Returns\n        -------\n        The full path to a weights file\n        \"\"\"\n        if not weights_file:\n            logger.debug(\"[Weights] No weights file selected.\")\n            return None\n\n        msg = \"\"\n        if not os.path.exists(weights_file):\n            msg = f\"Load weights selected, but the path '{weights_file}' does not exist.\"\n        elif not os.path.splitext(weights_file)[-1].lower() == \".keras\":\n            msg = (f\"Load weights selected, but the path '{weights_file}' is not a valid Keras \"\n                   f\"model (.keras) file.\")\n\n        if msg:\n            msg += \" Please check and try again.\"\n            raise FaceswapError(msg)\n\n        logger.verbose(\"Using weights file: %s\", weights_file)  # type:ignore\n        return weights_file\n\n    def freeze(self) -> None:\n        \"\"\"If freeze has been selected in the cli arguments, then freeze those models indicated\n        in the plugin's configuration. \"\"\"\n        # Blanket unfreeze layers, as checking the value of :attr:`layer.trainable` appears to\n        # return ``True`` even when the weights have been frozen\n        for layer in get_all_sub_models(self._model):\n            layer.trainable = True\n\n        if not self._do_freeze:\n            logger.debug(\"[Weights] Freeze weights deselected. Not freezing\")\n            return\n\n        for layer in get_all_sub_models(self._model):\n            if layer.name in self._freeze_layers:","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/plugins/train/model/_base/io.py#L406-L442","documentation":"Raised while validating the 'load weights' input in the training model IO: the user selected a weights file, but its path does not exist (the subsequent branch rejects paths that are not .keras files). It is a pre-flight check that runs before any weights are actually read.","triggerScenarios":"Launching training with the load-weights option pointing at a non-existent path — typo, file moved/deleted, or relative path resolved from the wrong working directory.","commonSituations":"Passing --load-weights / -wm paths by hand after moving files; scripts running with a different cwd; placeholder paths left in launch commands.","solutions":["Correct the path so it points at the existing .keras weights file (use an absolute path).","Confirm the extension is '.keras' — a valid file with the wrong extension fails the next check in the same function.","If you no longer want to warm-start, clear the load-weights setting."],"exampleFix":"# before\nfaceswap train ... -wm weights/model.h5\n\n# after\nfaceswap train ... -wm /home/user/weights/model.keras","handlingStrategy":"validation","validationCode":"import os\nassert not weights_path or (os.path.exists(weights_path)\n                             and os.path.splitext(weights_path)[-1].lower() == \".keras\"), \\\n    \"weights path must exist and end in .keras\"","typeGuard":"def is_valid_weights_file(path: str | None) -> bool:\n    return path is None or (os.path.isfile(path) and path.lower().endswith(\".keras\"))","tryCatchPattern":null,"preventionTips":["Use absolute paths for the -wm/--load-weights argument.","Keep weights files alongside the model dir and reference them consistently in launch scripts."],"tags":["faceswap","weights","file-not-found","training","configuration"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}