          self.encoding = face_recognition.face_encodings(image)[0] # Note: we take only first face, so the reference file should only contain one face. We could also keep all faces found and filter against multiple faces
          self.threshold = threshold
      
      def check(self, detected_face):
          encodings = face_recognition.face_encodings(detected_face.image)[0] # we could use detected landmarks, but I did not manage to do so
          score = face_recognition.face_distance([self.encoding], encodings)
          print(score)
          return score <= self.threshold
  
  
  # # Copy/Paste (mostly) from private method in face_recognition
  # face_recognition_model = face_recognition_models.face_recognition_model_location()
  # face_encoder = dlib.face_recognition_model_v1(face_recognition_model)
  
 
</s> remove         self.encoding = face_recognition.face_encodings(image)[0] # Note: we take only first face, so the reference file should only contain one face. We could also keep all faces found and filter against multiple faces
 </s> add         self.encoding = face_recognition.face_encodings(image)[0] # Note: we take only first face, so the reference file should only contain one face.
 </s> remove         filter_file = "filter.jpg" # TODO Pass as argument
 </s> add         filter_file = self.arguments.filter </s> remove         # Original model goes with Adjust or Masked converter
        # does the LowMem one work with only one? 
        # seems to work with both in testing - although Adjust with LowMem 
        # looks a real mess - you can see that it is "working"
 </s> add         # Original & LowMem models go with Adjust or Masked converter </s> remove         trainer = trainer if trainer != "Lowmem" else "LowMem"
 </s> add         trainer = "LowMem" if trainer.lower() == "lowmem" else trainer </s> remove coverage = 220 # Coverage of the face for training. Larger value will cover more features. @shaoanlu recommends 220. Original is 160

random_transform_args = {
    'rotation_range': 10,
    'zoom_range': 0.05,
    'shift_range': 0.05,
    'random_flip': 0.4,
}

# GAN
# random_transform_args = {
#     'rotation_range': 20,
#     'zoom_range': 0.1,
#     'shift_range': 0.05,
#     'random_flip': 0.5,
#     }
def read_image(fn, random_transform_args=random_transform_args):
    image = cv2.imread(fn) / 255.0
    image = cv2.resize(image, (256,256))
    image = random_transform( image, **random_transform_args )
    warped_img, target_img = random_warp( image )
 </s> add class TrainingDataGenerator():
    def __init__(self, random_transform_args, coverage):
        self.random_transform_args = random_transform_args
        self.coverage = coverage

    def minibatchAB(self, images, batchsize):
        batch = BackgroundGenerator(self.minibatch(images, batchsize), 1)
        for ep1, warped_img, target_img in batch.iterator():
            yield ep1, warped_img, target_img

    # A generator function that yields epoch, batchsize of warped_img and batchsize of target_img
    def minibatch(self, data, batchsize):
        length = len(data)
        assert length >= batchsize, "Number of images is lower than batch-size (Note that too few images may lead to bad training). # images: {}, batch-size: {}".format(length, batchsize)
        epoch = i = 0
        shuffle(data)
        while True:
            size = batchsize
            if i+size > length:
                shuffle(data)
                i = 0
                epoch+=1
            rtn = numpy.float32([self.read_image(img) for img in data[i:i+size]])
            i+=size
            yield epoch, rtn[:,0,:,:,:], rtn[:,1,:,:,:]       

    def color_adjust(self, img):
        return img / 255.0

        encodings = face_recognition.face_encodings(detected_face.image) # we could use detected landmarks, but I did not manage to do so. TODO The copy/paste below should help
        if encodings is not None and len(encodings) > 0:
            score = face_recognition.face_distance([self.encoding], encodings[0])
            print(score)
            return score <= self.threshold
        else:
            print("No face encodings found")
            return False

          self.encoding = face_recognition.face_encodings(image)[0] # Note: we take only first face, so the reference file should only contain one face. We could also keep all faces found and filter against multiple faces
          self.threshold = threshold
      
      def check(self, detected_face):
        encodings = face_recognition.face_encodings(detected_face.image) # we could use detected landmarks, but I did not manage to do so. TODO The copy/paste below should help
        if encodings is not None and len(encodings) > 0:
            score = face_recognition.face_distance([self.encoding], encodings[0])
            print(score)
            return score <= self.threshold
        else:
            print("No face encodings found")
            return False
        encodings = face_recognition.face_encodings(detected_face.image) # we could use detected landmarks, but I did not manage to do so. TODO The copy/paste below should help
        if encodings is not None and len(encodings) > 0:
            score = face_recognition.face_distance([self.encoding], encodings[0])
            print(score)
            return score <= self.threshold
        else:
            print("No face encodings found")
            return False
        encodings = face_recognition.face_encodings(detected_face.image) # we could use detected landmarks, but I did not manage to do so. TODO The copy/paste below should help
        if encodings is not None and len(encodings) > 0:
            score = face_recognition.face_distance([self.encoding], encodings[0])
            print(score)
            return score <= self.threshold
        else:
            print("No face encodings found")
            return False
        encodings = face_recognition.face_encodings(detected_face.image) # we could use detected landmarks, but I did not manage to do so. TODO The copy/paste below should help
        if encodings is not None and len(encodings) > 0:
            score = face_recognition.face_distance([self.encoding], encodings[0])
            print(score)
            return score <= self.threshold
        else:
            print("No face encodings found")
            return False
        encodings = face_recognition.face_encodings(detected_face.image) # we could use detected landmarks, but I did not manage to do so. TODO The copy/paste below should help
        if encodings is not None and len(encodings) > 0:
            score = face_recognition.face_distance([self.encoding], encodings[0])
            print(score)
            return score <= self.threshold
        else:
            print("No face encodings found")
            return False
  
  # # Copy/Paste (mostly) from private method in face_recognition
  # face_recognition_model = face_recognition_models.face_recognition_model_location()
  # face_encoder = dlib.face_recognition_model_v1(face_recognition_model)
  
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Misc updates on master before GAN. Added multithreading + mmod face detector (#109)

* Preparing GAN plugin

* Adding multithreading for extract

* Adding support for mmod human face detector

* Adding face filter argument

* Added process number argument to multiprocessing extractor.

Fixed progressbar for multiprocessing.

* Added tiff as image type.
compression artefacts hurt my feelings.

* Cleanup 
lib/FaceFilter.py