          offset = (backgrounds.shape[1] - foregrounds.shape[1]) // 2
          new_images = list()
          for idx, img in enumerate(backgrounds):
              img[offset:offset + foregrounds[idx].shape[0],
                  offset:offset + foregrounds[idx].shape[1], :3] = foregrounds[idx]
              new_images.append(img)
          retval = np.array(new_images)
          logger.debug("Overlayed foreground. Shape: %s", retval.shape)
          return retval
  
 
</s> remove             images = np.array([cv2.addWeighted(img,  # pylint: disable=no-member
                                               1.0, masks3[idx], 0.3, 0)
 </s> add             images = np.array([cv2.addWeighted(img, 1.0,  # pylint: disable=no-member
                                               masks3[idx], 0.3,
                                               0) </s> remove             masks = [np.ones((size_list_of_batches[-1].shape[:-1] + (1,)), dtype='float32')]
        retval = dict(targets=targets, masks=masks)
 </s> add             logger.trace("Batch has no mask")
            retval = dict(targets=batch) </s> remove             extension = '.png'
 </s> add             extension = Path(filename).suffix </s> remove         targets = [batch[..., :3] for batch in size_list_of_batches]
        if size_list_of_batches[-1].shape[-1] == 4:
            masks = [size_list_of_batches[-1][..., 3:]]
 </s> add         batch = [tgt.astype("float32") / 255.0 for tgt in batch]
        if all(tgt.shape[-1] == 4 for tgt in batch):
            logger.trace("Batch contains mask")
            sizes = [item.shape[1] for item in batch]
            mask_batch = np.expand_dims(batch[sizes.index(max(sizes))][..., -1], axis=-1)
            batch = [item[..., :3] for item in batch]
            logger.trace("batch shapes: %s, mask_batch shape: %s",
                         [tgt.shape for tgt in batch], mask_batch.shape)
            retval = dict(targets=batch, masks=mask_batch) </s> remove         if self.config.get("replicate_input_mask", False):
 </s> add         if self.config.get("mask_type", None) is not None:
                offset:offset + foregrounds[idx].shape[1]] = foregrounds[idx]
          offset = (backgrounds.shape[1] - foregrounds.shape[1]) // 2
          new_images = list()
          for idx, img in enumerate(backgrounds):
              img[offset:offset + foregrounds[idx].shape[0],
                offset:offset + foregrounds[idx].shape[1]] = foregrounds[idx]
              new_images.append(img)
          retval = np.array(new_images)
          logger.debug("Overlayed foreground. Shape: %s", retval.shape)
          return retval
  
keep keep keep keep 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/train/trainer/_base.py