                                     centering="legacy",
                                     size=256,
                                     is_aligned=True)
              mask = det_face.mask["components"]
              mask.set_sub_crop(aln_face.pose.offset[mask.stored_centering] * -1, centering="legacy")
              mask = cv2.resize(mask.mask, (256, 256), interpolation=cv2.INTER_CUBIC)[..., None]
              image = np.minimum(aln_face.face, mask)
          if image.ndim == 3:
              image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
          height, width = image.shape
 
</s> remove             mask.set_sub_crop(aln_face.pose.offset[mask.stored_centering] * -1, centering="legacy")
 </s> add             mask.set_sub_crop(aln_face.pose.offset[mask.stored_centering],
                              aln_face.pose.offset["legacy"],
                              centering="legacy") </s> remove             mask = self._get_stored_mask(detected_face, centering, sub_crop_offset)
 </s> add             mask = self._get_stored_mask(detected_face, centering, source_offset, target_offset) </s> remove def get_centered_size(source_centering, target_centering, size):
    """ Obtain the size of a cropped face from an aligned image.

    Given an image of a certain dimensions, returns the dimensions of the sub-crop within that
    image for the requested centering.

    Notes
    -----
    `"legacy"` places the nose in the center of the image (the original method for aligning).
    `"face"` aligns for the nose to be in the center of the face (top to bottom) but the center
    of the skull for left to right. `"head"` places the center in the middle of the skull in 3D
    space.

    The ROI in relation to the source image is calculated by rounding the padding of one side
    to the nearest integer then applying this padding to the center of the crop, to ensure that
    any dimensions always have an even number of pixels.

    Parameters
    ----------
    source_centering: ["head", "face", "legacy"]
        The centering that the original image is aligned at
    target_centering: ["head", "face", "legacy"]
        The centering that the sub-crop size should be obtained for
    size: int
        The size of the source image to obtain the cropped size for

    Returns
    -------
    int
        The pixel size of a sub-crop image from a full head aligned image
    """
    if source_centering == target_centering:
        retval = size
    else:
        src_size = size - (size * _EXTRACT_RATIOS[source_centering])
        retval = 2 * int(np.rint(src_size / (1 - _EXTRACT_RATIOS[target_centering]) / 2))
    logger.trace("source_centering: %s, target_centering: %s, size: %s, crop_size: %s",
                 source_centering, target_centering, size, retval)
    return retval


 </s> add  </s> remove         self._sub_crop["size"] = crop_size
        self._sub_crop["slice_in"] = [slice(max(roi[1], 0), max(roi[3], 0)),
                                      slice(max(roi[0], 0), max(roi[2], 0))]
        self._sub_crop["slice_out"] = [
 </s> add         self._sub_crop_size = crop_size
        self._sub_crop_slices["in"] = [slice(max(roi[1], 0), max(roi[3], 0)),
                                       slice(max(roi[0], 0), max(roi[2], 0))]
        self._sub_crop_slices["out"] = [ </s> remove             mask = np.float32(mask) / 255.
        return mask

    def _crop_to_coverage(self, mask: np.ndarray) -> np.ndarray:
        """ Crop the mask to the correct dimensions based on coverage ratio.

        Parameters
        ----------
        mask: :class:`numpy.ndarray`
            The original mask to be cropped

        Returns
        -------
        :class:`numpy.ndarray`
            The cropped mask
        """
        if self._coverage_ratio == 1.0:
            return mask
        mask_size = mask.shape[0]
        padding = round((mask_size * (1 - self._coverage_ratio)) / 2)
        mask_slice = slice(padding, mask_size - padding)
        mask = mask[mask_slice, mask_slice, :]
        logger.trace("mask_size: %s, coverage: %s, padding: %s, final shape: %s",  # type: ignore
                     mask_size, self._coverage_ratio, padding, mask.shape)
        return mask
 </s> add             face_mask = face_mask.astype("float32") / 255.
        return face_mask
            mask.set_sub_crop(aln_face.pose.offset[mask.stored_centering],
                              aln_face.pose.offset["legacy"],
                              centering="legacy")
                                     centering="legacy",
                                     size=256,
                                     is_aligned=True)
              mask = det_face.mask["components"]
            mask.set_sub_crop(aln_face.pose.offset[mask.stored_centering],
                              aln_face.pose.offset["legacy"],
                              centering="legacy")
              mask = cv2.resize(mask.mask, (256, 256), interpolation=cv2.INTER_CUBIC)[..., None]
              image = np.minimum(aln_face.face, mask)
          if image.ndim == 3:
              image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
          height, width = image.shape
keep keep keep keep replace keep keep keep keep keep
 lib.detected_face.Mask
  - Add source + target offset and coverage to set_sub_crop method 
tools/sort/sort.py