  
  
  class Align(object):
      """ Perform transformation to align and get landmarks """
      def __init__(self, frame, detected_faces, keras_model, verbose):
          self.verbose = verbose
          self.frame = frame.images[0]
          self.input_scale = frame.input_scale
          self.detected_faces = detected_faces
          self.keras = keras_model
 
</s> remove         self.frame = frame.images[0]
        self.input_scale = frame.input_scale
 </s> add         self.image = image </s> remove         self.bounding_box = None
 </s> add  </s> remove     @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)
 </s> add     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 </s> remove     def detect_faces(self, images):
        """ Detect faces in images """
 </s> add     def detect_faces(self, image):
        """ Detect faces in rgb image """ </s> remove         for current_image in images:
            detected_faces = detect_face(current_image, **self.kwargs)
            self.detected_faces = [dlib.rectangle(int(face[0]), int(face[1]),
                                                  int(face[2]), int(face[3]))
                                   for face in detected_faces]
            if self.detected_faces:
                break
 </s> add         detected_faces = detect_face(image, **self.kwargs)
        self.detected_faces = [dlib.rectangle(int(face[0]), int(face[1]),
                                              int(face[2]), int(face[3]))
                               for face in detected_faces]
    def __init__(self, image, detected_faces, keras_model, verbose):
  
  
  class Align(object):
      """ Perform transformation to align and get landmarks """
    def __init__(self, image, detected_faces, keras_model, verbose):
          self.verbose = verbose
          self.frame = frame.images[0]
          self.input_scale = frame.input_scale
          self.detected_faces = detected_faces
          self.keras = keras_model
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/extractor.py