          self._augment_color = augment_color
          self._no_flip = no_flip
          self._warp_to_landmarks = warp_to_landmarks
          self._landmarks = alignments.get("landmarks", None)
          self._masks = alignments.get("masks", None)
          self._nearest_landmarks = {}
  
          # Batchsize and processing class are set when this class is called by a feeder
          # from lib.training_data
          self._batchsize = 0
 
</s> remove class TrainingDataGenerator():
 </s> add class TrainingDataGenerator():  # pylint:disable=too-few-public-methods </s> remove class PenalizedLoss():  # pylint:disable=too-few-public-methods
    """ Penalized Loss function.

    Applies the given loss function just to the masked area of the image.

    Parameters
    ----------
    loss_func: function
        The actual loss function to use
    mask_prop: float, optional
        The amount of mask propagation. Default: `1.0`
    """
    def __init__(self, loss_func, mask_prop=1.0):
        self._loss_func = loss_func
        self._mask_prop = mask_prop

    def __call__(self, y_true, y_pred):
        """ Apply the loss function to the masked area of the image.

        Parameters
        ----------
        y_true: tensor or variable
            The ground truth value. This should contain the mask in the 4th channel that will be
            split off for penalizing.
        y_pred: tensor or variable
            The predicted value

        Returns
        -------
        tensor
            The Loss value
        """
        mask = self._prepare_mask(K.expand_dims(y_true[..., -1], axis=-1))
        y_true = y_true[..., :-1]
        n_true = y_true * mask
        n_pred = y_pred * mask
        if isinstance(self._loss_func, DSSIMObjective):
            # Extract Image Patches in SSIM requires that y_pred be of a known shape, so
            # specifically reshape the tensor.
            n_pred = K.reshape(n_pred, K.int_shape(y_pred))
        return self._loss_func(n_true, n_pred)

    def _prepare_mask(self, mask):
        """ Prepare the masks for calculating loss

        Parameters
        ----------
        mask: :class:`numpy.ndarray`
            The masks for the current batch

        Returns
        -------
        tensor
            The prepared mask for applying to loss
        """
        mask_as_k_inv_prop = 1 - self._mask_prop
        mask = (mask * self._mask_prop) + mask_as_k_inv_prop
        return mask


 </s> add  </s> remove     single output.

    Parameters
    ----------
    loss_functions: list
        A list of either a tuple of (:class:`keras.losses.Loss`, scalar weight) or just a
        :class:`keras.losses.Loss` function. If just the loss function is passed, then the weight
        is assumed to be 1.0 """
    def __init__(self, loss_functions):
        logger.debug("Initializing: %s: (loss_functions: %s)",
                     self.__class__.__name__, loss_functions)
 </s> add     single output and masking.
    """
    def __init__(self):
        logger.debug("Initializing: %s", self.__class__.__name__) </s> remove             side_inputs, side_targets = self._get_next(side)
            if self._model.config["penalized_mask_loss"]:
                side_targets = self._compile_masks(side_targets)
                if not self._model.config["learn_mask"]:  # Remove masks from the model targets
                    side_targets = side_targets[:-1]
 </s> add             batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]] </s> remove         applies a dummy all ones mask """
        logger.trace("Input batch shape: %s, side: %s", batch.shape, side)
        if self._masks is None:
            logger.trace("Creating dummy masks. side: %s", side)
            masks = np.ones_like(batch[..., :1], dtype=batch.dtype)
        else:
            logger.trace("Obtaining masks for batch. side: %s", side)
            masks = np.array([self._masks[side][filename].mask
                              for filename, face in zip(filenames, batch)], dtype=batch.dtype)
            masks = self._resize_masks(batch.shape[1], masks)
 </s> add         applies a dummy all ones mask.

        If the configuration options `eye_multiplier` and/or `mouth_multiplier` are greater than 1
        then these masks are applied to the final channels of the batch respectively.

        Parameters
        ----------
        filenames: list
            The list of filenames that correspond to this batch
        batch: :class:`numpy.ndarray`
            The batch of faces that have been loaded from disk
        side: str
            '"a"' or '"b"' the side that is being processed
        self._masks = dict(masks=alignments.get("masks", None),
                           eyes=alignments.get("masks_eye", None),
                           mouths=alignments.get("masks_mouth", None))
          self._augment_color = augment_color
          self._no_flip = no_flip
          self._warp_to_landmarks = warp_to_landmarks
          self._landmarks = alignments.get("landmarks", None)
        self._masks = dict(masks=alignments.get("masks", None),
                           eyes=alignments.get("masks_eye", None),
                           mouths=alignments.get("masks_mouth", None))
          self._nearest_landmarks = {}
  
          # Batchsize and processing class are set when this class is called by a feeder
          # from lib.training_data
          self._batchsize = 0
keep keep keep keep replace keep keep keep keep keep
 Add Mouth and Eye Priority to Loss options (#1054)

* Priority Training for Mouth and Eyes - Tensorflow

* Use chosen loss function for area multipliers

* loss multipliers for AMD

* Fix mask multipliers for plaid and roll PenalizedMaskLoss into LossWrapper

* losses_tf: roll PenalizedMaskLoss into LossWrapper 
lib/training_data.py