                                               cv2.INTER_AREA)
                                    for image in batch], dtype='float32') / 255.
                          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()})
 
</s> remove                       masks=[target_batch[-1][..., 3:]])
        logger.trace("returning: %s", {k: [tgt.shape for tgt in v] for k, v in retval.items()})
 </s> add                       masks=target_batch[-1][..., 3][..., None])
        if target_batch[-1].shape[-1] > 4:
            retval["additional_masks"] = target_batch[-1][..., 4:]
        logger.trace("returning: %s", {k: v.shape if isinstance(v, np.ndarray) else [tgt.shape
                                                                                     for tgt in v]
                                       for k, v in retval.items()}) </s> remove         logger.debug(retval)
 </s> add         if self._model.config["eye_multiplier"] > 1:
            retval["masks_eye"] = alignments.masks_eye

        if self._model.config["mouth_multiplier"] > 1:
            retval["masks_mouth"] = alignments.masks_mouth

        logger.debug({key: {k: len(v) for k, v in val.items()} for key, val in retval.items()}) </s> remove         The target masks are returned as its own item and is the 4th channel of the final target
        output.
 </s> add         Returns
        -------
        dict:
            The targets and the masks separated into their own items. The targets are a list of
            3 channel, 4 dimensional :class:`numpy.ndarray` objects sized for each output from the
            model. The masks are a :class:`numpy.ndarray` of the final output size. Any additional
            masks(e.g. eye and mouth masks) will be collated together into a :class:`numpy.ndarray`
            of the final output size. The number of channels will be the number of additional
            masks available </s> remove                 if (self._config["loss_function"] in self._uses_l2_reg
                        and self._config["l2_reg_term"] != 0):
                    loss_funcs = [selected_loss, self._loss_dict["mse"]]
                    loss_weights = [1.0, self._config["l2_reg_term"] / 100.0]
                else:
                    loss_funcs = [selected_loss]
                    loss_weights = [1.0]

                if self._config["penalized_mask_loss"]:
                    loss_funcs = [losses.PenalizedLoss(loss) for loss in loss_funcs]

                loss_func = losses.LossWrapper(loss_functions=list(zip(loss_funcs, loss_weights)))
 </s> add                 loss_func = losses.LossWrapper()
                loss_func.add_loss(face_loss, mask_channel=mask_channels[0])
                self._add_l2_regularization_term(loss_func, mask_channels[0])

                mask_channel = 1
                for multiplier in ("eye_multiplier", "mouth_multiplier"):
                    if self._config[multiplier] > 1:
                        loss_func.add_loss(face_loss,
                                           weight=self._config[multiplier] * 1.0,
                                           mask_channel=mask_channels[mask_channel])
                        self._add_l2_regularization_term(loss_func, mask_channel)
                    mask_channel += 1 </s> remove         logger.trace("masks shape: %s", masks.shape)
        batch = np.concatenate((batch, masks), axis=-1)
 </s> add         Returns
        -------
        :class:`numpy.ndarray`
            The batch with masks applied to the final channels
        """
        logger.trace("Input batch shape: %s, side: %s", batch.shape, side)
        size = batch.shape[1]
        for key in ("masks", "eyes", "mouths"):
            item = self._masks[key]
            if item is None and key != "masks":
                continue
            if item is None and key == "masks":
                logger.trace("Creating dummy masks. side: %s", side)
                masks = np.ones_like(batch[..., :1], dtype=batch.dtype)
            else:
                logger.trace("Obtaining masks for batch. (key: %s side: %s)", key, side)
                masks = np.array([self._get_mask(item[side][filename], size)
                                  for filename, face in zip(filenames, batch)], dtype=batch.dtype)
                masks = self._resize_masks(size, masks)

            logger.trace("masks: (key: %s, shape: %s)", key, masks.shape)
            batch = np.concatenate((batch, masks), axis=-1)
                     [tgt_images.shape for tgt_images in target_batch])
                                               cv2.INTER_AREA)
                                    for image in batch], dtype='float32') / 255.
                          for size in self._output_sizes]
          logger.trace("Target image shapes: %s",
                     [tgt_images.shape 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
 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