{"record":{"id":"8027d528712fffff","repo":"deepfakes/faceswap","slug":"mixing-aligned-and-non-aligned-images-is-not-suppo","errorCode":null,"errorMessage":"Mixing aligned and non-aligned images is not supported","messagePattern":"Mixing aligned and non-aligned images is not supported","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/infer/iterator.py","lineNumber":309,"sourceCode":"        \"\"\"\n        in_batch = ExtractBatch.from_frame_faces(media)\n        if not self._fifo:  # Add straight in to a fresh FIFO\n            self._append_to_fifo(in_batch)\n            return\n\n        last_fifo = self._fifo[-1]\n        exist_size = len(last_fifo.filenames) if self._plugin_type == \"detect\" else len(last_fifo)\n\n        if exist_size == self._batch_size:  # Append straight onto the end of FIFO\n            self._append_to_fifo(in_batch)\n            return\n\n        capacity = self._batch_size - exist_size\n        num_boxes = in_batch.bboxes.shape[0]\n        to_add = len(in_batch.filenames) if self._plugin_type == \"detect\" else num_boxes\n\n        if media.is_aligned != last_fifo.is_aligned:\n            raise ValueError(\"Mixing aligned and non-aligned images is not supported\")\n\n        if to_add <= capacity:  # Append to the last item in the FIFO\n            last_fifo.append(in_batch)\n            logger.trace(  # type:ignore[attr-defined]\n                \"[%s] Added batch with %s items to existing batch of %s items\",\n                self._name, to_add, exist_size)\n            return\n\n        # Only FrameFaces containing detected faces that need to be added to the last item in the\n        # fifo and then subsequently split will exist here\n        split_batch = in_batch[0:capacity]\n        last_fifo.append(split_batch)\n        logger.trace(  # type:ignore[attr-defined]\n            \"[%s] Added batch with %s items to existing batch of %s items\",\n            self._name, capacity, exist_size)\n        self._append_to_fifo(in_batch[capacity:capacity + (num_boxes - capacity)])\n\n    def __next__(self) -> ExtractBatch | ExtractSignal:","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/infer/iterator.py#L291-L327","documentation":"The batch iterator's FIFO attempts to merge an incoming batch into the last FIFO entry, which requires both to have the same alignment status (aligned face crops vs. raw frames). If in_batch.is_aligned differs from last_fifo.is_aligned, a ValueError is raised because downstream processing cannot mix the two representations.","triggerScenarios":"Feeding a detect/recognize pipeline a stream that interleaves pre-aligned face images with unaligned full frames; mixing an aligned faces folder and a frames folder as input in one run.","commonSituations":"Users pointing extraction at a folder that contains both extracted face PNGs and original frames; chaining plugins where one stage outputs aligned crops fed into a stage expecting raw frames.","solutions":["Separate inputs: run aligned and non-aligned images through distinct pipeline invocations.","Verify the input folder contains only one kind of image (frames OR aligned faces).","Check plugin ordering — alignment-aware plugins should receive consistent input types."],"exampleFix":"# before: mixed input folder\n$ python faceswap.py extract -i /mixed_folder -o /out  # ValueError\n\n# after: split by type first\n$ python faceswap.py extract -i /frames -o /out\n$ python faceswap.py extract -i /aligned_faces -o /out2","handlingStrategy":"validation","validationCode":"# Keep one input type per pipeline run\nfrom pathlib import Path\naligned_markers = {p for p in Path(folder).glob('*.png')\n                  if b'itxt' in Path(p).read_bytes()[:8192]}\nif aligned_markers and aligned_markers != set(folder_pngs):\n    raise SystemExit('input mixes aligned and non-aligned images; split folders')","typeGuard":null,"tryCatchPattern":"try:\n    process_pipeline(inputs)\nexcept ValueError as err:\n    if 'aligned' in str(err):\n        aligned = [i for i in inputs if i.is_aligned]\n        raw = [i for i in inputs if not i.is_aligned]\n        process_pipeline(aligned); process_pipeline(raw)\n    else:\n        raise","preventionTips":["Never mix extracted face crops with source frames in one input folder.","Tag/organize dataset folders by alignment status.","Keep plugin chains consistent about the image representation they consume."],"tags":["batching","alignment","pipeline","validation"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}