  #!/usr/bin/env python3
  """
  Return a requested detector/aligner pipeline
  
  Tensorflow does not like to release GPU VRAM, so these are launched in subprocesses
  so that the vram is released on subprocess exit """
  
  import logging
  
  from lib.gpu_stats import GPUStats
  from lib.multithreading import PoolProcess, SpawnProcess
 
</s> remove from lib.multithreading import PoolProcess, SpawnProcess
 </s> add  </s> remove import multiprocessing as mp
from multiprocessing.sharedctypes import RawArray
from ctypes import c_float
 </s> add from multiprocessing import cpu_count </s> remove         self.align_faces(detector, aligner, loglevel, multiprocess)
 </s> add         # TODO Revert face-filter to use the selected detector and aligner.
        # Currently Tensorflow does not release vram after it has been allocated
        # Whilst this vram can still be used, the pipeline for the extraction process can't see
        # it so thinks there is not enough vram available.
        # Either the pipeline will need to be changed to be re-usable by face-filter and extraction
        # Or another vram measurement technique will need to be implemented to for when TF has
        # already performed allocation. For now we force CPU detectors.

        # self.align_faces(detector, aligner, multiprocess)
        self.align_faces("cv2-dnn", "cv2-dnn", multiprocess)

 </s> remove logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
 </s> add """
import cv2
import numpy as np

from lib.faces_detect import DetectedFace
from lib.utils import rotate_landmarks
from plugins.extract._base import Extractor, logger


class Detector(Extractor):
    """ Detector Object

    Parent class for all Detector plugins

    Parameters
    ----------
    git_model_id: int
        The second digit in the github tag that identifies this model. See
        https://github.com/deepfakes-models/faceswap-models for more information
    model_filename: str
        The name of the model file to be loaded
    rotation: str, optional
        Pass in a single number to use increments of that size up to 360, or pass in a ``list`` of
        ``ints`` to enumerate exactly what angles to check. Can also pass in ``'on'`` to increment
        at 90 degree intervals. Default: ``None``
    min_size: int, optional
        Filters out faces detected below this size. Length, in pixels across the diagonal of the
        bounding box. Set to ``0`` for off. Default: ``0``

    Other Parameters
    ----------------
    configfile: str, optional
        Path to a custom configuration ``ini`` file. Default: Use system configfile

    See Also
    --------
    plugins.extract.pipeline : The extraction pipeline for calling plugins
    plugins.extract.detect : Detector plugins
    plugins.extract._base : Parent class for all extraction plugins
    plugins.extract.align._base : Aligner parent class for extraction plugins. </s> remove from io import StringIO
 </s> add 
Tensorflow does not like to release GPU VRAM, so parallel plugins need to be managed to work
together.

This module sets up a pipeline for the extraction workflow, loading align and detect plugins
either in parallal or in series, giving easy access to input and output.

 """
  #!/usr/bin/env python3
  """
  Return a requested detector/aligner pipeline
  
Tensorflow does not like to release GPU VRAM, so parallel plugins need to be managed to work
together.

This module sets up a pipeline for the extraction workflow, loading align and detect plugins
either in parallal or in series, giving easy access to input and output.

 """
Tensorflow does not like to release GPU VRAM, so parallel plugins need to be managed to work
together.

This module sets up a pipeline for the extraction workflow, loading align and detect plugins
either in parallal or in series, giving easy access to input and output.

 """
  
  import logging
  
  from lib.gpu_stats import GPUStats
  from lib.multithreading import PoolProcess, SpawnProcess
keep keep keep keep replace replace keep keep keep keep keep
 De-Multiprocess Extract (#871)

* requirements.txt: - Pin opencv to 4.1.1 (fixes cv2-dnn error)

* lib.face_detect.DetectedFace: change LandmarksXY to landmarks_xy. Add left, right, top, bottom attributes

* lib.model.session: Session manager for loading models into different graphs (for Nvidia + CPU)

* plugins.extract._base: New parent class for all extract plugins

* plugins.extract.pipeline. Remove MultiProcessing. Dynamically limit batchsize for Nvidia cards. Remove loglevel input

* S3FD + FAN plugins. Standardise to Keras version for all backends

* Standardize all extract plugins to new threaded codebase

* Documentation. Start implementing Numpy style docstrings for Sphinx Documentation

* Remove s3fd_amd. Change convert OTF to expect DetectedFace object

* faces_detect - clean up and documentation

* Remove PoolProcess

* Migrate manual tool to new extract workflow

* Remove AMD specific extractor code from cli and plugins

* Sort tool to new extract workflow

* Remove multiprocessing from project

* Remove multiprocessing queues from QueueManager

* Remove multiprocessing support from logger

* Move face_filter to new extraction pipeline

* Alignments landmarksXY > landmarks_xy and legacy handling

* Intercept get_backend for sphinx doc build

# Add Sphinx documentation 
plugins/extract/pipeline.py