  
  from lib.aligner import Extract as AlignerExtract
  from lib.alignments import Alignments, get_serializer
  from lib.faces_detect import DetectedFace
  from lib.image import (count_frames, encode_image_with_hash, read_image,
                         read_image_hash_batch)
  from lib.utils import _image_extensions, _video_extensions
  
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
 
</s> remove class Extract():
    """ Re-extract faces from source frames based on
        Alignment data """
 </s> add class Extract():  # pylint:disable=too-few-public-methods
    """ Re-extract faces from source frames based on Alignment data

    Parameters
    ----------
    alignments: :class:`tools.lib_alignments.media.AlignmentData`
        The alignments data loaded from an alignments file for this rename job
    arguments: :class:`argparse.Namespace`
        The :mod:`argparse` arguments as passed in from :mod:`tools.py`
    """ </s> remove         image = self.frames.load_image(frame)
        self.faces = [self.extract_one_face(alignment, image.copy()) for alignment in alignments]
 </s> add         image = self.frames.load_image(frame) if image is None else image
        self.faces = [self.extract_one_face(alignment, image) for alignment in alignments] </s> remove         """ Run extraction """
 </s> add         """ Run the re-extraction from Alignments file process""" </s> remove     def select_valid_faces(self, frame):
        """ Return valid faces for extraction """
        faces = self.extracted_faces.get_faces_in_frame(frame)
        if not self.arguments.large:
 </s> add     def _select_valid_faces(self, frame, image):
        """ Return the aligned faces from a frame that meet the selection criteria,

        Parameters
        ----------
        frame: str
            The filename (without the full path) of the current frame
        image: :class:`numpy.ndarray`
            The full frame that faces are to be extracted from

        Returns
        -------
        list:
            List of valid :class:`lib,faces_detect.DetectedFace` objects
        """
        faces = self._extracted_faces.get_faces_in_frame(frame, image=image)
        if not self._arguments.large: </s> remove         self.arguments = arguments
        self.alignments = alignments
        self.faces_dir = arguments.faces_dir
        self.frames = Frames(arguments.frames_dir)
        self.extracted_faces = ExtractedFaces(self.frames,
                                              self.alignments,
                                              size=arguments.size,
                                              align_eyes=arguments.align_eyes)
 </s> add         self._arguments = arguments
        self._alignments = alignments
        self._faces_dir = arguments.faces_dir
        self._frames = Frames(arguments.frames_dir)
        self._extracted_faces = ExtractedFaces(self._frames,
                                               self._alignments,
                                               size=arguments.size,
                                               align_eyes=arguments.align_eyes)
from lib.image import (count_frames, encode_image_with_hash, ImagesLoader, read_image,
  
  from lib.aligner import Extract as AlignerExtract
  from lib.alignments import Alignments, get_serializer
  from lib.faces_detect import DetectedFace
from lib.image import (count_frames, encode_image_with_hash, ImagesLoader, read_image,
                         read_image_hash_batch)
  from lib.utils import _image_extensions, _video_extensions
  
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
keep keep keep keep replace keep keep keep keep keep
 lib.alignments: improve re-extraction speed by 500% 
tools/lib_alignments/media.py