{"record":{"id":"5a230f9a378dd72c","repo":"deepfakes/faceswap","slug":"the-images-to-be-sorted-do-not-contain-alignment-d-5a230f","errorCode":null,"errorMessage":"The images to be sorted do not contain alignment data. Images must have been generated by Faceswap's Extract process.\\nIf you are sorting an older face set, then you should re-extract the faces from your source alignments file to generate this data.","messagePattern":"The images to be sorted do not contain alignment data\\. Images must have been generated by Faceswap's Extract process\\.\\\\nIf you are sorting an older face set, then you should re-extract the faces from your source alignments file to generate this data\\.","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"tools/sort/sort_methods_aligned.py","lineNumber":88,"sourceCode":"        ----------\n        filename: str\n            The filename of the currently processing image\n        image: :class:`np.ndarray` or ``None``\n            A face image loaded from disk or ``None``\n        alignments: dict or ``None``\n            The alignments dictionary for the aligned face or ``None``\n        \"\"\"\n        if self._log_once:\n            msg = \"Grouping\" if self._is_group else \"Sorting\"\n            logger.info(\"%s by %s...\", msg, self._method)\n            self._log_once = False\n\n        if not alignments:\n            msg = (\"The images to be sorted do not contain alignment data. Images must have \"\n                   \"been generated by Faceswap's Extract process.\\nIf you are sorting an \"\n                   \"older face set, then you should re-extract the faces from your source \"\n                   \"alignments file to generate this data.\")\n            raise FaceswapError(msg)\n\n        face = AlignedFace(alignments.landmarks_xy)\n        if (not self._logged_lm_count_once\n                and face.landmark_type == LandmarkType.LM_2D_4\n                and self.__class__.__name__ != \"SortSize\"):\n            logger.warning(\"You have selected to sort by an aligned metric, but at least one face \"\n                           \"does not contain facial landmark data. This probably won't work\")\n            self._logged_lm_count_once = True\n        self._result.append((filename, self._get_metric(face)))\n\n\nclass SortDistance(SortAlignedMetric):\n    \"\"\" Sorting mechanism for sorting faces from small to large \"\"\"\n    def _get_metric(self, aligned_face: AlignedFace) -> float:\n        \"\"\" Obtain the distance from mean face metric for the given face\n\n        Parameters\n        ----------","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/tools/sort/sort_methods_aligned.py#L70-L106","documentation":"Sort tool aligned-metric path (sort_methods_aligned.py, base for sort-by-yaw/pitch/roll/size/distance etc.): the per-image alignments metadata passed in is falsy, so there is no landmarks_xy to build an AlignedFace from. All aligned-metric sorts share this guard and fail identically.","triggerScenarios":"Running `python tools.py sort -t <yaw|pitch|roll|size|distance|...>` over a folder where one or more PNGs lack Faceswap alignment metadata — same root cause as the identity-sort variant: not extracted by Faceswap, re-saved by a metadata-stripping tool, or from an old extraction.","commonSituations":"Sorting legacy face sets predating metadata embedding; images passed through compression/editing; mixing manually cropped faces into an extracted folder.","solutions":["Re-extract faces with Faceswap's extract so each PNG embeds alignment data, then sort.","Purge non-Faceswap PNGs from the input folder.","Fall back to a histogram/pixel-based sort method that does not require alignment data if re-extraction is not possible."],"exampleFix":"# before\npython tools.py sort -t yaw -i faces/\n# FaceswapError: ... do not contain alignment data ...\n\n# after\npython scripts/extract.py -i frames/ -o faces_fresh/\npython tools.py sort -t yaw -i faces_fresh/","handlingStrategy":"validation","validationCode":"import os\nfrom lib.image import read_image_meta\n\ndef folder_has_alignment_data(folder: str) -> bool:\n    pngs = [f for f in os.listdir(folder) if f.lower().endswith(\".png\")]\n    if not pngs:\n        return False\n    meta = read_image_meta(os.path.join(folder, pngs[0]))\n    return meta.get(\"itxt\", {}).get(\"alignments\") is not None","typeGuard":null,"tryCatchPattern":"from lib.exceptions import FaceswapError\ntry:\n    sorter.sort()\nexcept FaceswapError as err:\n    if \"alignment data\" in str(err):\n        raise SystemExit(\"Re-extract faces with Faceswap before aligned-metric sort\") from err\n    raise","preventionTips":["Run aligned-metric sorts (yaw/pitch/roll/size/distance) only on Faceswap-extracted faces.","Keep a manifest of which folders came from extract; treat anything else as metadata-free.","Re-extract legacy face sets from the original alignments file before sorting by aligned metrics."],"tags":["faceswap","sort","metadata","alignments","landmarks"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}