deepfakes/faceswap · error · ValueError
Mixing aligned and non-aligned images is not supported
Error message
Mixing aligned and non-aligned images is not supported
What it means
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.
Source
Thrown at lib/infer/iterator.py:309
"""
in_batch = ExtractBatch.from_frame_faces(media)
if not self._fifo: # Add straight in to a fresh FIFO
self._append_to_fifo(in_batch)
return
last_fifo = self._fifo[-1]
exist_size = len(last_fifo.filenames) if self._plugin_type == "detect" else len(last_fifo)
if exist_size == self._batch_size: # Append straight onto the end of FIFO
self._append_to_fifo(in_batch)
return
capacity = self._batch_size - exist_size
num_boxes = in_batch.bboxes.shape[0]
to_add = len(in_batch.filenames) if self._plugin_type == "detect" else num_boxes
if media.is_aligned != last_fifo.is_aligned:
raise ValueError("Mixing aligned and non-aligned images is not supported")
if to_add <= capacity: # Append to the last item in the FIFO
last_fifo.append(in_batch)
logger.trace( # type:ignore[attr-defined]
"[%s] Added batch with %s items to existing batch of %s items",
self._name, to_add, exist_size)
return
# Only FrameFaces containing detected faces that need to be added to the last item in the
# fifo and then subsequently split will exist here
split_batch = in_batch[0:capacity]
last_fifo.append(split_batch)
logger.trace( # type:ignore[attr-defined]
"[%s] Added batch with %s items to existing batch of %s items",
self._name, capacity, exist_size)
self._append_to_fifo(in_batch[capacity:capacity + (num_boxes - capacity)])
def __next__(self) -> ExtractBatch | ExtractSignal:View on GitHub (pinned to f530cb7508)
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.
Example fix
# before: mixed input folder $ python faceswap.py extract -i /mixed_folder -o /out # ValueError # after: split by type first $ python faceswap.py extract -i /frames -o /out $ python faceswap.py extract -i /aligned_faces -o /out2
Defensive patterns
Strategy: validation
Validate before calling
# Keep one input type per pipeline run
from pathlib import Path
aligned_markers = {p for p in Path(folder).glob('*.png')
if b'itxt' in Path(p).read_bytes()[:8192]}
if aligned_markers and aligned_markers != set(folder_pngs):
raise SystemExit('input mixes aligned and non-aligned images; split folders') Try / catch
try:
process_pipeline(inputs)
except ValueError as err:
if 'aligned' in str(err):
aligned = [i for i in inputs if i.is_aligned]
raw = [i for i in inputs if not i.is_aligned]
process_pipeline(aligned); process_pipeline(raw)
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Landmark based masks cannot be created for {self._landmark_t
- Alignments file not found at {self._file}
- No display detected. GUI mode has been disabled.
- Config file does not exist at: {ini_path}
- [{self._name}] List values should be set as a Str or List. G
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/8027d528712fffff.
Report an issue: GitHub.