              The information held within the Faceswap PNG Header
          filename: str
              The full path to the file being validated
  
          Raises
          ------
          FaceswapError
              If a version 1.0 face appears in a 2.x set or vice versa
          """
          alignment_version = png_meta["source"]["alignments_version"]
  
          if not self._extract_version:
              logger.debug("Setting initial extract version: %s", alignment_version)
              self._extract_version = alignment_version
              if alignment_version == 1.0 and self._centering != "legacy":
                  self._reset_cache(True)
              return
  
          if (self._extract_version == 1.0 and alignment_version > 1.0) or (
                  alignment_version == 1.0 and self._extract_version > 1.0):
              raise FaceswapError("Mixing legacy and full head extracted facesets is not supported. "
                                  "The following folder contains a mix of extracted face types: "
 
</s> remove         if (self._extract_version == 1.0 and alignment_version > 1.0) or (
                alignment_version == 1.0 and self._extract_version > 1.0):
            raise FaceswapError("Mixing legacy and full head extracted facesets is not supported. "
                                "The following folder contains a mix of extracted face types: "
                                "{}".format(os.path.dirname(filename)))
 </s> add     def _apply_mask(self, detected_faces: List[DetectedFace], batch: np.ndarray) -> None:
        """ Applies the masks to the 4th channel of the batch. </s> remove         Parameters
        ----------
        png_meta: dict
            The information held within the Faceswap PNG Header
        filename: str
            The full path to the file being validated
 </s> add         with futures.ThreadPoolExecutor() as executor:
            proc = {executor.submit(face.aligned.extract_face, img): idx
                    for idx, (face, img) in enumerate(zip(detected_faces, images))} </s> remove         self._extract_version = min(alignment_version, self._extract_version)
 </s> add         If the configuration options `eye_multiplier` and/or `mouth_multiplier` are greater than 1
        then these masks are applied to the final channels of the batch respectively. </s> remove         with self._lock:
            for filename, meta in tqdm(read_image_meta_batch(filenames),
                                       desc="WTL: Caching Landmarks ({})".format(side.upper()),
                                       total=len(filenames),
                                       leave=False):
                if "itxt" not in meta or "alignments" not in meta["itxt"]:
                    raise FaceswapError(f"Invalid face image found. Aborting: '{filename}'")

                size = meta["width"]
                meta = meta["itxt"]
                # Version Check
                self._validate_version(meta, filename)
                detected_face = self._add_aligned_face(filename, meta["alignments"], size)
                self._cache[os.path.basename(filename)]["detected_face"] = detected_face
            self._partial_load = True

    def _validate_version(self, png_meta, filename):
        """ Validate that there are not a mix of v1.0 extracted faces and v2.x faces.
 </s> add         logger.trace("Cropping training images info: (filenames: %s, side: '%s')",  # type: ignore
                     filenames, self._side) </s> remove         if set_flag:
            logger.warning("You are using legacy extracted faces but have selected '%s' centering "
                           "which is incompatible. Switching centering to 'legacy'",
                           self._centering)
        self._config["centering"] = "legacy"
        self._centering = "legacy"
        self._cache = {key: dict(cached=False) for key in self._cache}
        self._cache_full = False
        self._size = None
        if set_flag:
            self._has_reset = True

    def _add_aligned_face(self, filename, alignments, image_size):
        """ Add a :class:`lib.align.AlignedFace` object to the cache.
 </s> add         if not self._use_mask:
            return

        masks = np.array([face.get_training_masks() for face in detected_faces])
        batch[..., 3:] = masks

        logger.trace("side: %s, masks: %s, batch: %s",  # type: ignore
                     self._side, masks.shape, batch.shape)

    def _process_batch(self, filenames: List[str]) -> BatchType:
        """ Prepares data for feeding through subclassed methods.

        If this is the first time a face has been loaded, then it's meta data is extracted from the
        png header and added to :attr:`_face_cache`
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
              The information held within the Faceswap PNG Header
          filename: str
              The full path to the file being validated
  
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
            for future in futures.as_completed(proc):
                batch[proc[future], ..., :3] = future.result()
  
          if (self._extract_version == 1.0 and alignment_version > 1.0) or (
                  alignment_version == 1.0 and self._extract_version > 1.0):
              raise FaceswapError("Mixing legacy and full head extracted facesets is not supported. "
                                  "The following folder contains a mix of extracted face types: "
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Data Augmentation update (#1263)

- lib.detected_face
    - Subclass Masks for Landmark based masks
    - Add training mask propery + methods to DetectedFace
  - lib.training_training
    - subclass TrainingDataGenerator for training and preview data
    - Split cache into own module
    - Reduce thread count to 1 to prevent image corruption + data re-use
    - Process on largest model input/output size rather than stored image size
    - Size and crop masks during caching stage
    - Implement ring buffer for data flow
    - Fix preview reload bug
  - augmentation
    - typing
    - switch color aug order
    - better initialization
    - Fix warp + landmark warp to correctly apply at different image scales
    - Slightly improved warp caching
    - Don't store whether image is_preview. Handle all data as training images implicitly
  - plugins.trainer: Typing and fixes to work with trainingdata refactor 
lib/training/generator.py