              masks are not included in the ``targets`` list. If masks are to be included in the \
              output they will be returned as their own item from the ``masks`` key.
  
              * **masks** (`numpy.ndarray`) - A 4-dimensional array containing the target masks in \
              the format (`batchsize`, `height`, `width`, `1`). **NB:** This item will only exist \
              in the ``dict`` if a batch of 4 channel images has been passed in :attr:`batch`
          """
          logger.trace("Compiling targets")
          slices = self._constants["tgt_slices"]
          target_batch = [np.array([cv2.resize(image[slices, slices, :],
                                               (size, size),
 
</s> remove             the format (`batchsize`, `height`, `width`, `1`). **NB:** This item will only exist \
            in the ``dict`` if the :attr:`mask_type` is not ``None``

            * **samples** (`numpy.ndarray`) - A 4-dimensional array containg the samples for \
            feeding to the model's predict function for generating preview and timelapse samples. \
            The array will be in the format (`batchsize`, `height`, `width`, `channels`). **NB:** \
            This item will only exist in the ``dict`` if :attr:`is_preview` or \
            :attr:`is_timelapse` is ``True``
 </s> add             the format (`batchsize`, `height`, `width`, `1`).

            * **samples** (`numpy.ndarray`) - A 4-dimensional array containing the samples for \
            feeding to the model's predict function for generating preview and time-lapse \
            samples. The array will be in the format (`batchsize`, `height`, `width`, \
            `channels`). **NB:** This item will only exist in the ``dict`` if :attr:`is_preview` \
            or :attr:`is_timelapse` is ``True`` </s> remove         `height`, `width`, 3). If the :attr:`batch` is 4 channels, then the masks will be split
        from the batch, with the largest output masks being returned in their own item.
 </s> add         `height`, `width`, 3).

        The target masks are returned as its own item and is the 4th channel of the final target
        output. </s> remove     def _separate_target_mask(batch):
 </s> add     def _separate_target_mask(target_batch): </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                                   for image in batch])
 </s> add                                   for image in batch], dtype='float32') / 255.
            the format (`batchsize`, `height`, `width`, `1`).
              masks are not included in the ``targets`` list. If masks are to be included in the \
              output they will be returned as their own item from the ``masks`` key.
  
              * **masks** (`numpy.ndarray`) - A 4-dimensional array containing the target masks in \
            the format (`batchsize`, `height`, `width`, `1`).
            the format (`batchsize`, `height`, `width`, `1`).
          """
          logger.trace("Compiling targets")
          slices = self._constants["tgt_slices"]
          target_batch = [np.array([cv2.resize(image[slices, slices, :],
                                               (size, size),
keep keep keep keep 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