              self.get_available_vram()
              gradient = 213 / 524288
              constant = 307
  
          free_mem = self.vram_free - buffer
          self.scale_to = int((free_mem - constant) / gradient)
  
          if self.scale_to < 4097:
              raise ValueError("Images would be shrunk too much "
                               "for successful extraction")
 
</s> remove         scale = (self.bounding_box['right']
                 - self.bounding_box['left']
                 + self.bounding_box['bottom']
                 - self.bounding_box['top']) / 195.0
 </s> add         scale = (detected_face['right']
                 - detected_face['left']
                 + detected_face['bottom']
                 - detected_face['top']) / 195.0 </s> remove         center[1] -= (self.bounding_box['bottom']
                      - self.bounding_box['top']) * 0.12
 </s> add         center[1] -= (detected_face['bottom']
                      - detected_face['top']) * 0.12 </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         if not VRAM.scale_to and VRAM.device != -1:
            VRAM.set_scale_to(detector)
 </s> add         self.input_scale = 1.0 </s> remove         if VRAM.device != -1:
            self.scale_to = VRAM.scale_to
        else:
            self.scale_to = self.height * self.width
 </s> add         self.image_bgr = input_image
        self.image_rgb = input_image[:, :, ::-1].copy()
        self.image_detect = self.scale_image(input_is_predetected_face,
                                             detector)
        if self.device != -1:
            free_mem = self.vram_free - buffer
        else:
            # Limit to 2GB if using CPU
            free_mem = 2048

              self.get_available_vram()
              gradient = 213 / 524288
              constant = 307
  
        if self.device != -1:
            free_mem = self.vram_free - buffer
        else:
            # Limit to 2GB if using CPU
            free_mem = 2048

          self.scale_to = int((free_mem - constant) / gradient)
  
          if self.scale_to < 4097:
              raise ValueError("Images would be shrunk too much "
                               "for successful extraction")
keep keep keep keep 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/vram_allocation.py