          method = cv2.INTER_CUBIC if scale > 1. else cv2.INTER_AREA  # pylint: disable=no-member
          resized = cv2.resize(image, (0, 0), fx=scale, fy=scale, interpolation=method)
          resized = resized if channels > 1 else resized[..., None]
          return resized
  
      @staticmethod
      def postprocessing(mask):
          """ Post-processing of Nirkin style segmentation masks """
          # Select_largest_segment
          if pop_small_segments:
              results = cv2.connectedComponentsWithStats(mask,  # pylint: disable=no-member
                                                         4,
                                                         cv2.CV_32S)  # pylint: disable=no-member
              _, labels, stats, _ = results
              segments_ranked_by_area = np.argsort(stats[:, -1])[::-1]
              mask[labels != segments_ranked_by_area[0, 0]] = 0.
  
          # Smooth contours
          if smooth_contours:
              iters = 2
              kernel = cv2.getStructuringElement(cv2.MORPH_RECT,  # pylint: disable=no-member
                                                 (5, 5))
              cv2.morphologyEx(mask, cv2.MORPH_OPEN,  # pylint: disable=no-member
                               kernel, iterations=iters)
              cv2.morphologyEx(mask, cv2.MORPH_CLOSE,  # pylint: disable=no-member
                               kernel, iterations=iters)
              cv2.morphologyEx(mask, cv2.MORPH_CLOSE,  # pylint: disable=no-member
                               kernel, iterations=iters)
              cv2.morphologyEx(mask, cv2.MORPH_OPEN,  # pylint: disable=no-member
                               kernel, iterations=iters)
  
          # Fill holes
          if fill_holes:
              not_holes = mask.copy()
              not_holes = np.pad(not_holes, ((2, 2), (2, 2), (0, 0)), 'constant')
              cv2.floodFill(not_holes, None, (0, 0), 255)  # pylint: disable=no-member
              holes = cv2.bitwise_not(not_holes)[2:-2, 2:-2]  # pylint: disable=no-member
              mask = cv2.bitwise_or(mask, holes)  # pylint: disable=no-member
              mask = np.expand_dims(mask, axis=-1)
          return mask
 
</s> remove                 hull = cv2.convexHull(item).astype('int32')  # pylint: disable=no-member
                cv2.fillConvexPoly(mask, hull, 255, lineType=cv2.LINE_AA)
        batch["prediction"] = masks
 </s> add                 hull = cv2.convexHull(item).astype("int32")  # pylint: disable=no-member
                cv2.fillConvexPoly(mask, hull, 1.0, lineType=cv2.LINE_AA)
        batch["prediction"] = batch["feed"] </s> remove                 hull = cv2.convexHull(item).astype('int32')  # pylint: disable=no-member
                cv2.fillConvexPoly(mask, hull, 255, lineType=cv2.LINE_AA)
        batch["prediction"] = masks
 </s> add                 hull = cv2.convexHull(item).astype("int32")  # pylint: disable=no-member
                cv2.fillConvexPoly(mask, hull, 1.0, lineType=cv2.LINE_AA)
        batch["prediction"] = batch["feed"] </s> remove         masks = np.zeros(batch["feed"].shape[:-1] + (1,), dtype='uint8')
        for mask, face in zip(masks, batch["detected_faces"]):
            parts = self.parse_parts(np.array(face.landmarks_xy))
 </s> add         for mask, face in zip(batch["feed"], batch["detected_faces"]):
            parts = self.parse_parts(np.array(face.feed_landmarks)) </s> remove         masks = np.zeros(batch["feed"].shape[:-1] + (1,), dtype='uint8')
        for mask, face in zip(masks, batch["detected_faces"]):
            parts = self.parse_parts(np.array(face.landmarks_xy))
 </s> add         for mask, face in zip(batch["feed"], batch["detected_faces"]):
            parts = self.parse_parts(np.array(face.feed_landmarks))
          method = cv2.INTER_CUBIC if scale > 1. else cv2.INTER_AREA  # pylint: disable=no-member
          resized = cv2.resize(image, (0, 0), fx=scale, fy=scale, interpolation=method)
          resized = resized if channels > 1 else resized[..., None]
          return resized




































keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace
 Mask plugin cleanup

- PEP8 Fixes
- Remove config for non NN Masks
- Tidy up defaults helptext
- cli.py fix typos
- Remove unused imports and functions _base.py
- Standardize input_size param
- Enable and update documentation
- Change references from `aligner` to `masker`
- Change  input_size, output_size and coverage_ratio from kwargs to params
- Move load_aligned to batch input iterator
- Remove unnecessary self.input param
- Add softmax layer append function to KSession
- Remove references to KSession protected objects
- Standardize plugin output into finalize method
- Make masks full frame and add to lib.faces_detect
- Add masks to alignments.json (temporary zipped base64 solution) 
plugins/extract/mask/_base.py