          # TODO Convert this and landmarks_xy to numpy arrays once serialization
          # decision is made, Hacky temp fix as can't serialize numpy arrays in json
          # and tolist is hugely slow and gobbles ram
          for mask, face in zip(batch["prediction"], batch["detected_faces"]):
              placeholder = np.zeros(face.image.shape[:2] + (1, ), dtype="float32")
              placeholder = (cv2.warpAffine(
                  mask,
                  face.feed_matrix,
                  (face.image.shape[1], face.image.shape[0]),
                  placeholder,
                  flags=cv2.WARP_INVERSE_MAP | face.feed_interpolators[1],
                  borderMode=cv2.BORDER_TRANSPARENT) * 255.0).astype("uint8")
              face.mask[self.name] = base64.b64encode(zlib.compress(placeholder)).decode()
          self._remove_invalid_keys(batch, ("detected_faces", "filename", "image"))
          logger.trace("Item out: %s", {key: val
                                        for key, val in batch.items()
                                        if key != "image"})
          for filename, image, face in zip(batch["filename"],
 
</s> remove         if self.blur_kernel is not None:
            predicted = np.array([cv2.GaussianBlur(mask, (self.blur_kernel, self.blur_kernel), 0)
                                  for mask in batch["prediction"]])
        else:
            predicted = batch["prediction"]
        predicted[predicted < 0.04] = 0.0
        predicted[predicted > 0.96] = 1.0
        # TODO Convert this and landmarks_xy to numpy arrays once serialization
        # decision is made, Hacky temp fix as can't serialize numpy arrays in json
        # and tolist is hugely slow and gobbles ram
 </s> add         # TODO Migrate these settings to retrieval rather than storage
        # if self.blur_kernel is not None:
        #    predicted = np.array([cv2.GaussianBlur(mask, (self.blur_kernel, self.blur_kernel), 0)
        #                          for mask in batch["prediction"]])
        # else:
        #    predicted = batch["prediction"]
        # predicted[predicted < 0.04] = 0.0
        # predicted[predicted > 0.96] = 1.0
        # TODO Convert landmarks_xy to numpy arrays </s> remove             batch[..., :3] = self._processing.color_adjust(batch[..., :3])
 </s> add             batch = self._processing.color_adjust(batch)

        # Add mask to batch prior to transforms and warps
        if self._mask_class:
            batch = np.array([self._mask_class(src_pts, image, channels=4).mask
                              for src_pts, image in zip(batch_src_pts, batch)]) </s> remove             src_face = detected_face.reference_face / np.array(255.0, dtype="float32")
 </s> add             src_face = detected_face.reference_face </s> remove         # Random Warp # TODO change masks to have a input mask and a warped target mask
        processed["feed"] = [self._processing.warp(batch[..., :3],
                                                   self._training_opts["warp_to_landmarks"],
                                                   **warp_kwargs)]
 </s> add         # Random Warp
        if to_landmarks:
            warp_kwargs = dict(batch_src_points=batch_src_pts,
                               batch_dst_points=self._get_closest_match(filenames,
                                                                        side,
                                                                        batch_src_pts))
        else:
            warp_kwargs = dict()
        processed["feed"] = self._processing.warp(batch[..., :3], to_landmarks, **warp_kwargs)
            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

          # TODO Convert this and landmarks_xy to numpy arrays once serialization
          # decision is made, Hacky temp fix as can't serialize numpy arrays in json
          # and tolist is hugely slow and gobbles ram
          for mask, face in zip(batch["prediction"], batch["detected_faces"]):
            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

            face.add_mask(self.name,
                          mask,
                          face.feed_matrix,
                          (face.image.shape[1], face.image.shape[0]),
                          face.feed_interpolators[1])
            face.feed = None

          self._remove_invalid_keys(batch, ("detected_faces", "filename", "image"))
          logger.trace("Item out: %s", {key: val
                                        for key, val in batch.items()
                                        if key != "image"})
          for filename, image, face in zip(batch["filename"],
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Serialize masks to alignments file

- Add new serializers (npy + compressed)
- Remove Serializer option from cli
- Revert get_aligned call in scripts/extract
- Default alignments to compressed
- Size masks to 128px and compress
- Remove mask thresholding/blur from generation code
- Add Mask class to lib/faces_detect
- Revert debug landmarks to aligned face
- Revert non-extraction code to staging version 
plugins/extract/mask/_base.py