  
          Returns
          -------
          dict
              The face filenames as keys with the zip compressed mask as value.
          """
          logger.trace("side: %s, detected_faces: %s, area: %s", side, detected_faces, area)
          masks = dict()
          size = list(self._aligned_faces[side].values())[0].size
          for fhash, face in detected_faces.items():
 
</s> remove             filename as key and :class:`lib.faces.detected_face.AlignedFace` object as value.
 </s> add             filename as key and :class:`lib.align.AlignedFace` object as value. </s> remove             ret_side = dict()
 </s> add             retval[side] = dict() </s> remove                                      input_sizes[side])
            for fhash, face in detected_faces.items():
                face.aligned = AlignedFace(face.landmarks_xy,
                                           centering=self._config["centering"],
                                           size=size,
                                           is_aligned=True)
                for filename in self._hash_to_filenames(side, fhash):
                    ret_side[filename] = face.aligned
            retval[side] = ret_side
 </s> add                                      self._image_sizes[side])
            for filename, face in detected_faces.items():
                retval[side][filename] = AlignedFace(face.landmarks_xy,
                                                     centering=self._config["centering"],
                                                     size=size,
                                                     is_aligned=True)
        logger.debug("Loaded aligned faces: %s", {k: len(v) for k, v in retval.items()}) </s> remove         input_sizes: dict
            The training image sizes in pixels for side `a` and `b` as they are saved on disk
 </s> add         output_warning: bool, optional
            If ``True`` outputs a warning that images are missing alignments data.

        Returns
        -------
        bool
            ``True`` if all images have valid metadata otherwise ``False``
        """
        all_valid = {side: all(val.values()) for side, val in self._detected_faces.items()}
        if all(all_valid.values()):
            return True
        if not output_warning:
            return False

        for side, valid in all_valid.items():
            if valid:
                continue
            invalid = [filename
                       for filename, meta in self._detected_faces[side].items() if not meta]

            logger.warning("Data for training side '%s' contains %s faces that do not contain "
                           "valid metadata and will be excluded from training.",
                           side.upper(), len(invalid))
            logger.warning("Run in VERBOSE mode if you wish to see a list of these files.")
            logger.verbose("Side '%s' images missing metadata: %s", side.upper(),
                           sorted(os.path.basename(fname) for fname in invalid))
            # Remove images without metadata
            self._detected_faces[side] = {key: val
                                          for key, val in self._detected_faces[side].items()
                                          if val}
        return False

    def _validate_masks(self):
        """ Validate the the loaded metadata all contain the masks required for training.

        Raises
        ------
        FaceswapError
            If at least one face in the training data does not contain the selected mask type
        """
        mask_type = self._config["mask_type"]
        invalid = {side: [filename for filename, detected_face in faces.items()
                          if mask_type not in detected_face.mask]
                   for side, faces in self._detected_faces.items()}
        if any(invalid.values()):
            msg = ("You have selected the Mask Type '{}' in your training configuration options "
                   "but at least one face does not have this mask type stored for it.\nYou should "
                   "select a mask type that exists within your face data, or generate the "
                   "required masks with the Mask Tool.".format(mask_type))
            for side, filenames in invalid.items():
                available = set(mask
                                for det_face in self._detected_faces[side].values()
                                for mask in det_face.mask)
                msg += ("\n{} faces in side {} do not contain the mask '{}'. Available "
                        "masks: {}".format(len(filenames), side.upper(), mask_type, available))
            raise FaceswapError(msg)

    # <<< LOAD REQUIRED DATA FOR TRAINING >>>
    def _get_aligned_faces(self):
        """ Pre-generate aligned faces as they are needed for all training functions.
            The face filenames as keys with the :func:`functools.partial` of the mask as value
  
          Returns
          -------
          dict
            The face filenames as keys with the :func:`functools.partial` of the mask as value
          """
          logger.trace("side: %s, detected_faces: %s, area: %s", side, detected_faces, area)
          masks = dict()
          size = list(self._aligned_faces[side].values())[0].size
          for fhash, face in detected_faces.items():
keep keep keep keep replace keep keep keep keep keep
 Update extracted faces to use PNG EXIF data (#1123)

Documentation
  - Update Usage.md, align.rst and image.rst
lib.image.py
  - read_image - Remove hash return, add metadata return
  - Remove read_image_hash functions
  - Add read_image_meta functios
  - Replace encode_image_with_hash with encode_image (to store metadata)
  - Add png meta reading and writing functions
  - Update Image Loaders/Savers to handle metadata rather than hashes
lib.training_data
  - Naming updates to remove references to hashes
lib.align.Alignments
  - Add versioning notes
  - Increment alignments version to 2.1
  - Deprecate hashing lookup functions
  - Replace filter_hashes with filter_faces
lib.align.detected_face
  - DetectedFace
    - Remove hash property
    - Add png header data serializing/deserializing functions
  - Mask
    - Add png header data serializing/deserializing functions
  - add update_legacy_png_header function to update png meta data
lib.cli.args - Deprecate alignments files for training
- plugins.train.trainer
  - Update alignments/mask code to read png header data
- scripts.convert
  - Aligned images folder - read data from png headers
- scripts.extract
  - Write png header information and no longer store hash of face
- tools.alignments
  - remove leftover-faces, merge and update-hashes jobs
  - Update jobs to use png meta data rather than hashes
- tools.manual
  - Update extract code to output png meta data and don't store hashes
  - Perform check on launch that tool is not pointing at a faces folder
tools.mask
  - Update to use png meta data
tools.sort
  - Update to use png meta data 
plugins/train/trainer/_base.py