  
          if not VRAM.scale_to and VRAM.device != -1:
              VRAM.set_scale_to(detector)
  
          if VRAM.device != -1:
              self.scale_to = VRAM.scale_to
          else:
              self.scale_to = self.height * self.width
  
          self.input_scale = 1.0
          self.images = self.process_input(input_image,
                                           input_is_predetected_face)
  
 
</s> remove         if not VRAM.scale_to and VRAM.device != -1:
            VRAM.set_scale_to(detector)
 </s> add         self.input_scale = 1.0 </s> remove         self.input_scale = 1.0
        self.images = self.process_input(input_image,
                                         input_is_predetected_face)

    def process_input(self, input_image, input_is_predetected_face):
        """ Process import image:
            Size down if required
            Duplicate into rgb colour space """
        if not input_is_predetected_face:
            input_image = self.scale_down(input_image)
        return self.compile_color_space(input_image)

    def scale_down(self, image):
 </s> add     def scale_image(self, input_is_predetected_face, detector): </s> remove         free_mem = self.vram_free - buffer
 </s> add         if self.device != -1:
            free_mem = self.vram_free - buffer
        else:
            # Limit to 2GB if using CPU
            free_mem = 2048
 </s> remove         pixel_count = self.width * self.height
 </s> add         image = self.image_rgb
        if input_is_predetected_face:
            return 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()
        self.image_bgr = input_image
        self.image_rgb = input_image[:, :, ::-1].copy()
        self.image_detect = self.scale_image(input_is_predetected_face,
                                             detector)
  
          if not VRAM.scale_to and VRAM.device != -1:
              VRAM.set_scale_to(detector)
  
        self.image_bgr = input_image
        self.image_rgb = input_image[:, :, ::-1].copy()
        self.image_detect = self.scale_image(input_is_predetected_face,
                                             detector)
        self.image_bgr = input_image
        self.image_rgb = input_image[:, :, ::-1].copy()
        self.image_detect = self.scale_image(input_is_predetected_face,
                                             detector)
        self.image_bgr = input_image
        self.image_rgb = input_image[:, :, ::-1].copy()
        self.image_detect = self.scale_image(input_is_predetected_face,
                                             detector)
        self.image_bgr = input_image
        self.image_rgb = input_image[:, :, ::-1].copy()
        self.image_detect = self.scale_image(input_is_predetected_face,
                                             detector)
  
          self.input_scale = 1.0
          self.images = self.process_input(input_image,
                                           input_is_predetected_face)
  
keep keep keep keep replace replace replace replace keep keep keep keep keep
 DLib scaling amends (#461)

* Scaling area fix and rework of frames and bounding boxes

* Update DLib scaling and initialization 
lib/face_alignment/extractor.py