{"record":{"id":"a16315c85e10a5c4","repo":"deepfakes/faceswap","slug":"no-faces-were-found-in-any-of-the-frames-passed-in","errorCode":null,"errorMessage":"No faces were found in any of the frames passed in. Make sure you are passing in a frames source rather than extracted faces, and that you have provided the correct alignments file.","messagePattern":"No faces were found in any of the frames passed in\\. Make sure you are passing in a frames source rather than extracted faces, and that you have provided the correct alignments file\\.","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"tools/preview/preview.py","lineNumber":368,"sourceCode":"        \"\"\"Get a list of files for the input, filtering out those frames which do\n        not contain faces.\n\n        Returns\n        -------\n        list\n            A list of filenames of frames that contain faces.\n        \"\"\"\n        logger.debug(\"Filtering file list to frames with faces\")\n        retval = [filename for filename in self._images.file_list\n                  if self._alignments.frame_has_faces(os.path.basename(filename))]\n        logger.debug(\"Filtered out frames: %s\", self._images.count - len(retval))\n        try:\n            assert retval\n        except AssertionError as err:\n            msg = (\"No faces were found in any of the frames passed in. Make sure you are passing \"\n                   \"in a frames source rather than extracted faces, and that you have provided \"\n                   \"the correct alignments file.\")\n            raise FaceswapError(msg) from err\n        return retval\n\n    def _get_indices(self) -> list[list[int]]:\n        \"\"\"Get indices for each sample group.\n\n        Obtain :attr:`self.sample_size` evenly sized groups of indices\n        pertaining to the filtered :attr:`self._file_list`\n\n        Returns\n        -------\n        list of indices relating to the filtered file list, split into groups\n        \"\"\"\n        # Remove start and end values to get a list divisible by self.sample_size\n        no_files = len(self._filelist)\n        self._sample_size = min(self._sample_size, no_files)\n        crop = no_files % self._sample_size\n        top_tail = list(range(no_files))[\n            crop // 2:no_files - (crop - (crop // 2))]","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/tools/preview/preview.py#L350-L386","documentation":"Preview tool filter failure: after filtering the input file list to frames whose basename appears in the alignments file with at least one face, the result is empty (an `assert retval` fails and is converted to FaceswapError). The tool needs frames with detected faces to build preview samples.","triggerScenarios":"Running `python tools.py preview -i <frames_or_faces> -a <alignments>` where no input filename matches a frame key with faces in the alignments — classically when -i points at the extracted faces folder instead of the frames folder, or the alignments file belongs to a different video/folder than the images supplied.","commonSituations":"Passing the aligned-faces directory as input; using an alignments file from another video (filename mismatch); alignments generated before any faces were detected; renaming frames after extraction.","solutions":["Point -i at the original frames folder that was extracted, and -a at the matching alignments file.","If you renamed/moved frames, re-extract or restore original filenames so they match alignments keys.","Confirm the alignments actually contain faces: `python tools.py alignments -j spans -a <file>` or open it in the Alignment tool."],"exampleFix":"# before\npython tools.py preview -i aligned_faces/ -a alignments.fsa   # faces dir has no matching frame keys\n\n# after\npython tools.py preview -i original_frames/ -a alignments.fsa","handlingStrategy":"validation","validationCode":"import os\nfrom lib.align import Alignments\n\ndef frames_have_faces(input_dir: str, alignments_file: str) -> bool:\n    al = Alignments(alignments_file)\n    return any(\n        al.frame_has_faces(os.path.basename(f))\n        for f in os.listdir(input_dir)\n    )","typeGuard":null,"tryCatchPattern":"from lib.exceptions import FaceswapError\ntry:\n    preview.run()\nexcept FaceswapError as err:\n    if \"No faces were found\" in str(err):\n        raise SystemExit(\"Use the frames folder and matching alignments file\") from err\n    raise","preventionTips":["Only run preview with the original frames directory plus the alignments file generated from it.","Don't rename frames between extract and preview — preview matches by basename."],"tags":["faceswap","preview","alignments","frames","configuration"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}