  
          # 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)
  
          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         if self._mask_class or to_landmarks:
            batch_src_pts = self._get_landmarks(filenames, batch, side)
 </s> add         if self._training_opts["warp_to_landmarks"]:
            batch_src_pts = self._get_landmarks(filenames, side)
            batch_dst_pts = self._get_closest_match(filenames, side, batch_src_pts)
            warp_kwargs = dict(batch_src_points=batch_src_pts,
                               batch_dst_points=batch_dst_pts)
        else:
            warp_kwargs = dict() </s> remove         to_landmarks = self._training_opts["warp_to_landmarks"]
 </s> add  </s> remove                      [tgt.shape for tgt_images in target_batch for tgt in tgt_images])
 </s> add                      [tgt_images.shape[1:] for tgt_images in target_batch]) </s> remove         batch = read_image_batch(filenames)
 </s> add         filenames, batch = read_image_batch(filenames)
        batch = self._apply_mask(filenames, batch, side) </s> remove         src_points = [self._landmarks[side].get(sha1(face).hexdigest(), None) for face in batch]

 </s> add         src_points = [self._landmarks[side].get(filename, None) for filename in filenames]
        # 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)]
  
          # 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)]
        # 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)]
        # 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)]
        # 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)]
        # 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)]
        # 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)]
        # 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)]
        # 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)]
        # 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]
keep keep keep keep replace replace replace replace replace replace replace replace 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