                                               cv2.INTER_AREA)
                                    for image in batch])
                          for size in self._output_sizes]
          logger.trace("Target image shapes: %s",
                       [tgt.shape for tgt_images in target_batch for tgt in tgt_images])
  
          retval = self._separate_target_mask(target_batch)
          logger.trace("Final targets: %s",
                       {k: v.shape if isinstance(v, np.ndarray) else [img.shape for img in v]
                        for k, v in retval.items()})
 
</s> remove                                   for image in batch])
 </s> add                                   for image in batch], dtype='float32') / 255. </s> remove         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)
        else:
            logger.trace("Batch has no mask")
            retval = dict(targets=batch)
 </s> add         logger.trace("target_batch shapes: %s", [tgt.shape for tgt in target_batch])
        retval = dict(targets=[batch[..., :3] for batch in target_batch],
                      masks=[target_batch[-1][..., 3:]])
        logger.trace("returning: %s", {k: [tgt.shape for tgt in v] for k, v in retval.items()}) </s> remove             landmarks[side] = self.transform_landmarks(alignments)
        return landmarks
 </s> add             retval[side] = self._to_detected_faces(alignments, side)
        logger.debug("Returning: %s", {k: len(v) for k, v in retval.items()})
        return retval </s> remove         # 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)
 </s> add         # 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> remove             images = np.array([cv2.addWeighted(img, 1.0,  # pylint: disable=no-member
                                               masks3[idx], 0.3,
                                               0)
 </s> add             images = np.array([cv2.addWeighted(img, 1.0, masks3[idx], 0.3, 0)
                     [tgt_images.shape[1:] for tgt_images in target_batch])
                                               cv2.INTER_AREA)
                                    for image in batch])
                          for size in self._output_sizes]
          logger.trace("Target image shapes: %s",
                     [tgt_images.shape[1:] for tgt_images in target_batch])
  
          retval = self._separate_target_mask(target_batch)
          logger.trace("Final targets: %s",
                       {k: v.shape if isinstance(v, np.ndarray) else [img.shape for img in v]
                        for k, v in retval.items()})
keep keep keep keep replace keep keep keep keep keep
 Smart Masks - Training Implementation (#914)

* Smart Masks - Training

- Reinstate smart mask training code
- Reinstate mask_type back to model.config
- change 'replicate_input_mask to 'learn_mask'
- Add learn mask option
- Add mask loading from alignments to plugins.train.trainer
- Add mask_blur and mask threshold options
- _base.py - Pass mask options through training_opts dict
- plugins.train.model - check for mask_type not None for learn_mask and penalized_mask_loss
- Limit alignments loading to just those faces that appear in the training folder
- Raise error if not all training images have an alignment, and alignment file is required
- lib.training_data - Mask generation code
- lib.faces_detect - cv2 dimension stripping bugfix
- Remove cv2 linting code

* Update mask helptext in cli.py

* Fix Warp to Landmarks
Remove SHA1 hashing from training data

* Update mask training config

* Capture missing masks at training init

* lib.image.read_image_batch - Return filenames with batch for ordering

* scripts.train - Documentation

* plugins.train.trainer - documentation

* Ensure backward compatibility.
Fix convert for new predicted masks

* Update removed masks to components for legacy models. 
lib/training_data.py