  
          # Get Targets
          processed.update(self._processing.get_targets(batch))
  
          # 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)]
  
          logger.trace("Processed batch: (filenames: %s, side: '%s', processed: %s)",
                       filenames,
                       side,
                       {k: v.shape if isinstance(v, np.ndarray) else[i.shape for i in v]
 
</s> remove                      [tgt_images.shape[1:] for tgt_images in target_batch])
 </s> add                      [tgt.shape for tgt_images in target_batch for tgt in tgt_images]) </s> remove                      "landmarks_xy: %s, filename: %s)",
 </s> add                      "landmarks_xy: %s, mask: %s, filename: %s)", </s> remove         if self.config["replicate_input_mask"] or self.config["penalized_mask_loss"]:
            # penalized mask doesn't have a mask ouput, so we can't use output shapes
            # mask should always be last output..this needs to be a rule
            mask_shape = output_network.output_shapes[-1]
            inputs.append(Input(shape=(mask_shape[1:-1] + (1,)), name="mask_in"))
 </s> add         mask_idx = [idx for idx, name in enumerate(output_network.output_names)
                    if name.startswith("mask")]
        if mask_idx:
            # Add the final mask shape as input
            mask_shape = output_network.output_shapes[mask_idx[0]]
            inputs.append(Input(shape=mask_shape[1:], name="mask_in")) </s> remove         config item ``warp_to_landmarks`` is ``True``. If the landmarks for an image cannot be
        found, then an error is raised. """
 </s> add         config item ``warp_to_landmarks`` is ``True`` or if :attr:`mask_type` is not ``None``. If
        the landmarks for an image cannot be found, then an error is raised. """ </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
        # 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)
  
          # Get Targets
          processed.update(self._processing.get_targets(batch))
  
        # 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)
        # 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)
        # 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)
        # 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)
  
          logger.trace("Processed batch: (filenames: %s, side: '%s', processed: %s)",
                       filenames,
                       side,
                       {k: v.shape if isinstance(v, np.ndarray) else[i.shape for i in v]
keep keep keep keep 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 
lib/training_data.py