          for filename in self.input_dir:
              if self.arguments.verbose:
                  print('Processing: {}'.format(os.path.basename(filename)))
  
              self.process_image(filename)
              self.images_processed = self.images_processed + 1
  
          self.finalize()
  
      # for now, we limit this class responsability to the read of files. images and faces are processed outside this class
 
</s> remove 
        self.finalize()
 </s> add     
    def get_faces(self, image):
        faces_count = 0
        for face in detect_faces(image):
            if self.filter is not None and not self.filter.check(face):
                print('Skipping not recognized face!')
                continue

            yield faces_count, face

            self.faces_detected = self.faces_detected + 1
            faces_count +=1
        
        if faces_count > 0 and self.arguments.verbose:
            print('Note: Found more than one face in an image!')
            self.verify_output = True
    
    def load_filter(self):
        filter_file = "filter.jpg" # TODO Pass as argument
        if Path(filter_file).exists():
            print('Loading reference image for filtering')
            return FaceFilter(filter_file) </s> remove     def process_image(self, filename):
 </s> add     def process(self): </s> remove         self.process_directory()

    def process_directory(self):
 </s> add     def read_directory(self): </s> remove         print('Starting, this may take a while...')
 </s> add         import threading
        self.stop = False

        thr = threading.Thread(target=self.processThread, args=(), kwargs={})
        thr.start()

        if self.arguments.preview:
            print('Using live preview')
            while True:
                for name, image in self.preview_buffer.items():
                    cv2.imshow(name, image)

                key = cv2.waitKey(1000)
                if key == ord('\n') or key == ord('\r'):
                    break
        else:
            input() # TODO how to catch a specific key instead of Enter?

        print("Exit requested! The trainer will complete its current cycle, save the models and quit (it can take up a couple of seconds depending on your training speed). If you want to kill it now, press Ctrl + c")
        self.stop = True
        thr.join() # waits until thread finishes
    
    def processThread(self):
        variant = "Original" # TODO Pass as argument
        
        print('Loading data, this may take a while...')
        model = PluginLoader.get_model(variant)(self.arguments.model_dir)
        model.load(swapped=False)

            yield filename
          for filename in self.input_dir:
              if self.arguments.verbose:
                  print('Processing: {}'.format(os.path.basename(filename)))
  
            yield filename
              self.images_processed = self.images_processed + 1
  
          self.finalize()
  
      # for now, we limit this class responsability to the read of files. images and faces are processed outside this class
keep keep keep keep replace keep keep keep keep keep
 Adding models as plugins + Face filtering (#53) + #39 + #43 + #44 + #49 (#61)

* Making Models as plugins

* Do not reload model on each image #39 + Adding FaceFilter #53

* Adding @lukaville PR for #43 and #44 (possibly)

* Training done in a separate thread

* Better log for plugin load

* Adding a prefetch to train.py #49
(Note that we prefetch 2 batches of images, due to the queue behavior)
+ More compact logging with verbose info included

* correction of DirectoryProcessor signature

* adding missing import

* Convert with parallel preprocessing of files

* Added coverage var for trainer

Added a var with comment. Feel free to add it as argument

* corrections

* Modifying preview and normalization of image + correction

* Cleanup 
lib/cli.py