{"record":{"id":"566cf618701a32b9","repo":"deepfakes/faceswap","slug":"alignments-file-not-found-at-self-file","errorCode":null,"errorMessage":"Alignments file not found at {self._file}","messagePattern":"Alignments file not found at (.+?)","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"lib/align/alignments.py","lineNumber":589,"sourceCode":"            MaskCentering(alignments_dict, self._version),\n            IdentityAndVideoMeta(alignments_dict, self._version))]\n        if any(updates):\n            self.update_version()\n        return any(updates)\n\n    def load(self) -> dict[str, AlignmentsEntry]:\n        \"\"\"Load the alignments data from the serialized alignments :attr:`file`.\n\n        Populates :attr:`_version` with the alignment file's loaded version as well as returning\n        the serialized data.\n\n        Returns\n        -------\n        The loaded alignments data\n        \"\"\"\n        logger.debug(\"Loading alignments\")\n        if not self.have_alignments_file:\n            raise FaceswapError(f\"Alignments file not found at {self._file}\")\n\n        logger.info(\"Reading alignments from: '%s'\", self._file)\n        data = self._serializer.load(self._file)\n        meta = data.get(\"__meta__\", {\"version\": 1.0})\n        self._version = meta[\"version\"]\n        if self._version < 2.0:\n            logger.error(\"This alignments file was generated with a very old legacy extraction \"\n                         \"method.\")\n            logger.error(\"Updating these very old files is no longer supported.\")\n            logger.error(\"To update to a more recent, supported format, you should run the \"\n                         \"alignments tool's 'extract' job with this file in Faceswap v2.3: \"\n                         \"https://github.com/deepfakes/faceswap/releases/tag/v2.3.0\")\n            sys.exit(1)\n\n        alignments = data[\"__data__\"]\n        if self._update_legacy(alignments):\n            logger.info(\"Writing alignments to: '%s'\", self._file)\n            self._serializer.save(self._file, {\"__meta__\": {\"version\": self._version},","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/align/alignments.py#L571-L607","documentation":"LandmarkType.from_shape (lib/align/constants.py) maps a landmarks array's shape tuple to a LandmarkType enum member. Only (4,2), (51,2), (68,2), (98,2) and (26,3) are recognized; any other shape raises ValueError because Faceswap has no mean-face/template for it.","triggerScenarios":"Calling LandmarkType.from_shape(landmarks.shape) with a landmarks ndarray of any other shape, e.g. (5,2) from some external detector, (68,3) 3D landmarks, or a flattened (136,) array that was never reshaped to (68,2).","commonSituations":"Converting third-party detector outputs (MediaPipe 468-point, dlib 5-point, 3D landmarks) into Faceswap alignments; forgetting to reshape flat landmark vectors before passing them in; a corrupt/short landmarks row in a hand-edited alignments file.","solutions":["Reshape/convert landmarks to one of the supported shapes before calling (e.g. arr.reshape(-1, 2) and verify the point count is 4/51/68/98 for 2D or 26 for 3D)","For unsupported detectors, map landmarks down to 68 points (see MAP_2D_98 for an example of a mapping table) before creating DetectedFace data","Validate the shape early and skip/log malformed frames instead of crashing the pipeline"],"exampleFix":"# before\nlms = np.loadtxt(\"landmarks.txt\")        # shape (136,)\nltype = LandmarkType.from_shape(lms.shape)  # ValueError\n\n# after\nlms = lms.reshape(-1, 2)                  # (68, 2)\nif lms.shape in {(4, 2), (51, 2), (68, 2), (98, 2), (26, 3)}:\n    ltype = LandmarkType.from_shape(lms.shape)","handlingStrategy":"validation","validationCode":"import os\n\ndef alignments_ready(path):\n    return os.path.isfile(path) and os.path.getsize(path) > 0\n\nassert alignments_ready(my_path), f\"missing alignments: {my_path}\"","typeGuard":null,"tryCatchPattern":"try:\n    alignments = Alignments(folder, filename)\n    alignments.load()\nexcept FaceswapError as err:\n    if \"not found at\" in str(err):\n        raise SystemExit(f\"Run extraction first to create {path}\") from err\n    raise","preventionTips":["Verify the alignments file exists before starting train/convert","Use consistent -a/-als argument naming across pipeline steps","Script a preflight that checks input frames, alignments and model dir together"],"tags":["faceswap","landmarks","validation","numpy"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}