              image = cv2.resize(image, dimensions, interpolation=cv2.INTER_AREA)
  
          return image
  
      @staticmethod
      def compile_color_space(image_bgr):
          """ cv2 and numpy inputs differs in rgb-bgr order
          this affects chance of dlib face detection so
          pass both versions """
          image_rgb = image_bgr[:, :, ::-1].copy()
          return (image_rgb, image_bgr)
  
  
  class Align(object):
      """ Perform transformation to align and get landmarks """
      def __init__(self, frame, detected_faces, keras_model, verbose):
 
</s> remove     def __init__(self, frame, detected_faces, keras_model, verbose):
 </s> add     def __init__(self, image, detected_faces, keras_model, verbose): </s> remove         self.frame = frame.images[0]
        self.input_scale = frame.input_scale
 </s> add         self.image = image </s> remove         if pixel_count > self.scale_to:
            self.input_scale = self.scale_to / pixel_count
            dimensions = (int(self.width * self.input_scale),
                          int(self.height * self.input_scale))
            if self.verbose:
                print("Resizing image from {}x{} "
                      "to {}.".format(str(self.width), str(self.height),
                                      "x".join(str(i) for i in dimensions)))
            image = cv2.resize(image, dimensions, interpolation=cv2.INTER_AREA)
 </s> add         if detector == "mtcnn":
            self.scale_mtcnn()
        else:
            self.scale_dlib()

        if self.input_scale == 1.0:
            return image

        if self.input_scale > 1.0:
            interpolation = cv2.INTER_LINEAR
        else:
            interpolation = cv2.INTER_AREA

        dimensions = (int(self.width * self.input_scale),
                      int(self.height * self.input_scale))
        if self.verbose and self.input_scale < 1.0:
            print("Resizing image from {}x{} "
                  "to {}.".format(str(self.width), str(self.height),
                                  "x".join(str(i) for i in dimensions)))
        image = cv2.resize(image,
                           dimensions,
                           interpolation=interpolation).copy() </s> remove             self.frame,
 </s> add             self.image,
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
              image = cv2.resize(image, dimensions, interpolation=cv2.INTER_AREA)
  
          return image
  
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
    def scale_mtcnn(self):
        """ Set scaling for mtcnn """
        pixel_count = self.width * self.height
        if pixel_count > VRAM.scale_to:
            self.input_scale = (VRAM.scale_to / pixel_count)**0.5

    def scale_dlib(self):
        """ Set scaling for dlib

        DLIB is finickity, and pure pixel count won't help as when an
        initial portrait image goes in, rotating it to landscape sucks
        up VRAM for no discernible reason. This does not happen when the
        initial image is a landscape image.
        To mitigate this we need to make sure that all images fit within
        a square based on the pixel count
        There is also no way to set the acceptable size for a positive
        match, so all images should be scaled to the maximum possible
        to detect all available faces """

        max_length_scale = int(VRAM.scale_to ** 0.5)
        max_length_image = max(self.height, self.width)
        self.input_scale = max_length_scale / max_length_image
  
  
  class Align(object):
      """ Perform transformation to align and get landmarks """
      def __init__(self, frame, detected_faces, keras_model, verbose):
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
 Merge staging to Master (#470)

* DLib scaling amends (#461)

* Scaling area fix and rework of frames and bounding boxes

* Update DLib scaling and initialization

* Extract - Detector reinitialization bugfix

* Slight OriginaHightRes Model re-factoring (#464)

* Model re-factoring, might fix red screen of death on multi-gpu configurations

* Limited trainer support for various INPUT_SIZE

* Auto Extraction multiprocess bugfix

* Sort tool bugfixes and linting 
lib/face_alignment/extractor.py